diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/dist/ft.vim | 11 | ||||
-rw-r--r-- | runtime/autoload/provider/clipboard.vim | 12 | ||||
-rw-r--r-- | runtime/doc/api.txt | 2 | ||||
-rw-r--r-- | runtime/doc/change.txt | 17 | ||||
-rw-r--r-- | runtime/doc/cmdline.txt | 3 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 3 | ||||
-rw-r--r-- | runtime/doc/index.txt | 13 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 15 | ||||
-rw-r--r-- | runtime/doc/map.txt | 2 | ||||
-rw-r--r-- | runtime/doc/options.txt | 12 | ||||
-rw-r--r-- | runtime/doc/quickfix.txt | 5 | ||||
-rw-r--r-- | runtime/doc/starting.txt | 8 | ||||
-rw-r--r-- | runtime/doc/tips.txt | 2 | ||||
-rw-r--r-- | runtime/doc/ui.txt | 14 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 13 | ||||
-rw-r--r-- | runtime/doc/various.txt | 3 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 3 | ||||
-rw-r--r-- | runtime/filetype.vim | 16 | ||||
-rw-r--r-- | runtime/lua/vim/_meta.lua | 147 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 6 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 4 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 13 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 21 | ||||
-rw-r--r-- | runtime/syntax/lsp_markdown.vim | 10 | ||||
-rw-r--r-- | runtime/syntax/vim.vim | 11 |
26 files changed, 259 insertions, 109 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 1ac74b5785..ac80659113 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -172,6 +172,17 @@ func dist#ft#FTent() setf dtd endfunc +func dist#ft#ExCheck() + let lines = getline(1, min([line("$"), 100])) + if exists('g:filetype_euphoria') + exe 'setf ' . g:filetype_euphoria + elseif match(lines, '^--\|^ifdef\>\|^include\>') > -1 + setf euphoria3 + else + setf elixir + endif +endfunc + func dist#ft#EuphoriaCheck() if exists('g:filetype_euphoria') exe 'setf ' . g:filetype_euphoria diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index 07f37d604f..dea79f21f0 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -156,7 +156,14 @@ function! s:clipboard.get(reg) abort elseif s:selections[a:reg].owner > 0 return s:selections[a:reg].data end - return s:try_cmd(s:paste[a:reg]) + + let clipboard_data = s:try_cmd(s:paste[a:reg]) + if match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 && get(s:selections[a:reg].data, 0, []) == clipboard_data + " When system clipboard return is same as our cache return the cache + " as it contains regtype information + return s:selections[a:reg].data + end + return clipboard_data endfunction function! s:clipboard.set(lines, regtype, reg) abort @@ -175,6 +182,9 @@ function! s:clipboard.set(lines, regtype, reg) abort if s:cache_enabled == 0 call s:try_cmd(s:copy[a:reg], a:lines) + "Cache it anyway we can compare it later to get regtype of the yank + let s:selections[a:reg] = copy(s:selection) + let s:selections[a:reg].data = [a:lines, a:regtype] return 0 end diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 919417f3a0..07c45c9298 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -422,7 +422,7 @@ Buffer text can be highlighted by typical mechanisms (syntax highlighting, options from the current window; specify `style=minimal` in |nvim_open_win()| to disable various visual features such as the 'number' column. -Currently, floating windows don't support widgets like border or scrollbar. +Currently, floating windows don't support some widgets like scrollbar. Example: create a float with scratch buffer: > diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 49c6d06fbf..7a63a89986 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -913,22 +913,7 @@ This replaces an end-of-line with a new line containing the value of $HOME. > This replaces each 'E' character with a euro sign. Read more in |<Char->|. -4.3 Search and replace *search-replace* - - *:pro* *:promptfind* -:promptf[ind] [string] - Put up a Search dialog. When [string] is given, it is - used as the initial search string. - {only for Win32 GUI} - - *:promptr* *:promptrepl* -:promptr[epl] [string] - Put up a Search/Replace dialog. When [string] is - given, it is used as the initial search string. - {only for Win32 GUI} - - -4.4 Changing tabs *change-tabs* +4.3 Changing tabs *change-tabs* *:ret* *:retab* *:retab!* :[range]ret[ab][!] [new_tabstop] Replace all sequences of white-space containing a diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index dcdc2384dc..2db694cf07 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -532,7 +532,6 @@ that see the '"' as part of their argument: :normal :ownsyntax :popup - :promptfind (and the like) :registers :return :sort @@ -571,8 +570,6 @@ followed by another Vim command: :make :normal :perlfile - :promptfind - :promptrepl :pyfile :python :registers diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9f44c016f0..bf7f2b21de 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -7879,7 +7879,8 @@ setqflist({list} [, {action}[, {what}]]) *setqflist()* the last quickfix list. quickfixtextfunc function to get the text to display in the - quickfix window. Refer to + quickfix window. The value can be the name of + a function or a funcref or a lambda. Refer to |quickfix-window-function| for an explanation of how to write the function and an example. title quickfix list title text. See |quickfix-title| diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index c54b588e6b..2aafc075a6 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1201,6 +1201,7 @@ tag command action ~ |:cgetfile| :cg[etfile] read file with error messages |:changes| :changes print the change list |:chdir| :chd[ir] change directory +|:checkhealth| :checkh[ealth] run healthchecks |:checkpath| :che[ckpath] list included files |:checktime| :checkt[ime] check timestamp of loaded buffers |:chistory| :chi[story] list the error lists @@ -1278,6 +1279,7 @@ tag command action ~ |:endtry| :endt[ry] end previous :try |:endwhile| :endw[hile] end previous :while |:enew| :ene[w] edit a new, unnamed buffer +|:eval| :ev[al] evaluate an expression and discard the result |:ex| :ex same as ":edit" |:execute| :exe[cute] execute result of expressions |:exit| :exi[t] same as ":xit" @@ -1451,14 +1453,12 @@ tag command action ~ |:packloadall| :packl[oadall] load all packages under 'packpath' |:pclose| :pc[lose] close preview window |:pedit| :ped[it] edit file in the preview window -|:perl| :perl execute perl command -|:perldo| :perldo execute perl command for each line -|:perfile| :perlfile execute perl script file +|:perl| :pe[rl] execute perl command +|:perldo| :perld[o] execute perl command for each line +|:perlfile| :perlf[ile] execute perl script file |:print| :p[rint] print lines |:profdel| :profd[el] stop profiling a function or script |:profile| :prof[ile] profiling functions and scripts -|:promptfind| :pro[mptfind] open GUI dialog for searching -|:promptrepl| :promptr[epl] open GUI dialog for search/replace |:pop| :po[p] jump to older entry in tag stack |:popup| :popu[p] popup a menu by name |:ppop| :pp[op] ":pop" in preview window @@ -1537,7 +1537,6 @@ tag command action ~ buffer list |:scriptnames| :scr[iptnames] list names of all sourced Vim scripts |:scriptencoding| :scripte[ncoding] encoding used in sourced Vim script -|:scriptversion| :scriptv[ersion] version of Vim script used |:scscope| :scs[cope] split window and execute cscope command |:set| :se[t] show or set options |:setfiletype| :setf[iletype] set 'filetype', unless it was set already @@ -1549,8 +1548,6 @@ tag command action ~ |:sign| :sig[n] manipulate signs |:silent| :sil[ent] run a command silently |:sleep| :sl[eep] do nothing for a few seconds -|:sleep!| :sl[eep]! do nothing for a few seconds, without the - cursor visible |:slast| :sla[st] split window and go to last file in the argument list |:smagic| :sm[agic] :substitute with 'magic' diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index aa95245bd0..d6ef761bcb 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -135,12 +135,6 @@ FAQ *lsp-faq* autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) < - *vim.lsp.callbacks* -- Q: What happened to `vim.lsp.callbacks`? - A: After better defining the interface of |lsp-handler|s, we thought it best - to remove the generic usage of `callbacks` and transform to `handlers`. - Due to this, `vim.lsp.callbacks` was renamed to |vim.lsp.handlers|. - *lsp-vs-treesitter* - Q: How do LSP and Treesitter compare? A: LSP requires a client and language server. The language server uses @@ -525,6 +519,15 @@ LspDiagnosticsSignHint Used for "Hint" signs in sign column. See |vim.lsp.diagnostic.set_signs()| + *lsp-highlight-codelens* + +Highlight groups related to |lsp-codelens| functionality. + + *hl-LspCodeLens* +LspCodeLens + Used to color the virtual text of the codelens. See + |nvim_buf_set_virtual_text()|. + ============================================================================== AUTOCOMMANDS *lsp-autocommands* diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 77cbf7d9b7..10d503e180 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -855,7 +855,7 @@ Here is an example that counts the number of spaces with <F4>: > set clipboard= selection=inclusive let commands = #{line: "'[V']y", char: "`[v`]y", block: "`[\<c-v>`]y"} silent exe 'noautocmd keepjumps normal! ' .. get(commands, a:type, '') - echom getreg('"')->count(' ') + echom count(getreg('"'), ' ') finally call setreg('"', reg_save) call setpos("'<", visual_marks_save[0]) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index cc9696e536..791fb8664e 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4607,7 +4607,8 @@ A jump table for the options with a short description can be found at |Q_op|. customize the information displayed in the quickfix or location window for each entry in the corresponding quickfix or location list. See |quickfix-window-function| for an explanation of how to write the - function and an example. + function and an example. The value can be the name of a function or a + lambda. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. @@ -5237,11 +5238,12 @@ A jump table for the options with a short description can be found at |Q_op|. Note that such processing is done after |:set| did its own round of unescaping, so to keep yourself sane use |:let-&| like shown above. *shell-powershell* - To use powershell: > + To use PowerShell: > let &shell = has('win32') ? 'powershell' : 'pwsh' - set shellquote= shellpipe=\| shellxquote= - set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command - set shellredir=\|\ Out-File\ -Encoding\ UTF8 + let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' + let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' + let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' + set shellquote= shellxquote= < This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index ebc7e2a1b4..563fb0c962 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1919,7 +1919,10 @@ The function should return a single line of text to display in the quickfix window for each entry from start_idx to end_idx. The function can obtain information about the entries using the |getqflist()| function and specifying the quickfix list identifier "id". For a location list, getloclist() function -can be used with the 'winid' argument. +can be used with the 'winid' argument. If an empty list is returned, then the +default format is used to display all the entries. If an item in the returned +list is an empty string, then the default format is used to display the +corresponding entry. If a quickfix or location list specific customization is needed, then the 'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 2110b88330..5431ce3bd8 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -416,11 +416,11 @@ accordingly. Vim proceeds in this order: the same time. Each line in a "init.vim" is executed as an Ex command line. See also |vimrc-intro| and |base-directories|. - The Nvim config file is "init.vim", located at: - Unix ~/.config/nvim/init.vim - Windows ~/AppData/Local/nvim/init.vim + The config file is located at: + Unix ~/.config/nvim/init.vim (or init.lua) + Windows ~/AppData/Local/nvim/init.vim (or init.lua) or if |$XDG_CONFIG_HOME| is defined: - $XDG_CONFIG_HOME/nvim/init.vim + $XDG_CONFIG_HOME/nvim/init.vim (or init.lua) If Nvim was started with "-u {file}" then {file} is used as the config and all initializations until 5. are skipped. $MYVIMRC is not set. diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt index bcb2e48cbf..27b6ca2885 100644 --- a/runtime/doc/tips.txt +++ b/runtime/doc/tips.txt @@ -462,7 +462,7 @@ the current window, try this custom `:HelpCurwin` command: execute mods .. ' helpclose' let s:did_open_help = v:true endif - if !getcompletion(a:subject, 'help')->empty() + if !empty(getcompletion(a:subject, 'help')) execute mods .. ' edit ' .. &helpfile endif return 'help ' .. a:subject diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 82406898c8..e7be14e732 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -219,8 +219,8 @@ the editor. ["busy_start"] ["busy_stop"] - Nvim started or stopped being busy, and possibly not responsive to - user input. This could be indicated to the user by hiding the cursor. + Indicates to the UI that it must stop rendering the cursor. This event + is misnamed and does not actually have anything to do with busyness. ["suspend"] |:suspend| command or |CTRL-Z| mapping is used. A terminal client (or @@ -631,11 +631,13 @@ Tabline Events *ui-tabline* Activated by the `ext_tabline` |ui-option|. -["tabline_update", curtab, tabs] +["tabline_update", curtab, tabs, curbuf, buffers] Tabline was updated. UIs should present this data in a custom tabline - widget. - curtab: Current Tabpage - tabs: List of Dicts [{ "tab": Tabpage, "name": String }, ...] + widget. Note: options `curbuf` + `buffers` were added in API7. + curtab: Current Tabpage + tabs: List of Dicts [{ "tab": Tabpage, "name": String }, ...] + curbuf: Current buffer handle. + buffers: List of Dicts [{ "buffer": buffer handle, "name": String}, ...] ============================================================================== Cmdline Events *ui-cmdline* diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index f92cb3c509..a190bf2f27 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -99,8 +99,6 @@ and the value of the variable i. Since i is one, this will print: Then there is the ":let i += 1" command. This does the same thing as ":let i = i + 1". This adds one to the variable i and assigns the new value to the same variable. -Note: this is how it works in legacy Vim script, which is what we discuss in -this file. The example was given to explain the commands, but would you really want to make such a loop, it can be written much more compact: > @@ -120,24 +118,23 @@ Numbers can be decimal, hexadecimal, octal or binary. A hexadecimal number starts with "0x" or "0X". For example "0x1f" is decimal 31. -An octal number starts with "0o", "0O" or a zero and another digit. "0o17" is -decimal 15. Using just a zero prefix is not supported in Vim9 script. +An octal number starts with a zero and another digit. "017" is decimal 15. A binary number starts with "0b" or "0B". For example "0b101" is decimal 5. A decimal number is just digits. Careful: don't put a zero before a decimal -number, it will be interpreted as an octal number in legacy script! +number, it will be interpreted as an octal number! The ":echo" command always prints decimal numbers. Example: > - :echo 0x7f 0o36 + :echo 0x7f 036 < 127 30 ~ A number is made negative with a minus sign. This also works for hexadecimal, octal and binary numbers. A minus sign is also used for subtraction. Compare this with the previous example: > - :echo 0x7f -0o36 + :echo 0x7f -036 < 97 ~ White space in an expression is ignored. However, it's recommended to use it @@ -145,7 +142,7 @@ for separating items, to make the expression easier to read. For example, to avoid the confusion with a negative number above, put a space between the minus sign and the following number: > - :echo 0x7f - 0o36 + :echo 0x7f - 036 ============================================================================== *41.2* Variables diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index d5c07d9622..ec91b6e29a 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -506,7 +506,8 @@ gO Show a filetype-specific, navigable "outline" of the Queued messages are processed during the sleep. *:sl!* *:sleep!* -:[N]sl[eep]! [N] [m] Same as above, but hide the cursor. +:[N]sl[eep]! [N] [m] Same as above. Unlike Vim, it does not hide the + cursor. |vim-differences| ============================================================================== 2. Using Vim like less or more *less* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index bb30495d77..27c4b82aca 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -421,7 +421,10 @@ Commands: :mode (no longer accepts an argument) :open :Print + :promptfind + :promptrepl :shell + :sleep! (does not hide the cursor; same as :sleep) :smile :tearoff diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 09a1d1d0e6..2617d8ffc0 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -389,7 +389,7 @@ au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf " Configure scripts au BufNewFile,BufRead configure.in,configure.ac setf config -" CUDA Cumpute Unified Device Architecture +" CUDA Compute Unified Device Architecture au BufNewFile,BufRead *.cu,*.cuh setf cuda " Dockerfilb; Podman uses the same syntax with name Containerfile @@ -404,8 +404,15 @@ au BufNewFile,BufRead *enlightenment/*.cfg setf c " Eterm au BufNewFile,BufRead *Eterm/*.cfg setf eterm +" Elixir or Euphoria +au BufNewFile,BufRead *.ex call dist#ft#ExCheck() + +" Elixir +au BufRead,BufNewFile mix.lock,*.exs setf elixir +au BufRead,BufNewFile *.eex,*.leex setf eelixir + " Euphoria 3 or 4 -au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call dist#ft#EuphoriaCheck() +au BufNewFile,BufRead *.eu,*.ew,*.exu,*.exw call dist#ft#EuphoriaCheck() if has("fname_case") au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call dist#ft#EuphoriaCheck() endif @@ -851,6 +858,9 @@ au BufNewFile,BufRead *.jov,*.j73,*.jovial setf jovial " JSON au BufNewFile,BufRead *.json,*.jsonp,*.webmanifest setf json +" JSON Patch (RFC 6902) +au BufNewFile,BufRead *.json-patch setf json + " Jupyter Notebook is also json au BufNewFile,BufRead *.ipynb setf json @@ -1495,7 +1505,7 @@ au BufNewFile,BufRead *.sass setf sass au BufNewFile,BufRead *.sa setf sather " Scala -au BufNewFile,BufRead *.scala setf scala +au BufNewFile,BufRead *.scala,*.sc setf scala " SBT - Scala Build Tool au BufNewFile,BufRead *.sbt setf sbt diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index 02d1154df4..b1f935541c 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -209,12 +209,17 @@ local function get_scoped_option(k, set_type) end if is_window_option(info) then - if vim.api.nvim_get_option_info(k).was_set then - local was_set, value = pcall(a.nvim_win_get_option, 0, k) - if was_set then return value end + local ok, value = pcall(a.nvim_win_get_option, 0, k) + if ok then + return value end - return a.nvim_get_option(k) + local global_ok, global_val = pcall(a.nvim_get_option, k) + if global_ok then + return global_val + end + + error("win_get: This should never happen. File an issue and tag @tjdevries") end error("This fallback case should not be possible. " .. k) @@ -262,7 +267,7 @@ local key_value_options = { winhl = true, } ----@class OptionType +---@class OptionTypes --- Option Type Enum local OptionTypes = setmetatable({ BOOLEAN = 0, @@ -306,6 +311,28 @@ local get_option_type = function(name, info) end +-- Check whether the OptionTypes is allowed for vim.opt +-- If it does not match, throw an error which indicates which option causes the error. +local function assert_valid_value(name, value, types) + local type_of_value = type(value) + for _, valid_type in ipairs(types) do + if valid_type == type_of_value then + return + end + end + + error(string.format("Invalid option type '%s' for '%s', should be %s", type_of_value, name, table.concat(types, " or "))) +end + +local valid_types = { + [OptionTypes.BOOLEAN] = { "boolean" }, + [OptionTypes.NUMBER] = { "number" }, + [OptionTypes.STRING] = { "string" }, + [OptionTypes.SET] = { "string", "table" }, + [OptionTypes.ARRAY] = { "string", "table" }, + [OptionTypes.MAP] = { "string", "table" }, +} + --- Convert a lua value to a vimoption_T value local convert_value_to_vim = (function() -- Map of functions to take a Lua style value and convert to vimoption_T style value. @@ -315,24 +342,41 @@ local convert_value_to_vim = (function() [OptionTypes.NUMBER] = function(_, value) return value end, [OptionTypes.STRING] = function(_, value) return value end, - [OptionTypes.SET] = function(_, value) + [OptionTypes.SET] = function(info, value) if type(value) == "string" then return value end - local result = '' - for k in pairs(value) do - result = result .. k - end - return result + if info.flaglist and info.commalist then + local keys = {} + for k, v in pairs(value) do + if v then + table.insert(keys, k) + end + end + + table.sort(keys) + return table.concat(keys, ",") + else + local result = '' + for k, v in pairs(value) do + if v then + result = result .. k + end + end + + return result + end end, - [OptionTypes.ARRAY] = function(_, value) + [OptionTypes.ARRAY] = function(info, value) if type(value) == "string" then return value end - return table.concat(remove_duplicate_values(value), ",") + if not info.allows_duplicates then + value = remove_duplicate_values(value) + end + return table.concat(value, ",") end, [OptionTypes.MAP] = function(_, value) if type(value) == "string" then return value end - if type(value) == "function" then error(debug.traceback("asdf")) end local result = {} for opt_key, opt_value in pairs(value) do @@ -345,7 +389,10 @@ local convert_value_to_vim = (function() } return function(name, info, value) - return to_vim_value[get_option_type(name, info)](info, value) + local option_type = get_option_type(name, info) + assert_valid_value(name, value, valid_types[option_type]) + + return to_vim_value[option_type](info, value) end end)() @@ -358,26 +405,82 @@ local convert_value_to_lua = (function() [OptionTypes.NUMBER] = function(_, value) return value end, [OptionTypes.STRING] = function(_, value) return value end, - [OptionTypes.ARRAY] = function(_, value) + [OptionTypes.ARRAY] = function(info, value) if type(value) == "table" then - value = remove_duplicate_values(value) + if not info.allows_duplicates then + value = remove_duplicate_values(value) + end + return value end + -- Empty strings mean that there is nothing there, + -- so empty table should be returned. + if value == '' then + return {} + end + + -- Handles unescaped commas in a list. + if string.find(value, ",,,") then + local comma_split = vim.split(value, ",,,") + local left = comma_split[1] + local right = comma_split[2] + + local result = {} + vim.list_extend(result, vim.split(left, ",")) + table.insert(result, ",") + vim.list_extend(result, vim.split(right, ",")) + + table.sort(result) + + return result + end + + if string.find(value, ",^,,", 1, true) then + local comma_split = vim.split(value, ",^,,", true) + local left = comma_split[1] + local right = comma_split[2] + + local result = {} + vim.list_extend(result, vim.split(left, ",")) + table.insert(result, "^,") + vim.list_extend(result, vim.split(right, ",")) + + table.sort(result) + + return result + end + return vim.split(value, ",") end, [OptionTypes.SET] = function(info, value) if type(value) == "table" then return value end + -- Empty strings mean that there is nothing there, + -- so empty table should be returned. + if value == '' then + return {} + end + assert(info.flaglist, "That is the only one I know how to handle") - local result = {} - for i = 1, #value do - result[value:sub(i, i)] = true - end + if info.flaglist and info.commalist then + local split_value = vim.split(value, ",") + local result = {} + for _, v in ipairs(split_value) do + result[v] = true + end - return result + return result + else + local result = {} + for i = 1, #value do + result[value:sub(i, i)] = true + end + + return result + end end, [OptionTypes.MAP] = function(info, raw_value) diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index ad5a348d4c..b13d662ccb 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -339,7 +339,7 @@ end --- Add the folder at path to the workspace folders. If {path} is --- not provided, the user will be prompted for a path using |input()|. function M.add_workspace_folder(workspace_folder) - workspace_folder = workspace_folder or npcall(vfn.input, "Workspace Folder: ", vfn.expand('%:p:h')) + workspace_folder = workspace_folder or npcall(vfn.input, "Workspace Folder: ", vfn.expand('%:p:h'), 'dir') vim.api.nvim_command("redraw") if not (workspace_folder and #workspace_folder > 0) then return end if vim.fn.isdirectory(workspace_folder) == 0 then diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index e4acfd0711..64dde78f17 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -1214,9 +1214,9 @@ function M.set_loclist(opts) if severity then return d.severity == severity end - severity = to_severity(opts.severity_limit) - if severity then - return d.severity == severity + local severity_limit = to_severity(opts.severity_limit) + if severity_limit then + return d.severity <= severity_limit end return true end diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 5d38150fc0..41852b9d88 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -196,7 +196,6 @@ M['textDocument/references'] = function(_, _, result) if not result then return end util.set_qflist(util.locations_to_items(result)) api.nvim_command("copen") - api.nvim_command("wincmd p") end --@private @@ -211,7 +210,6 @@ local symbol_handler = function(_, _, result, _, bufnr) util.set_qflist(util.symbols_to_items(result, bufnr)) api.nvim_command("copen") - api.nvim_command("wincmd p") end --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol M['textDocument/documentSymbol'] = symbol_handler @@ -302,7 +300,6 @@ local function location_handler(_, method, result) if #result > 1 then util.set_qflist(util.locations_to_items(result)) api.nvim_command("copen") - api.nvim_command("wincmd p") end else util.jump_to_location(result) @@ -383,7 +380,6 @@ local make_call_hierarchy_handler = function(direction) end util.set_qflist(items) api.nvim_command("copen") - api.nvim_command("wincmd p") end end diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 98835d6708..4c5f02af9d 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -50,8 +50,13 @@ recursive_convert_NIL = function(v, tbl_processed) return nil elseif not tbl_processed[v] and type(v) == 'table' then tbl_processed[v] = true + local inside_list = vim.tbl_islist(v) return vim.tbl_map(function(x) - return recursive_convert_NIL(x, tbl_processed) + if not inside_list or (inside_list and type(x) == "table") then + return recursive_convert_NIL(x, tbl_processed) + else + return x + end end, v) end @@ -444,7 +449,7 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) method = method; params = params; } - if result then + if result and message_callbacks then message_callbacks[message_id] = schedule_wrap(callback) return result, message_id else @@ -543,14 +548,14 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) -- - The server will not send a result callback after this cancellation. -- - If the server sent this cancellation ACK after sending the result, the user of this RPC -- client will ignore the result themselves. - if result_id then + if result_id and message_callbacks then message_callbacks[result_id] = nil end return end end - local callback = message_callbacks[result_id] + local callback = message_callbacks and message_callbacks[result_id] if callback then message_callbacks[result_id] = nil validate { diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 7c0132822e..195e3a0e65 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1056,6 +1056,21 @@ function M._trim(contents, opts) return contents end +-- Generates a table mapping markdown code block lang to vim syntax, +-- based on g:markdown_fenced_languages +-- @return a table of lang -> syntax mappings +-- @private +local function get_markdown_fences() + local fences = {} + for _, fence in pairs(vim.g.markdown_fenced_languages or {}) do + local lang, syntax = fence:match("^(.*)=(.*)$") + if lang then + fences[lang] = syntax + end + end + return fences +end + --- Converts markdown into syntax highlighted regions by stripping the code --- blocks and converting them into highlighted code. --- This will by default insert a blank line separator after those code block @@ -1138,7 +1153,7 @@ function M.stylize_markdown(bufnr, contents, opts) table.insert(highlights, { ft = match.ft; start = start + 1; - finish = #stripped + 1 - 1; + finish = #stripped; }) else table.insert(stripped, line) @@ -1187,11 +1202,13 @@ function M.stylize_markdown(bufnr, contents, opts) -- keep track of syntaxes we already inlcuded. -- no need to include the same syntax more than once local langs = {} + local fences = get_markdown_fences() local function apply_syntax_to_region(ft, start, finish) if ft == "" then vim.cmd(string.format("syntax region markdownCode start=+\\%%%dl+ end=+\\%%%dl+ keepend extend", start, finish + 1)) return end + ft = fences[ft] or ft local name = ft..idx idx = idx + 1 local lang = "@"..ft:upper() @@ -1220,7 +1237,7 @@ function M.stylize_markdown(bufnr, contents, opts) apply_syntax_to_region(h.ft, h.start, h.finish) last = h.finish + 1 end - if last < #stripped then + if last <= #stripped then apply_syntax_to_region("lsp_markdown", last, #stripped) end end) diff --git a/runtime/syntax/lsp_markdown.vim b/runtime/syntax/lsp_markdown.vim index d9b50be54c..90d3185673 100644 --- a/runtime/syntax/lsp_markdown.vim +++ b/runtime/syntax/lsp_markdown.vim @@ -10,8 +10,14 @@ execute 'source' expand('<sfile>:p:h') .. '/markdown.vim' syn cluster mkdNonListItem add=mkdEscape,mkdNbsp -syntax region mkdEscape matchgroup=mkdEscape start=/\\\ze[\\\x60*{}\[\]()#+\-,.!_>~|"$%&'\/:;<=?@^ ]/ end=/.\zs/ keepend contains=mkdEscapeCh oneline concealends -syntax match mkdEscapeCh /./ contained +syn clear markdownEscape +syntax region markdownEscape matchgroup=markdownEscape start=/\\\ze[\\\x60*{}\[\]()#+\-,.!_>~|"$%&'\/:;<=?@^ ]/ end=/./ containedin=ALL keepend oneline concealends + +" conceal html entities syntax match mkdNbsp / / conceal cchar= +syntax match mkdLt /</ conceal cchar=< +syntax match mkdGt />/ conceal cchar=> +syntax match mkdAmp /&/ conceal cchar=& +syntax match mkdQuot /"/ conceal cchar=" hi def link mkdEscape special diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index d395c6b1c3..55c47aa34d 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -149,7 +149,7 @@ syn match vimNumber '\<0[xX]\x\+' skipwhite nextgroup=vimGlobal,vimSubst syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0[zZ][a-zA-Z0-9.]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0b[01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment " All vimCommands are contained by vimIsCommand. {{{2 syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAddress,vimAutoCmd,vimEcho,vimIsCommand,vimExtCmd,vimFilter,vimLet,vimMap,vimMark,vimSet,vimSyntax,vimUserCmd @@ -355,8 +355,8 @@ syn match vimCmplxRepeat '[^a-zA-Z_/\\()]q[0-9a-zA-Z"]\>'lc=1 syn match vimCmplxRepeat '@[0-9a-z".=@:]\ze\($\|[^a-zA-Z]\>\)' " Set command and associated set-options (vimOptions) with comment {{{2 -syn region vimSet matchgroup=vimCommand start="\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skip="\%(\\\\\)*\\." end="$" end="|" matchgroup=vimNotation end="<[cC][rR]>" keepend oneline contains=vimSetEqual,vimOption,vimErrSetting,vimComment,vim9Comment,vimSetString,vimSetMod -syn region vimSetEqual contained start="[=:]\|[-+^]=" skip="\\\\\|\\\s" end="[| \t]\|$"me=e-1 contains=vimCtrlChar,vimSetSep,vimNotation,vimEnvvar oneline +syn region vimSet matchgroup=vimCommand start="\<\%(setl\%[ocal]\|setg\%[lobal]\|se\%[t]\)\>" skip="\%(\\\\\)*\\." end="$" end="|" matchgroup=vimNotation end="<[cC][rR]>" oneline keepend contains=vimSetEqual,vimOption,vimErrSetting,vimComment,vim9Comment,vimSetString,vimSetMod + syn region vimSetEqual contained start="[=:]\|[-+^]=" skip="\\\\\|\\\s" end="[| \t]"me=e-1 end="$" contains=vimCtrlChar,vimSetSep,vimNotation,vimEnvvar syn region vimSetString contained start=+="+hs=s+1 skip=+\\\\\|\\"+ end=+"+ contains=vimCtrlChar syn match vimSetSep contained "[,:]" syn match vimSetMod contained "&vim\=\|[!&?<]\|all&" @@ -435,7 +435,8 @@ syn match vimFunc "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA syn match vimUserFunc contained "\%(\%([sSgGbBwWtTlL]:\|<[sS][iI][dD]>\)\=\%(\w\+\.\)*\I[a-zA-Z0-9_.]*\)\|\<\u[a-zA-Z0-9.]*\>\|\<if\>" contains=vimNotation " User Command Highlighting: {{{2 -syn match vimUsrCmd '^\s*\zs\u\w*.*$' +"syn match vimUsrCmd '^\s*\zs\u\w*.*$' +syn match vimUsrCmd '^\s*\zs\u\%(\w*\)\@>\%([(#[]\|\s\+\%([-+*/%]\=\|\.\.\)=\)\@!' " Errors And Warnings: {{{2 " ==================== @@ -573,7 +574,7 @@ syn case match syn match vimHiAttribList contained "\i\+" contains=vimHiAttrib syn match vimHiAttribList contained "\i\+,"he=e-1 contains=vimHiAttrib nextgroup=vimHiAttribList syn case ignore -syn keyword vimHiCtermColor contained black blue brown cyan darkblue darkcyan darkgray darkgreen darkgrey darkmagenta darkred darkyellow gray green grey lightblue lightcyan lightgray lightgreen lightgrey lightmagenta lightred magenta red white yellow +syn keyword vimHiCtermColor contained black blue brown cyan darkblue darkcyan darkgray darkgreen darkgrey darkmagenta darkred darkyellow gray green grey grey40 grey50 grey90 lightblue lightcyan lightgray lightgreen lightgrey lightmagenta lightred lightyellow magenta red seagreen white yellow syn match vimHiCtermColor contained "\<color\d\{1,3}\>" syn case match |