diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/health/lsp.vim | 5 | ||||
-rw-r--r-- | runtime/doc/autocmd.txt | 7 | ||||
-rw-r--r-- | runtime/doc/cmdline.txt | 2 | ||||
-rw-r--r-- | runtime/doc/deprecated.txt | 3 | ||||
-rw-r--r-- | runtime/doc/develop.txt | 41 | ||||
-rw-r--r-- | runtime/doc/diff.txt | 8 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 15 | ||||
-rw-r--r-- | runtime/doc/ft_sql.txt | 2 | ||||
-rw-r--r-- | runtime/doc/index.txt | 2 | ||||
-rw-r--r-- | runtime/doc/job_control.txt | 4 | ||||
-rw-r--r-- | runtime/doc/lua.txt | 35 | ||||
-rw-r--r-- | runtime/doc/options.txt | 2 | ||||
-rw-r--r-- | runtime/doc/quickfix.txt | 3 | ||||
-rw-r--r-- | runtime/doc/spell.txt | 6 | ||||
-rw-r--r-- | runtime/doc/starting.txt | 12 | ||||
-rw-r--r-- | runtime/doc/usr_08.txt | 2 | ||||
-rw-r--r-- | runtime/doc/usr_09.txt | 2 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 24 | ||||
-rw-r--r-- | runtime/doc/visual.txt | 2 | ||||
-rw-r--r-- | runtime/indent/python.vim | 4 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 33 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/health.lua | 27 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/log.lua | 16 | ||||
-rw-r--r-- | runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 42 | ||||
-rw-r--r-- | runtime/syntax/c.vim | 5 | ||||
-rw-r--r-- | runtime/syntax/cpp.vim | 40 | ||||
-rw-r--r-- | runtime/syntax/sh.vim | 46 |
27 files changed, 255 insertions, 135 deletions
diff --git a/runtime/autoload/health/lsp.vim b/runtime/autoload/health/lsp.vim new file mode 100644 index 0000000000..2d2ba91cdf --- /dev/null +++ b/runtime/autoload/health/lsp.vim @@ -0,0 +1,5 @@ +function! health#lsp#check() abort + call health#report_start('Checking language server client configuration') + lua require 'vim.lsp.health'.check_health() +endfunction + diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 03e182cb33..960148d506 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -798,9 +798,10 @@ QuickFixCmdPost Like QuickFixCmdPre, but after a quickfix *QuitPre* QuitPre When using `:quit`, `:wq` or `:qall`, before deciding whether it closes the current window - or quits Vim. Can be used to close any - non-essential window if the current window is - the last ordinary window. + or quits Vim. For `:wq` the buffer is written + before QuitPre is triggered. Can be used to + close any non-essential window if the current + window is the last ordinary window. See also |ExitPre|, ||WinClosed|. *RemoteReply* RemoteReply When a reply from a Vim that functions as diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 689fb1ecd2..70a465f636 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -1067,7 +1067,7 @@ in Normal mode and Insert mode. It is possible to use ":", "/" and other commands that use the command-line, but it's not possible to open another command-line window then. There is no nesting. - *E11* + *E11* *E1188* The command-line window is not a normal window. It is not possible to move to another window or edit another buffer. All commands that would do this are disabled in the command-line window. Of course it _is_ possible to execute diff --git a/runtime/doc/deprecated.txt b/runtime/doc/deprecated.txt index 3b5287ee44..861aed4884 100644 --- a/runtime/doc/deprecated.txt +++ b/runtime/doc/deprecated.txt @@ -14,6 +14,7 @@ updated. API ~ *nvim_buf_clear_highlight()* Use |nvim_buf_clear_namespace()| instead. +*nvim_buf_set_virtual_text()* Use |nvim_buf_set_extmark()| instead. *nvim_command_output()* Use |nvim_exec()| instead. *nvim_execute_lua()* Use |nvim_exec_lua()| instead. @@ -54,6 +55,8 @@ Functions ~ without stopping the job. Use chanclose(id) to close any socket. +Lua ~ +*vim.register_keystroke_callback()* Use |vim.on_key()| instead. Modifiers ~ *cpo-<* diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 60a3f870a9..14f35acce3 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -127,14 +127,20 @@ Sometimes a GUI or other application may want to force a provider to DOCUMENTATION *dev-doc* -- Do not prefix help tags with "nvim-". Use |vim_diff.txt| to document - differences from Vim; no other distinction is necessary. -- If a Vim feature is removed, delete its help section and move its tag to - |vim_diff.txt|. -- Move deprecated features to |deprecated.txt|. +- "Just say it". Avoid mushy, colloquial phrasing in all documentation + (docstrings, user manual, website materials, newsletters, …). Don't mince + words. Personality and flavor, used sparingly, are welcome--but in general, + optimize for the reader's time and energy: be "precise yet concise". + - Prefer the active voice: "Foo does X", not "X is done by Foo". +- Vim differences: + - Do not prefix help tags with "nvim-". Use |vim_diff.txt| to catalog + differences from Vim; no other distinction is necessary. + - If a Vim feature is removed, delete its help section and move its tag to + |vim_diff.txt|. +- Mention deprecated features in |deprecated.txt| and delete their old doc. - Use consistent language. - - "terminal" in a help tag always means "the embedded terminal emulator", not - "the user host terminal". + - "terminal" in a help tag always means "the embedded terminal emulator", + not "the user host terminal". - Use "tui-" to prefix help tags related to the host terminal, and "TUI" in prose if possible. - Docstrings: do not start parameter descriptions with "The" or "A" unless it @@ -222,13 +228,13 @@ LUA *dev-lua* - Keep the core Lua modules |lua-stdlib| simple. Avoid elaborate OOP or pseudo-OOP designs. Plugin authors just want functions to call, they don't - want to learn a big, fancy inheritance hierarchy. So we should avoid complex - objects: tables are usually better. + want to learn a big, fancy inheritance hierarchy. Thus avoid specialized + objects; tables or values are usually better. API *dev-api* -Use this template to name new API functions: +Use this template to name new RPC |API| functions: nvim_{thing}_{action}_{arbitrary-qualifiers} If the function acts on an object then {thing} is the name of that object @@ -356,4 +362,19 @@ External UIs are expected to implement these common features: published in this event. See also "mouse_on", "mouse_off". +NAMING *dev-naming* + +Naming is important. Consistent naming in the API and UI helps both users and +developers discover and intuitively understand related concepts ("families"), +and reduces cognitive burden. Discoverability encourages code re-use and +likewise avoids redundant, overlapping mechanisms, which reduces code +surface-area, and thereby minimizes bugs... + +Naming conventions ~ + +Use the "on_" prefix to name event handlers and also the interface for +"registering" such handlers (on_key). The dual nature is acceptable to avoid +a confused collection of naming conventions for these related concepts. + + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index a9e2a0d522..6115a5d235 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -334,9 +334,11 @@ between file1 and file2: > The ">" is replaced with the value of 'shellredir'. -The output of "diff" must be a normal "ed" style diff or a unified diff. Do -NOT use a context diff. This example explains the format that Vim expects for -the "ed" style diff: > +The output of "diff" must be a normal "ed" style diff or a unified diff. A +context diff will NOT work. For a unified diff no context lines can be used. +Using "diff -u" will NOT work, use "diff -U0". + +This example explains the format that Vim expects for the "ed" style diff: > 1a2 > bbb diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 87240831a2..e6405145cd 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2368,6 +2368,7 @@ matchstr({expr}, {pat}[, {start}[, {count}]]) matchstrpos({expr}, {pat}[, {start}[, {count}]]) List {count}'th match of {pat} in {expr} max({expr}) Number maximum value of items in {expr} +menu_get({path} [, {modes}]) List description of |menus| matched by {path} min({expr}) Number minimum value of items in {expr} mkdir({name} [, {path} [, {prot}]]) Number create directory {name} @@ -5873,8 +5874,8 @@ jobwait({jobs}[, {timeout}]) *jobwait()* Waits for jobs and their |on_exit| handlers to complete. {jobs} is a List of |job-id|s to wait for. - {timeout} is the maximum waiting time in milliseconds, -1 - means forever. + {timeout} is the maximum waiting time in milliseconds. If + omitted or -1, wait forever. Timeout of 0 can be used to check the status of a job: > let running = jobwait([{job-id}], 0)[0] == -1 @@ -6400,7 +6401,7 @@ matcharg({nr}) *matcharg()* Highlighting matches using the |:match| commands are limited to three matches. |matchadd()| does not have this limitation. -matchdelete({id} [, {win}) *matchdelete()* *E802* *E803* +matchdelete({id} [, {win}]) *matchdelete()* *E802* *E803* Deletes a match with ID {id} previously defined by |matchadd()| or one of the |:match| commands. Returns 0 if successful, otherwise -1. See example for |matchadd()|. All matches can @@ -6479,7 +6480,7 @@ max({expr}) Return the maximum value of all items in {expr}. Can also be used as a |method|: > mylist->max() -menu_get({path}, {modes}) *menu_get()* +menu_get({path} [, {modes}]) *menu_get()* Returns a |List| of |Dictionaries| describing |menus| (defined by |:menu|, |:amenu|, …), including |hidden-menus|. @@ -8364,7 +8365,7 @@ sinh({expr}) *sinh()* Can also be used as a |method|: > Compute()->sinh() -sockconnect({mode}, {address}, {opts}) *sockconnect()* +sockconnect({mode}, {address} [, {opts}]) *sockconnect()* Connect a socket to an address. If {mode} is "pipe" then {address} should be the path of a named pipe. If {mode} is "tcp" then {address} should be of the form "host:port" where @@ -8376,7 +8377,7 @@ sockconnect({mode}, {address}, {opts}) *sockconnect()* |rpcrequest()| and |rpcnotify()| to communicate with a RPC socket. - {opts} is a dictionary with these keys: + {opts} is an optional dictionary with these keys: |on_data| : callback invoked when data was read from socket data_buffered : read socket data in |channel-buffered| mode. rpc : If set, |msgpack-rpc| will be used to communicate @@ -9275,7 +9276,7 @@ tanh({expr}) *tanh()* Can also be used as a |method|: > Compute()->tanh() - +< *timer_info()* timer_info([{id}]) Return a list with information about timers. diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt index f38c8edbf3..53a99a9e1d 100644 --- a/runtime/doc/ft_sql.txt +++ b/runtime/doc/ft_sql.txt @@ -436,7 +436,7 @@ the space bar): replace the column list with the list of tables. - This allows you to quickly drill down into a table to view its columns and back again. - - <Right> and <Left> can be also be chosen via + - <Right> and <Left> can also be chosen via your |init.vim| > let g:ftplugin_sql_omni_key_right = '<Right>' let g:ftplugin_sql_omni_key_left = '<Left>' diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 69a13557d1..9a279ad880 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1608,7 +1608,7 @@ tag command action ~ |:tab| :tab create new tab when opening new window |:tag| :ta[g] jump to tag |:tags| :tags show the contents of the tag stack -|:tcd| :tcd change directory for tab page +|:tcd| :tc[d] change directory for tab page |:tchdir| :tch[dir] change directory for tab page |:terminal| :te[rminal] open a terminal buffer |:tfirst| :tf[irst] jump to first matching tag diff --git a/runtime/doc/job_control.txt b/runtime/doc/job_control.txt index bf01e8e266..6a9d865c40 100644 --- a/runtime/doc/job_control.txt +++ b/runtime/doc/job_control.txt @@ -19,7 +19,7 @@ Job Id *job-id* Each job is identified by an integer id, unique for the life of the current Nvim session. Each job-id is a valid |channel-id|: they share the same "key space". Functions like |jobstart()| return job ids; functions like -|jobsend()|, |jobstop()|, |rpcnotify()|, and |rpcrequest()| take job ids. +|jobstop()|, |chansend()|, |rpcnotify()|, and |rpcrequest()| take job ids. Job stdio streams form a |channel| which can send and receive raw bytes or |msgpack-rpc| messages. @@ -28,7 +28,7 @@ Job stdio streams form a |channel| which can send and receive raw bytes or Usage *job-control-usage* To control jobs, use the "job…" family of functions: |jobstart()|, -|jobsend()|, |jobstop()|. +|jobstop()|, etc. Example: > diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index a44b2e42f5..5d600eae99 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -576,11 +576,11 @@ If you want to exclude visual selections from highlighting on yank, use vim.highlight.on_yank({opts}) *vim.highlight.on_yank()* Highlights the yanked text. The fields of the optional dict {opts} control the highlight: - - {higroup} highlight group for yanked region (default `"IncSearch"`) + - {higroup} highlight group for yanked region (default |hl-IncSearch|) - {timeout} time in ms before highlight is cleared (default `150`) - {on_macro} highlight when executing macro (default `false`) - {on_visual} highlight when yanking visual selection (default `true`) - - {event} event structure (default `vim.v.event`) + - {event} event structure (default |v:event|) vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclusive}) *vim.highlight.range()* @@ -1243,37 +1243,6 @@ region({bufnr}, {pos1}, {pos2}, {regtype}, {inclusive}) *vim.region()* Return: ~ region lua table of the form {linenr = {startcol,endcol}} - *vim.register_keystroke_callback()* -register_keystroke_callback({fn}, {ns_id}) - Register a lua {fn} with an {id} to be run after every - keystroke. - - If {fn} is nil, it removes the callback for the associated - {ns_id} - Note: - {fn} will not be cleared from |nvim_buf_clear_namespace()| - - Note: - {fn} will receive the keystrokes after mappings have been - evaluated - - Parameters: ~ - {fn} function: Function to call. It should take one - argument, which is a string. The string will contain - the literal keys typed. See |i_CTRL-V| - {ns_id} number? Namespace ID. If not passed or 0, will - generate and return a new namespace ID from - |nvim_create_namesapce()| - - Return: ~ - number Namespace ID associated with {fn} - - Note: - {fn} will be automatically removed if an error occurs - while calling. This is to prevent the annoying situation - of every keystroke erroring while trying to remove a - broken callback. - schedule_wrap({cb}) *vim.schedule_wrap()* Defers callback `cb` until the Nvim API is safe to call. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 475ccb66b3..d7bd91ad4f 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6118,6 +6118,8 @@ A jump table for the options with a short description can be found at |Q_op|. 'switchbuf' 'swb' string (default "uselast") global This option controls the behavior when switching between buffers. + Mostly for |quickfix| commands some values are also used for other + commands, as mentioned below. Possible values (comma separated list): useopen If included, jump to the first open window that contains the specified buffer (if there is one). diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 563fb0c962..9c1f584415 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1333,7 +1333,8 @@ Basic items %o module name (finds a string) %l line number (finds a number) %c column number (finds a number representing character - column of the error, (1 <tab> == 1 character column)) + column of the error, byte index, a <tab> is 1 + character column) %v virtual column number (finds a number representing screen column of the error (1 <tab> == 8 screen columns)) diff --git a/runtime/doc/spell.txt b/runtime/doc/spell.txt index 22d7cdf491..03c00c8495 100644 --- a/runtime/doc/spell.txt +++ b/runtime/doc/spell.txt @@ -1127,10 +1127,10 @@ flag to avoid lots of errors. CIRCUMFIX *spell-CIRCUMFIX* The CIRCUMFIX flag means a prefix and suffix must be added at the same time. -If a prefix has the CIRCUMFIX flag than only suffixes with the CIRCUMFIX flag +If a prefix has the CIRCUMFIX flag then only suffixes with the CIRCUMFIX flag can be added, and the other way around. -An alternative is to only specify the suffix, and give the that suffix two -flags: The required prefix and the NEEDAFFIX flag. |spell-NEEDAFFIX| +An alternative is to only specify the suffix, and give that suffix two flags: +the required prefix and the NEEDAFFIX flag. |spell-NEEDAFFIX| PFXPOSTPONE *spell-PFXPOSTPONE* diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index d6b54fbd01..87a48e6d2a 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -329,12 +329,12 @@ argument. -w{number} Set the 'window' option to {number}. *-w* --w {scriptout} All the characters that you type are recorded in the file - "scriptout", until you exit Vim. This is useful if you want - to create a script file to be used with "vim -s" or - ":source!". When the "scriptout" file already exists, new - characters are appended. See also |complex-repeat|. - {scriptout} cannot start with a digit. +-w {scriptout} All keys that you type are recorded in the file "scriptout", + until you exit Vim. Useful to create a script file to be used + with "vim -s" or ":source!". Appends to the "scriptout" file + if it already exists. {scriptout} cannot start with a digit. + See also |vim.on_key()|. + See also |complex-repeat|. *-W* -W {scriptout} Like -w, but do not append, overwrite an existing file. diff --git a/runtime/doc/usr_08.txt b/runtime/doc/usr_08.txt index 8e69307a94..8ccaa73006 100644 --- a/runtime/doc/usr_08.txt +++ b/runtime/doc/usr_08.txt @@ -235,7 +235,7 @@ windows like this: +----------------------------------+ Clearly the last one should be at the top. Go to that window (using CTRL-W w) -and the type this command: > +and then type this command: > CTRL-W K diff --git a/runtime/doc/usr_09.txt b/runtime/doc/usr_09.txt index 757d13e0f3..8084d13b5d 100644 --- a/runtime/doc/usr_09.txt +++ b/runtime/doc/usr_09.txt @@ -109,7 +109,7 @@ when the 'wrap' option has been reset (more about that later). When there are vertically split windows, only the windows on the right side will have a scrollbar. However, when you move the cursor to a window on the -left, it will be this one the that scrollbar controls. This takes a bit of +left, it will be this one that the scrollbar controls. This takes a bit of time to get used to. When you work with vertically split windows, consider adding a scrollbar on the left. This can be done with a menu item, or with the 'guioptions' option: diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 4b134926a2..a5fcef2800 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -6,16 +6,16 @@ Differences between Nvim and Vim *vim-differences* -Nvim differs from Vim in many ways, although editor and VimL features are -mostly identical. This document is a complete and centralized reference of -the differences. +Nvim differs from Vim in many ways, although editor and Vimscript (not +Vim9script) features are mostly identical. This document is a complete and +centralized reference of the differences. Type |gO| to see the table of contents. ============================================================================== 1. Configuration *nvim-config* -- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for configuration. +- Use `$XDG_CONFIG_HOME/nvim/init.vim` instead of `.vimrc` for your |config|. - Use `$XDG_CONFIG_HOME/nvim` instead of `.vim` to store configuration files. - Use `$XDG_DATA_HOME/nvim/shada/main.shada` instead of `.viminfo` for persistent session information. |shada| @@ -78,6 +78,8 @@ the differences. Default Mappings ~ *default-mappings* +Nvim creates the following default mappings at |startup|. You can disable any +of these in your config by simply removing the mapping, e.g. ":unmap Y". > nnoremap Y y$ nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L> @@ -101,17 +103,19 @@ nvim_cmdwin: MAJOR COMPONENTS ~ API |API| -Lua scripting |lua| Job control |job-control| -Remote plugins |remote-plugin| +LSP framework |lsp| +Lua scripting |lua| +Parsing engine |treesitter| Providers Clipboard |provider-clipboard| Node.js plugins |provider-nodejs| Python plugins |provider-python| Ruby plugins |provider-ruby| +Remote plugins |remote-plugin| Shared data |shada| -Embedded terminal |terminal| -VimL parser |nvim_parse_expression()| +Terminal emulator |terminal| +Vimscript parser |nvim_parse_expression()| XDG base directories |xdg| USER EXPERIENCE ~ @@ -160,7 +164,7 @@ FEATURES ~ Command-line highlighting: The expression prompt (|@=|, |c_CTRL-R_=|, |i_CTRL-R_=|) is highlighted - using a built-in VimL expression parser. |expr-highlight| + using a built-in Vimscript expression parser. |expr-highlight| *E5408* *E5409* |input()|, |inputdialog()| support custom highlighting. |input()-highlight| *g:Nvim_color_cmdline* @@ -413,7 +417,7 @@ TUI: UI/Display: |Visual| selection highlights the character at cursor. |visual-use| -VimL (Vim script) compatibility: +Vimscript compatibility: `count` does not alias to |v:count| `errmsg` does not alias to |v:errmsg| `shell_error` does not alias to |v:shell_error| diff --git a/runtime/doc/visual.txt b/runtime/doc/visual.txt index f7828f0289..111588e43a 100644 --- a/runtime/doc/visual.txt +++ b/runtime/doc/visual.txt @@ -419,7 +419,7 @@ abcdefghijklmnopqrstuvwxyz abcdefghijklmnSTRINGopqrstuvwxyz abc STRING defghijklmnopqrstuvwxyz -abcdef ghi STRING jklmnopqrstuvwxyz +abcdef ghi STRING jklmnopqrstuvwxyz abcdefghijklmnSTRINGopqrstuvwxyz 2. fo<C-v>3j$ASTRING<ESC> *v_b_A_example* diff --git a/runtime/indent/python.vim b/runtime/indent/python.vim index f9236e63c7..307b7f656b 100644 --- a/runtime/indent/python.vim +++ b/runtime/indent/python.vim @@ -2,7 +2,7 @@ " Language: Python " Maintainer: Bram Moolenaar <Bram@vim.org> " Original Author: David Bustos <bustos@caltech.edu> -" Last Change: 2019 Feb 21 +" Last Change: 2021 May 26 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -191,7 +191,7 @@ function GetPythonIndent(lnum) if getline(a:lnum) =~ '^\s*\(elif\|else\)\>' " Unless the previous line was a one-liner - if getline(plnumstart) =~ '^\s*\(for\|if\|try\)\>' + if getline(plnumstart) =~ '^\s*\(for\|if\|elif\|try\)\>' return plindent endif diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 264d7c0247..8bfcd90f12 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -249,13 +249,34 @@ end ---@param new_name (string) If not provided, the user will be prompted for a new ---name using |input()|. function M.rename(new_name) - -- TODO(ashkan) use prepareRename - -- * result: [`Range`](#range) \| `{ range: Range, placeholder: string }` \| `null` describing the range of the string to rename and optionally a placeholder text of the string content to be renamed. If `null` is returned then it is deemed that a 'textDocument/rename' request is not valid at the given position. local params = util.make_position_params() - new_name = new_name or npcall(vfn.input, "New Name: ", vfn.expand('<cword>')) - if not (new_name and #new_name > 0) then return end - params.newName = new_name - request('textDocument/rename', params) + local function prepare_rename(err, result) + if err == nil and result == nil then + vim.notify('nothing to rename', vim.log.levels.INFO) + return + end + if result and result.placeholder then + new_name = new_name or npcall(vfn.input, "New Name: ", result.placeholder) + elseif result and result.start and result['end'] and + result.start.line == result['end'].line then + local line = vfn.getline(result.start.line+1) + local start_char = result.start.character+1 + local end_char = result['end'].character + new_name = new_name or npcall(vfn.input, "New Name: ", string.sub(line, start_char, end_char)) + else + -- fallback to guessing symbol using <cword> + -- + -- this can happen if the language server does not support prepareRename, + -- returns an unexpected response, or requests for "default behavior" + -- + -- see https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareRename + new_name = new_name or npcall(vfn.input, "New Name: ", vfn.expand('<cword>')) + end + if not (new_name and #new_name > 0) then return end + params.newName = new_name + request('textDocument/rename', params) + end + request('textDocument/prepareRename', params, prepare_rename) end --- Lists all the references to the symbol under the cursor in the quickfix window. diff --git a/runtime/lua/vim/lsp/health.lua b/runtime/lua/vim/lsp/health.lua new file mode 100644 index 0000000000..855679a2df --- /dev/null +++ b/runtime/lua/vim/lsp/health.lua @@ -0,0 +1,27 @@ +local M = {} + +--- Performs a healthcheck for LSP +function M.check_health() + local report_info = vim.fn['health#report_info'] + local report_warn = vim.fn['health#report_warn'] + + local log = require('vim.lsp.log') + local current_log_level = log.get_level() + local log_level_string = log.levels[current_log_level] + report_info(string.format("LSP log level : %s", log_level_string)) + + if current_log_level < log.levels.WARN then + report_warn(string.format("Log level %s will cause degraded performance and high disk usage", log_level_string)) + end + + local log_path = vim.lsp.get_log_path() + report_info(string.format("Log path: %s", log_path)) + + local log_size = vim.loop.fs_stat(log_path).size + + local report_fn = (log_size / 1000000 > 100 and report_warn or report_info) + report_fn(string.format("Log size: %d KB", log_size / 1000 )) +end + +return M + diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua index a2d5c3a774..5d2e396cc5 100644 --- a/runtime/lua/vim/lsp/log.lua +++ b/runtime/lua/vim/lsp/log.lua @@ -32,6 +32,17 @@ do vim.fn.mkdir(vim.fn.stdpath('cache'), "p") local logfile = assert(io.open(logfilename, "a+")) + + local log_info = vim.loop.fs_stat(logfilename) + if log_info and log_info.size > 1e9 then + local warn_msg = string.format( + "LSP client log is large (%d MB): %s", + log_info.size / (1000 * 1000), + logfilename + ) + vim.notify(warn_msg) + end + -- Start message for logging logfile:write(string.format("[ START ] %s ] LSP logging initiated\n", os.date(log_date_format))) for level, levelnr in pairs(log.levels) do @@ -88,6 +99,11 @@ function log.set_level(level) end end +--- Gets the current log level. +function log.get_level() + return current_log_level +end + --- Checks whether the level is sufficient for logging. ---@param level number log level ---@returns (bool) true if would log, false if not diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index ae1274f81f..2914e2bc4d 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -2,7 +2,7 @@ " " Author: Bram Moolenaar " Copyright: Vim license applies, see ":help license" -" Last Change: 2021 May 16 +" Last Change: 2021 May 18 " " WORK IN PROGRESS - Only the basics work " Note: On MS-Windows you need a recent version of gdb. The one included with @@ -181,6 +181,15 @@ func s:CloseBuffers() unlet! s:gdbwin endfunc +func s:CheckGdbRunning() + if nvim_get_chan_info(s:gdb_job_id) == {} + echoerr string(g:termdebugger) . ' exited unexpectedly' + call s:CloseBuffers() + return '' + endif + return 'ok' +endfunc + func s:StartDebug_term(dict) " Open a terminal window without a job, to run the debugged program in. execute s:vertical ? 'vnew' : 'new' @@ -229,7 +238,7 @@ func s:StartDebug_term(dict) let gdb_args = get(a:dict, 'gdb_args', []) let proc_args = get(a:dict, 'proc_args', []) - let cmd = [g:termdebugger, '-quiet', '-tty', pty] + gdb_args + let cmd = [g:termdebugger, '-quiet', '-tty', pty, '--eval-command', 'echo startupdone\n'] + gdb_args "call ch_log('executing "' . join(cmd) . '"') execute 'new' let s:gdb_job_id = termopen(cmd, {'on_exit': function('s:EndTermDebug')}) @@ -246,9 +255,28 @@ func s:StartDebug_term(dict) let s:gdbbuf = gdb_job_info['buffer'] let s:gdbwin = win_getid(winnr()) - " Set arguments to be run. First wait a bit to make detecting gdb a bit - " more reliable. - sleep 200m + " Wait for the "startupdone" message before sending any commands. + let try_count = 0 + while 1 + if s:CheckGdbRunning() != 'ok' + return + endif + + for lnum in range(1, 200) + if get(getbufline(s:gdbbuf, lnum), 0, '') =~ 'startupdone' + let try_count = 9999 + break + endif + endfor + let try_count += 1 + if try_count > 300 + " done or give up after five seconds + break + endif + sleep 10m + endwhile + + " Set arguments to be run. if len(proc_args) call chansend(s:gdb_job_id, 'set args ' . join(proc_args) . "\r") endif @@ -260,9 +288,7 @@ func s:StartDebug_term(dict) " why the debugger doesn't work. let try_count = 0 while 1 - if nvim_get_chan_info(s:gdb_job_id) == {} - echoerr string(g:termdebugger) . ' exited unexpectedly' - call s:CloseBuffers() + if s:CheckGdbRunning() != 'ok' return endif diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index d07aaf2658..20f8632006 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Jan 11 +" Last Change: 2021 May 24 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -414,6 +414,9 @@ if exists("c_autodoc") syn cluster cPreProcGroup add=cAutodocReal endif +" be able to fold #pragma regions +syn region cPragma start="^\s*#pragma\s\+region\>" end="^\s*#pragma\s\+endregion\>" transparent keepend extend fold + " Highlight User Labels syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString if s:ft ==# 'c' || exists("cpp_no_cpp11") diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim index ed38913f29..3ad79d5545 100644 --- a/runtime/syntax/cpp.vim +++ b/runtime/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan <ccshan@post.harvard.edu> -" Last Change: 2021 Jan 12 +" Last Change: 2021 May 04 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -44,22 +44,40 @@ if !exists("cpp_no_cpp11") syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE - syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell + syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ contains=@Spell syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*<"me=e-1 syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*$" endif " C++ 14 extensions if !exists("cpp_no_cpp14") - syn case ignore - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" contains=cFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>" - syn case match + syn match cppNumbers display transparent "\<\d\|\.\d" contains=cppNumber,cppFloat + syn match cppNumber display contained "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display contained "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display contained "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display contained "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell +endif + +" C++ 17 extensions +if !exists("cpp_no_cpp17") + syn match cppCast "\<reinterpret_pointer_cast\s*<"me=e-1 + syn match cppCast "\<reinterpret_pointer_cast\s*$" + syn match cppFloat display contained "\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" endif " C++ 20 extensions if !exists("cpp_no_cpp20") + syn match cppNumber display contained "\<0\(y\|d\)\>" + syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\(y\|d\)\>" + syn match cppNumber display contained "\<0\o\+\(y\|d\)\>" + syn match cppNumber display contained "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>" + syn match cppNumber display contained "\<0x\x\('\=\x\+\)*\(y\|d\)\>" syn keyword cppStatement co_await co_return co_yield requires syn keyword cppStorageClass consteval constinit syn keyword cppStructure concept @@ -67,12 +85,6 @@ if !exists("cpp_no_cpp20") syn keyword cppModule import module export endif -" C++ 17 extensions -if !exists("cpp_no_cpp17") - syn match cppCast "\<reinterpret_pointer_cast\s*<"me=e-1 - syn match cppCast "\<reinterpret_pointer_cast\s*$" -endif - " The minimum and maximum operators in GNU C++ syn match cppMinMax "[<>]?" @@ -90,7 +102,9 @@ hi def link cppBoolean Boolean hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String +hi def link cppString String hi def link cppNumber Number +hi def link cppFloat Number hi def link cppModule Include let b:current_syntax = "cpp" diff --git a/runtime/syntax/sh.vim b/runtime/syntax/sh.vim index 48a0024b00..0ab9c0ad58 100644 --- a/runtime/syntax/sh.vim +++ b/runtime/syntax/sh.vim @@ -2,8 +2,8 @@ " Language: shell (sh) Korn shell (ksh) bash (sh) " Maintainer: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM> " Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int> -" Last Change: Nov 24, 2020 -" Version: 196 +" Last Change: Feb 18, 2021 +" Version: 198 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH " For options and settings, please use: :help ft-sh-syntax " This file includes many ideas from Eric Brunet (eric.brunet@ens.fr) and heredoc fixes from Felipe Contreras @@ -13,33 +13,35 @@ if exists("b:current_syntax") finish endif -" trying to answer the question: which shell is /bin/sh, really? -" If the user has not specified any of g:is_kornshell, g:is_bash, g:is_posix, g:is_sh, then guess. -if getline(1) =~ '\<ksh$' +" If the shell script itself specifies which shell to use, use it +if getline(1) =~ '\<ksh\>' let b:is_kornshell = 1 -elseif getline(1) =~ '\<bash$' +elseif getline(1) =~ '\<bash\>' let b:is_bash = 1 -elseif getline(1) =~ '\<dash$' +elseif getline(1) =~ '\<dash\>' let b:is_dash = 1 elseif !exists("g:is_kornshell") && !exists("g:is_bash") && !exists("g:is_posix") && !exists("g:is_sh") && !exists("g:is_dash") + " user did not specify which shell to use, and + " the script itself does not specify which shell to use. FYI: /bin/sh is ambiguous. + " Assuming /bin/sh is executable, and if its a link, find out what it links to. let s:shell = "" if executable("/bin/sh") let s:shell = resolve("/bin/sh") elseif executable("/usr/bin/sh") let s:shell = resolve("/usr/bin/sh") endif - if s:shell =~ 'ksh$' + if s:shell =~ '\<ksh\>' let b:is_kornshell= 1 - elseif s:shell =~ 'bash$' + elseif s:shell =~ '\<bash\>' let b:is_bash = 1 - elseif s:shell =~ 'dash$' + elseif s:shell =~ '\<dash\>' let b:is_dash = 1 endif unlet s:shell endif " handling /bin/sh with is_kornshell/is_sh {{{1 -" b:is_sh is set when "#! /bin/sh" is found; +" b:is_sh will be set when "#! /bin/sh" is found; " However, it often is just a masquerade by bash (typically Linux) " or kornshell (typically workstations with Posix "sh"). " So, when the user sets "g:is_bash", "g:is_kornshell", @@ -98,12 +100,14 @@ if g:sh_fold_enabled && &fdm == "manual" setl fdm=syntax endif -" set up the syntax-highlighting iskeyword +" set up the syntax-highlighting for iskeyword if (v:version == 704 && has("patch-7.4.1142")) || v:version > 704 - if exists("b:is_bash") - exe "syn iskeyword ".&iskeyword.",-,:" - else - exe "syn iskeyword ".&iskeyword.",-" + if !exists("g:sh_syntax_isk") || (exists("g:sh_syntax_isk") && g:sh_syntax_isk) + if exists("b:is_bash") + exe "syn iskeyword ".&iskeyword.",-,:" + else + exe "syn iskeyword ".&iskeyword.",-" + endif endif endif @@ -374,12 +378,11 @@ elseif !exists("g:sh_no_error") syn region shExDoubleQuote matchGroup=Error start=+\$"+ skip=+\\\\\|\\.+ end=+"+ contains=shStringSpecial endif syn region shSingleQuote matchgroup=shQuote start=+'+ end=+'+ contains=@Spell nextgroup=shSpecialStart,shSpecialSQ -syn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell nextgroup=shSpecialStart -syn region shDoubleQuote matchgroup=shQuote start=+"+ matchgroup=shSpecial skip=+\\"+ matchgroup=shQuote end=+"+ contained contains=@shDblQuoteList,shStringSpecial,@Spell nextgroup=shSpecialStart +syn region shDoubleQuote matchgroup=shQuote start=+\%(\%(\\\\\)*\\\)\@<!"+ skip=+\\.+ end=+"+ contains=@shDblQuoteList,shStringSpecial,@Spell nextgroup=shSpecialStart syn match shStringSpecial "[^[:print:] \t]" contained -syn match shStringSpecial "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" nextgroup=shComment -syn match shSpecialSQ "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" contained nextgroup=shBkslshSnglQuote,@shNoZSList -syn match shSpecialDQ "[^\\]\zs\%(\\\\\)*\\[\\"'`$()#]" contained nextgroup=shBkslshDblQuote,@shNoZSList +syn match shStringSpecial "[^\\]\zs\%(\\\\\)*\(\\[\\"'`$()#]\)\+" nextgroup=shComment +syn match shSpecialSQ "[^\\]\zs\%(\\\\\)*\(\\[\\"'`$()#]\)\+" contained nextgroup=shBkslshSnglQuote,@shNoZSList +syn match shSpecialDQ "[^\\]\zs\%(\\\\\)*\(\\[\\"'`$()#]\)\+" contained nextgroup=shBkslshDblQuote,@shNoZSList syn match shSpecialStart "\%(\\\\\)*\\[\\"'`$()#]" contained nextgroup=shBkslshSnglQuote,shBkslshDblQuote,@shNoZSList syn match shSpecial "^\%(\\\\\)*\\[\\"'`$()#]" syn match shSpecialNoZS contained "\%(\\\\\)*\\[\\"'`$()#]" @@ -402,6 +405,7 @@ syn match shQuickComment contained "#.*$" syn match shBQComment contained "#.\{-}\ze`" contains=@shCommentGroup " Here Documents: {{{1 +" (modified by Felipe Contreras) " ========================================= ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc01 start="<<\s*\z([^ \t|>]\+\)" matchgroup=shHereDoc01 end="^\z1\s*$" contains=@shDblQuoteList ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc02 start="<<-\s*\z([^ \t|>]\+\)" matchgroup=shHereDoc02 end="^\s*\z1\s*$" contains=@shDblQuoteList |