diff options
Diffstat (limited to 'runtime')
45 files changed, 929 insertions, 828 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim index dea79f21f0..991bed6bbd 100644 --- a/runtime/autoload/provider/clipboard.vim +++ b/runtime/autoload/provider/clipboard.vim @@ -158,7 +158,9 @@ function! s:clipboard.get(reg) abort end 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 + if match(&clipboard, '\v(unnamed|unnamedplus)') >= 0 + \ && type(clipboard_data) == v:t_list + \ && 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 diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 07c45c9298..dae7986fdb 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -661,8 +661,7 @@ nvim_create_namespace({name}) *nvim_create_namespace()* Creates a new namespace, or gets an existing one. Namespaces are used for buffer highlights and virtual text, - see |nvim_buf_add_highlight()| and - |nvim_buf_set_virtual_text()|. + see |nvim_buf_add_highlight()| and |nvim_buf_set_extmark()|. Namespaces can be named or anonymous. If `name` matches an existing namespace, the associated id is returned. If `name` @@ -1104,7 +1103,7 @@ nvim_input_mouse({button}, {action}, {modifier}, {grid}, {row}, {col}) intermediate mouse positions will be ignored. It should be used to implement real-time mouse input in a GUI. The deprecated pseudokey form ("<LeftMouse><col,row>") of - |nvim_input()| has the same limitiation. + |nvim_input()| has the same limitation. Attributes: ~ {fast} @@ -1183,7 +1182,7 @@ nvim_notify({msg}, {log_level}, {opts}) *nvim_notify()* Notify the user with a message Relays the call to vim.notify . By default forwards your - message in the echo area but can be overriden to trigger + message in the echo area but can be overridden to trigger desktop notifications. Parameters: ~ @@ -1197,7 +1196,7 @@ nvim_open_term({buffer}, {opts}) *nvim_open_term()* By default (and currently the only option) the terminal will not be connected to an external process. Instead, input send on the channel will be echoed directly by the terminal. This - is useful to disply ANSI terminal sequences returned as part + is useful to display ANSI terminal sequences returned as part of a rpc message, or similar. Note: to directly initiate the terminal using the right size, @@ -1419,8 +1418,9 @@ nvim_parse_expression({expr}, {flags}, {highlight}) • "len": Amount of bytes successfully parsed. With flags equal to "" that should be equal to the length of expr - string. (“Sucessfully parsed” here means “participated - in AST creation”, not “till the first error”.) + string. (“Successfully parsed” here means + “participated in AST creation”, not “till the first + error”.) • "ast": AST, either nil or a dictionary with these keys: • "type": node type, one of the value names from @@ -1681,7 +1681,7 @@ nvim_set_decoration_provider({ns_id}, {opts}) Note: this function should not be called often. Rather, the callbacks themselves can be used to throttle unneeded callbacks. the `on_start` callback can return `false` to - disable the provider until the next redraw. Similarily, return + disable the provider until the next redraw. Similarly, return `false` in `on_win` will skip the `on_lines` calls for that window (but any extmarks set in `on_win` will still be used). A plugin managing multiple sources of decoration should @@ -1721,7 +1721,7 @@ nvim_set_hl({ns_id}, {name}, {val}) *nvim_set_hl()* Parameters: ~ {ns_id} number of namespace for this highlight {name} highlight group name, like ErrorMsg - {val} highlight definiton map, like + {val} highlight definition map, like |nvim_get_hl_by_name|. in addition the following keys are also recognized: `default` : don't override existing definition, like `hi default` @@ -2289,7 +2289,16 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts}) • hl_group : name of the highlight group used to highlight this mark. • virt_text : virtual text to link to this mark. - • virt_text_pos : positioning of virtual text. + A list of [text, highlight] tuples, each + representing a text chunk with specified + highlight. `highlight` element can either be a + a single highlight group, or an array of + multiple highlight groups that will be stacked + (highest priority last). A highlight group can + be supplied either as a string or as an + integer, the latter which can be obtained + using |nvim_get_hl_id_by_name|. + • virt_text_pos : position of virtual text. Possible values: • "eol": right after eol character (default) • "overlay": display over the specified @@ -2426,44 +2435,6 @@ nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()* {name} Variable name {value} Variable value - *nvim_buf_set_virtual_text()* -nvim_buf_set_virtual_text({buffer}, {src_id}, {line}, {chunks}, {opts}) - Set the virtual text (annotation) for a buffer line. - - By default (and currently the only option) the text will be - placed after the buffer text. Virtual text will never cause - reflow, rather virtual text will be truncated at the end of - the screen line. The virtual text will begin one cell - (|lcs-eol| or space) after the ordinary text. - - Namespaces are used to support batch deletion/updating of - virtual text. To create a namespace, use - |nvim_create_namespace()|. Virtual text is cleared using - |nvim_buf_clear_namespace()|. The same `ns_id` can be used for - both virtual text and highlights added by - |nvim_buf_add_highlight()|, both can then be cleared with a - single call to |nvim_buf_clear_namespace()|. If the virtual - text never will be cleared by an API call, pass `ns_id = -1` . - - As a shorthand, `ns_id = 0` can be used to create a new - namespace for the virtual text, the allocated id is then - returned. - - Parameters: ~ - {buffer} Buffer handle, or 0 for current buffer - {ns_id} Namespace to use or 0 to create a namespace, or - -1 for a ungrouped annotation - {line} Line to annotate with virtual text - (zero-indexed) - {chunks} A list of [text, hl_group] arrays, each - representing a text chunk with specified - highlight. `hl_group` element can be omitted for - no highlight. - {opts} Optional parameters. Currently not used. - - Return: ~ - The ns_id that was used - ============================================================================== Window Functions *api-window* diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 9ee1954514..87c2e11a1e 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -232,7 +232,7 @@ BufDelete Before deleting a buffer from the buffer list. *BufEnter* BufEnter After entering a buffer. Useful for setting options for a file type. Also executed when - starting to edit a buffer, after the + starting to edit a buffer. After |BufAdd|. After |BufReadPost|. *BufFilePost* diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index 7a63a89986..6be87af8a9 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -568,9 +568,7 @@ with ".". Vim does not recognize a comment (starting with '"') after the option is empty (this is the default), use the internal formatting function |C-indenting| and |'lisp'|. But when 'indentexpr' is not empty, it will - be used instead |indent-expression|. When Vim was - compiled without internal formatting then the "indent" - program is used as a last resort. + be used instead |indent-expression|. *==* == Filter [count] lines like with ={motion}. @@ -1011,9 +1009,7 @@ inside of strings can change! Also see 'softtabstop' option. > with `zp`. (for {Visual} see |Visual-mode|) *:y* *:yank* *E850* -:[range]y[ank] [x] Yank [range] lines [into register x]. Yanking to the - "* or "+ registers is possible only when the - |+clipboard| feature is included. +:[range]y[ank] [x] Yank [range] lines [into register x]. :[range]y[ank] [x] {count} Yank {count} lines, starting with last line number @@ -1802,8 +1798,7 @@ found here: |sort()|, |uniq()|. With [f] sorting is done on the Float in the line. The value of Float is determined similar to passing the text (after or inside a {pattern} match) to - str2float() function. This option is available only - if Vim was compiled with Floating point support. + str2float() function. With [x] sorting is done on the first hexadecimal number in the line (after or inside a {pattern} diff --git a/runtime/doc/digraph.txt b/runtime/doc/digraph.txt index b7dc16341d..dd7e9a331a 100644 --- a/runtime/doc/digraph.txt +++ b/runtime/doc/digraph.txt @@ -165,7 +165,7 @@ ROUBLE The rouble sign was added in 2014 as 0x20bd. Vim supports the digraphs =R and =P for this. Note that R= and P= are other characters. - *digraph-table* + *digraph-table* *digraph-table-mbyte* char digraph hex dec official name ~ ^@ NU 0x00 0 NULL (NUL) ^A SH 0x01 1 START OF HEADING (SOH) @@ -341,12 +341,6 @@ $ DO 0x24 36 DOLLAR SIGN ý y' 0xfd 253 LATIN SMALL LETTER Y WITH ACUTE þ th 0xfe 254 LATIN SMALL LETTER THORN (Icelandic) ÿ y: 0xff 255 LATIN SMALL LETTER Y WITH DIAERESIS - -If your Vim is compiled with |multibyte| support and you are using a multibyte -'encoding', Vim provides this enhanced set of additional digraphs: - - *digraph-table-mbyte* -char digraph hex dec official name ~ Ā A- 0100 0256 LATIN CAPITAL LETTER A WITH MACRON ā a- 0101 0257 LATIN SMALL LETTER A WITH MACRON Ă A( 0102 0258 LATIN CAPITAL LETTER A WITH BREVE diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index bf7f2b21de..a76298c86c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2203,9 +2203,11 @@ getbufline({expr}, {lnum} [, {end}]) getbufvar({expr}, {varname} [, {def}]) any variable {varname} in buffer {expr} getchangelist({expr}) List list of change list items -getchar([expr]) Number get one character from the user +getchar([expr]) Number or String + get one character from the user getcharmod() Number modifiers for the last typed character getcharsearch() Dict last character search +getcharstr([expr]) String get one character from the user getcmdline() String return the current command-line getcmdpos() Number return cursor position in command-line getcmdtype() String return current command-line type @@ -3252,8 +3254,7 @@ count({comp}, {expr} [, {ic} [, {start}]]) *count()* cscope_connection([{num} , {dbpath} [, {prepend}]]) Checks for the existence of a |cscope| connection. If no parameters are specified, then the function returns: - 0, if cscope was not available (not compiled in), or - if there are no cscope connections; + 0, if there are no cscope connections; 1, if there is at least one cscope connection. If parameters are specified, then the value of {num} @@ -4309,6 +4310,7 @@ getchar([expr]) *getchar()* Return zero otherwise. If [expr] is 1, only check if a character is available, it is not consumed. Return zero if no character available. + If you prefer always getting a string use |getcharstr()|. Without [expr] and when [expr] is 0 a whole character or special key is returned. If it is a single character, the @@ -4400,6 +4402,20 @@ getcharsearch() *getcharsearch()* :nnoremap <expr> , getcharsearch().forward ? ',' : ';' < Also see |setcharsearch()|. + +getcharstr([expr]) *getcharstr()* + Get a single character from the user or input stream as a + string. + If [expr] is omitted, wait until a character is available. + If [expr] is 0 or false, only get a character when one is + available. Return an empty string otherwise. + If [expr] is 1 or true, only check if a character is + available, it is not consumed. Return an empty string + if no character is available. + Otherwise this works like |getchar()|, except that a number + result is converted to a string. + + getcmdline() *getcmdline()* Return the current command-line. Only works when the command line is being edited, thus requires use of |c_CTRL-\_e| or @@ -4743,7 +4759,10 @@ getqflist([{what}]) *getqflist()* bufname() to get the name module module name lnum line number in the buffer (first line is 1) + end_lnum + end of line number if the item is multiline col column number (first column is 1) + end_col end of column number if the item has range vcol |TRUE|: "col" is visual column |FALSE|: "col" is byte index nr error number @@ -5299,9 +5318,6 @@ iconv({expr}, {from}, {to}) *iconv()* are replaced with "?". The encoding names are whatever the iconv() library function can accept, see ":!man 3 iconv". - Most conversions require Vim to be compiled with the |+iconv| - feature. Otherwise only UTF-8 to latin1 conversion and back - can be done. Note that Vim uses UTF-8 for all Unicode encodings, conversion from/to UCS-2 is automatically changed to use UTF-8. You cannot use UCS-2 in a string anyway, because of the NUL bytes. @@ -5641,6 +5657,9 @@ jobstart({cmd}[, {opts}]) *jobstart()* before invoking `on_stderr`. |channel-buffered| stdout_buffered: (boolean) Collect data until EOF (stream closed) before invoking `on_stdout`. |channel-buffered| + stdin: (string) Either "pipe" (default) to connect the + job's stdin to a channel or "null" to disconnect + stdin. width: (number) Width of the `pty` terminal. {opts} is passed as |self| dictionary to the callback; the @@ -5830,8 +5849,7 @@ lispindent({lnum}) *lispindent()* indenting rules, as with 'lisp'. The indent is counted in spaces, the value of 'tabstop' is relevant. {lnum} is used just like in |getline()|. - When {lnum} is invalid or Vim was not compiled the - |+lispindent| feature, -1 is returned. + When {lnum} is invalid, -1 is returned. list2str({list} [, {utf8}]) *list2str()* Convert each number in {list} to a character string can @@ -6352,6 +6370,10 @@ mode([expr]) Return a string that indicates the current mode. s Select by character S Select by line CTRL-S Select blockwise + vs Visual by character using |v_CTRL-O| from + Select mode + Vs Visual by line using |v_CTRL-O| from Select mode + CTRL-Vs Visual blockwise using |v_CTRL-O| from Select mode i Insert ic Insert mode completion |compl-generic| ix Insert mode |i_CTRL-X| completion @@ -6360,8 +6382,7 @@ mode([expr]) Return a string that indicates the current mode. Rv Virtual Replace |gR| Rx Replace mode |i_CTRL-X| completion c Command-line editing - cv Vim Ex mode |gQ| - ce Normal Ex mode |Q| + cv Vim Ex mode |Q| or |gQ| r Hit-enter prompt rm The -- more -- prompt r? |:confirm| query of some sort @@ -7150,7 +7171,6 @@ rubyeval({expr}) *rubyeval()* Hashes are represented as Vim |Dictionary| type. Other objects are represented as strings resulted from their "Object#to_s" method. - {only available when compiled with the |+ruby| feature} screenattr({row}, {col}) *screenattr()* Like |screenchar()|, but return the attribute. This is a rather @@ -9139,8 +9159,6 @@ undofile({name}) *undofile()* If {name} is empty undofile() returns an empty string, since a buffer without a file name will not write an undo file. Useful in combination with |:wundo| and |:rundo|. - When compiled without the |+persistent_undo| option this always - returns an empty string. undotree() *undotree()* Return the current state of the undo tree in a dictionary with @@ -9305,10 +9323,12 @@ win_gettype([{nr}]) *win_gettype()* Return the type of the window: "autocmd" autocommand window. Temporary window used to execute autocommands. - "popup" popup window |popup| - "preview" preview window |preview-window| "command" command-line window |cmdwin| (empty) normal window + "loclist" |location-list-window| + "popup" popup window |popup| + "preview" preview window |preview-window| + "quickfix" |quickfix-window| "unknown" window {nr} not found When {nr} is omitted return the type of the current window. diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt index 0f1fa2b7a7..812259741f 100644 --- a/runtime/doc/gui.txt +++ b/runtime/doc/gui.txt @@ -175,7 +175,6 @@ system. To do this, put these commands in your vimrc file: > :map <F4> :emenu <C-Z> Pressing <F4> will start the menu. You can now use the cursor keys to select a menu entry. Hit <Enter> to execute it. Hit <Esc> if you want to cancel. -This does require the |+menu| feature enabled at compile time. Creating New Menus *creating-menus* @@ -473,9 +472,8 @@ Executing Menus *execute-menus* insert-mode menu Eg: > :emenu File.Exit -If the console-mode vim has been compiled with WANT_MENU defined, you can -use :emenu to access useful menu items you may have got used to from GUI -mode. See 'wildmenu' for an option that works well with this. See +You can use :emenu to access useful menu items you may have got used to from +GUI mode. See 'wildmenu' for an option that works well with this. See |console-menus| for an example. When using a range, if the lines match with '<,'>, then the menu is executed diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index 8b096ff28b..353058ec03 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -130,6 +130,7 @@ Advanced editing ~ |eval.txt| expression evaluation, conditional commands |fold.txt| hide (fold) ranges of lines |lua.txt| Lua API +|api.txt| Nvim API via RPC, Lua and VimL Special issues ~ |testing.txt| testing Vim and Vim scripts @@ -137,14 +138,15 @@ Special issues ~ |remote.txt| using Vim as a server or client Programming language support ~ -|indent.txt| automatic indenting for C and other languages -|lsp.txt| Language Server Protocol (LSP) -|syntax.txt| syntax highlighting -|filetype.txt| settings done specifically for a type of file -|quickfix.txt| commands for a quick edit-compile-fix cycle -|ft_ada.txt| Ada (the programming language) support -|ft_rust.txt| Filetype plugin for Rust -|ft_sql.txt| about the SQL filetype plugin +|indent.txt| automatic indenting for C and other languages +|lsp.txt| Language Server Protocol (LSP) +|treesitter.txt| tree-sitter library for incremental parsing of buffers +|syntax.txt| syntax highlighting +|filetype.txt| settings done specifically for a type of file +|quickfix.txt| commands for a quick edit-compile-fix cycle +|ft_ada.txt| Ada (the programming language) support +|ft_rust.txt| Filetype plugin for Rust +|ft_sql.txt| about the SQL filetype plugin Language support ~ |digraph.txt| list of available digraphs diff --git a/runtime/doc/helphelp.txt b/runtime/doc/helphelp.txt index 7643d84017..4a94701b2e 100644 --- a/runtime/doc/helphelp.txt +++ b/runtime/doc/helphelp.txt @@ -249,7 +249,6 @@ command: > It is possible to add translated help files, next to the original English help files. Vim will search for all help in "doc" directories in 'runtimepath'. -This is only available when compiled with the |+multi_lang| feature. At this moment translations are available for: Chinese - multiple authors diff --git a/runtime/doc/if_ruby.txt b/runtime/doc/if_ruby.txt index 02edd50ae8..47305c65fb 100644 --- a/runtime/doc/if_ruby.txt +++ b/runtime/doc/if_ruby.txt @@ -32,10 +32,6 @@ downloading Ruby there. This form of the |:ruby| command is mainly useful for including ruby code in vim scripts. - Note: This command doesn't work when the Ruby feature - wasn't compiled in. To avoid errors, see - |script-here|. - Example Vim script: > function! RedGem() diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 2aafc075a6..69a13557d1 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -699,8 +699,7 @@ tag char note action in Normal mode ~ tag char note action in Normal mode ~ ------------------------------------------------------------------------------ -|g_CTRL-A| g CTRL-A only when compiled with MEM_PROFILE - defined: dump a memory profile +|g_CTRL-A| g CTRL-A dump a memory profile |g_CTRL-G| g CTRL-G show information about current cursor position |g_CTRL-H| g CTRL-H start Select block mode diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index d6ef761bcb..7e589c095b 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -322,6 +322,18 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method } } < + Some handlers do not have an explicitly named handler function (such as + |on_publish_diagnostics()|). To override these, first create a reference + to the existing handler: > + + local on_references = vim.lsp.handlers["textDocument/references"] + vim.lsp.handlers["textDocument/references"] = vim.lsp.with( + on_references, { + -- Use location list instead of quickfix list + loclist = true, + } + ) +< *lsp-handler-resolution* Handlers can be set by: @@ -526,7 +538,19 @@ 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()|. + |nvim_buf_set_extmark()|. + +LspCodeLensSeparator *hl-LspCodeLensSeparator* + Used to color the seperator between two or more code lens. + + *lsp-highlight-signature* + +Highlight groups related to |vim.lsp.handlers.signature_help()|. + + *hl-LspSignatureActiveParameter* +LspSignatureActiveParameter + Used to highlight the active parameter in the signature help. See + |vim.lsp.handlers.signature_help()|. ============================================================================== AUTOCOMMANDS *lsp-autocommands* @@ -804,109 +828,117 @@ start_client({config}) *vim.lsp.start_client()* table. Parameters: ~ - {root_dir} (required, string) Directory where the - LSP server will base its rootUri on - initialization. - {cmd} (required, string or list treated like - |jobstart()|) Base command that - initiates the LSP client. - {cmd_cwd} (string, default=|getcwd()|) Directory - to launch the `cmd` process. Not - related to `root_dir` . - {cmd_env} (table) Environment flags to pass to - the LSP on spawn. Can be specified - using keys like a map or as a list with `k=v` pairs or both. Non-string values are - coerced to string. Example: > + {root_dir} (required, string) Directory where + the LSP server will base its rootUri + on initialization. + {cmd} (required, string or list treated + like |jobstart()|) Base command that + initiates the LSP client. + {cmd_cwd} (string, default=|getcwd()|) + Directory to launch the `cmd` + process. Not related to `root_dir` . + {cmd_env} (table) Environment flags to pass to + the LSP on spawn. Can be specified + using keys like a map or as a list + with `k=v` pairs or both. Non-string values are + coerced to string. Example: > { "PRODUCTION=true"; "TEST=123"; PORT = 8080; HOST = "0.0.0.0"; } < - {capabilities} Map overriding the default capabilities - defined by - |vim.lsp.protocol.make_client_capabilities()|, - passed to the language server on - initialization. Hint: use - make_client_capabilities() and modify - its result. - • Note: To send an empty dictionary use - `{[vim.type_idx]=vim.types.dictionary}` - , else it will be encoded as an - array. - {handlers} Map of language server method names to - |lsp-handler| - {settings} Map with language server specific - settings. These are returned to the - language server if requested via - `workspace/configuration` . Keys are - case-sensitive. - {init_options} Values to pass in the initialization - request as `initializationOptions` . - See `initialize` in the LSP spec. - {name} (string, default=client-id) Name in log - messages. - {get_language_id} function(bufnr, filetype) -> language - ID as string. Defaults to the filetype. - {offset_encoding} (default="utf-16") One of "utf-8", - "utf-16", or "utf-32" which is the - encoding that the LSP server expects. - Client does not verify this is correct. - {on_error} Callback with parameters (code, ...), - invoked when the client operation - throws an error. `code` is a number - describing the error. Other arguments - may be passed depending on the error - kind. See |vim.lsp.client_errors| for - possible errors. Use - `vim.lsp.client_errors[code]` to get - human-friendly name. - {before_init} Callback with parameters - (initialize_params, config) invoked - before the LSP "initialize" phase, - where `params` contains the parameters - being sent to the server and `config` - is the config that was passed to - |vim.lsp.start_client()|. You can use - this to modify parameters before they - are sent. - {on_init} Callback (client, initialize_result) - invoked after LSP "initialize", where - `result` is a table of `capabilities` - and anything else the server may send. - For example, clangd sends - `initialize_result.offsetEncoding` if - `capabilities.offsetEncoding` was sent - to it. You can only modify the - `client.offset_encoding` here before - any notifications are sent. Most - language servers expect to be sent - client specified settings after - initialization. Neovim does not make - this assumption. A - `workspace/didChangeConfiguration` - notification should be sent to the - server during on_init. - {on_exit} Callback (code, signal, client_id) - invoked on client exit. - • code: exit code of the process - • signal: number describing the signal - used to terminate (if any) - • client_id: client handle - {on_attach} Callback (client, bufnr) invoked when - client attaches to a buffer. - {trace} "off" | "messages" | "verbose" | nil - passed directly to the language server - in the initialize request. - Invalid/empty values will default to - "off" - {flags} A table with flags for the client. The - current (experimental) flags are: - • allow_incremental_sync (bool, default - true): Allow using incremental sync - for buffer edits - • debounce_text_changes (number, - default nil): Debounce didChange - notifications to the server by the - given number in milliseconds. No - debounce occurs if nil + {capabilities} Map overriding the default + capabilities defined by + |vim.lsp.protocol.make_client_capabilities()|, + passed to the language server on + initialization. Hint: use + make_client_capabilities() and modify + its result. + • Note: To send an empty dictionary + use + `{[vim.type_idx]=vim.types.dictionary}` + , else it will be encoded as an + array. + {handlers} Map of language server method names + to |lsp-handler| + {settings} Map with language server specific + settings. These are returned to the + language server if requested via + `workspace/configuration` . Keys are + case-sensitive. + {init_options} Values to pass in the initialization + request as `initializationOptions` . + See `initialize` in the LSP spec. + {name} (string, default=client-id) Name in + log messages. + {workspace_folders} (table) List of workspace folders + passed to the language server. + Defaults to root_dir if not set. See + `workspaceFolders` in the LSP spec + {get_language_id} function(bufnr, filetype) -> language + ID as string. Defaults to the + filetype. + {offset_encoding} (default="utf-16") One of "utf-8", + "utf-16", or "utf-32" which is the + encoding that the LSP server expects. + Client does not verify this is + correct. + {on_error} Callback with parameters (code, ...), + invoked when the client operation + throws an error. `code` is a number + describing the error. Other arguments + may be passed depending on the error + kind. See |vim.lsp.client_errors| for + possible errors. Use + `vim.lsp.client_errors[code]` to get + human-friendly name. + {before_init} Callback with parameters + (initialize_params, config) invoked + before the LSP "initialize" phase, + where `params` contains the + parameters being sent to the server + and `config` is the config that was + passed to |vim.lsp.start_client()|. + You can use this to modify parameters + before they are sent. + {on_init} Callback (client, initialize_result) + invoked after LSP "initialize", where + `result` is a table of `capabilities` + and anything else the server may + send. For example, clangd sends + `initialize_result.offsetEncoding` if + `capabilities.offsetEncoding` was + sent to it. You can only modify the + `client.offset_encoding` here before + any notifications are sent. Most + language servers expect to be sent + client specified settings after + initialization. Neovim does not make + this assumption. A + `workspace/didChangeConfiguration` + notification should be sent to the + server during on_init. + {on_exit} Callback (code, signal, client_id) + invoked on client exit. + • code: exit code of the process + • signal: number describing the + signal used to terminate (if any) + • client_id: client handle + {on_attach} Callback (client, bufnr) invoked when + client attaches to a buffer. + {trace} "off" | "messages" | "verbose" | nil + passed directly to the language + server in the initialize request. + Invalid/empty values will default to + "off" + {flags} A table with flags for the client. + The current (experimental) flags are: + • allow_incremental_sync (bool, + default true): Allow using + incremental sync for buffer edits + • debounce_text_changes (number, + default nil): Debounce didChange + notifications to the server by the + given number in milliseconds. No + debounce occurs if nil Return: ~ Client id. |vim.lsp.get_client_by_id()| Note: client may @@ -1176,6 +1208,34 @@ workspace_symbol({query}) *vim.lsp.buf.workspace_symbol()* ============================================================================== Lua module: vim.lsp.diagnostic *lsp-diagnostic* + *vim.lsp.diagnostic.apply_to_diagnostic_items()* +apply_to_diagnostic_items({item_handler}, {command}, {opts}) + Gets diagnostics, converts them to quickfix/location list + items, and applies the item_handler callback to the items. + + Parameters: ~ + {item_handler} function Callback to apply to the + diagnostic items + {command} string|nil Command to execute after + applying the item_handler + {opts} table|nil Configuration table. Keys: + • {client_id}: (number) + • If nil, will consider all clients + attached to buffer. + + • {severity}: (DiagnosticSeverity) + • Exclusive severity to consider. + Overrides {severity_limit} + + • {severity_limit}: (DiagnosticSeverity) + • Limit severity of diagnostics found. + E.g. "Warning" means { "Error", + "Warning" } will be valid. + + • {workspace}: (boolean, default false) + • Set the list with workspace + diagnostics + *vim.lsp.diagnostic.clear()* clear({bufnr}, {client_id}, {diagnostic_ns}, {sign_ns}) Clears the currently displayed diagnostics @@ -1187,6 +1247,26 @@ clear({bufnr}, {client_id}, {diagnostic_ns}, {sign_ns}) namespace {sign_ns} number|nil Associated sign namespace +disable({bufnr}, {client_id}) *vim.lsp.diagnostic.disable()* + Disable diagnostics for the given buffer and client + + Parameters: ~ + {bufnr} (optional, number): Buffer handle, defaults + to current + {client_id} (optional, number): Disable diagnostics for + the given client. The default is to disable + diagnostics for all attached clients. + +enable({bufnr}, {client_id}) *vim.lsp.diagnostic.enable()* + Enable diagnostics for the given buffer and client + + Parameters: ~ + {bufnr} (optional, number): Buffer handle, defaults + to current + {client_id} (optional, number): Enable diagnostics for + the given client. The default is to enable + diagnostics for all attached clients. + get({bufnr}, {client_id}) *vim.lsp.diagnostic.get()* Return associated diagnostics for bufnr @@ -1296,7 +1376,8 @@ get_prev_pos({opts}) *vim.lsp.diagnostic.get_prev_pos()* *vim.lsp.diagnostic.get_virtual_text_chunks_for_line()* get_virtual_text_chunks_for_line({bufnr}, {line}, {line_diags}, {opts}) - Default function to get text chunks to display using `nvim_buf_set_virtual_text` . + Default function to get text chunks to display using + |nvim_buf_set_extmark()|. Parameters: ~ {bufnr} number The buffer to display the virtual @@ -1308,7 +1389,9 @@ get_virtual_text_chunks_for_line({bufnr}, {line}, {line_diags}, {opts}) |vim.lsp.diagnostic.set_virtual_text()| Return: ~ - table chunks, as defined by |nvim_buf_set_virtual_text()| + an array of [text, hl_group] arrays. This can be passed + directly to the {virt_text} option of + |nvim_buf_set_extmark()|. goto_next({opts}) *vim.lsp.diagnostic.goto_next()* Move to the next diagnostic @@ -1407,6 +1490,22 @@ on_publish_diagnostics({_}, {_}, {params}, {client_id}, {_}, {config}) • Sort diagnostics (and thus signs and virtual text) +redraw({bufnr}, {client_id}) *vim.lsp.diagnostic.redraw()* + Redraw diagnostics for the given buffer and client + + This calls the "textDocument/publishDiagnostics" handler + manually using the cached diagnostics already received from + the server. This can be useful for redrawing diagnostics after + making changes in diagnostics configuration. + |lsp-handler-configuration| + + Parameters: ~ + {bufnr} (optional, number): Buffer handle, defaults + to current + {client_id} (optional, number): Redraw diagnostics for + the given client. The default is to redraw + diagnostics for all attached clients. + reset({client_id}, {buffer_client_map}) *vim.lsp.diagnostic.reset()* Clear diagnotics and diagnostic cache @@ -1418,6 +1517,11 @@ reset({client_id}, {buffer_client_map}) *vim.lsp.diagnostic.reset()* {buffer_client_map} table map of buffers to active clients + *vim.lsp.diagnostic.restore_extmarks()* +restore_extmarks({bufnr}, {last}) + Parameters: ~ + {last} number last line that was changed + save({diagnostics}, {bufnr}, {client_id}) *vim.lsp.diagnostic.save()* Save diagnostics to the current buffer. @@ -1429,12 +1533,16 @@ save({diagnostics}, {bufnr}, {client_id}) *vim.lsp.diagnostic.save()* {bufnr} number {client_id} number + *vim.lsp.diagnostic.save_extmarks()* +save_extmarks({bufnr}, {client_id}) + TODO: Documentation + set_loclist({opts}) *vim.lsp.diagnostic.set_loclist()* Sets the location list Parameters: ~ {opts} table|nil Configuration table. Keys: - • {open_loclist}: (boolean, default true) + • {open}: (boolean, default true) • Open loclist after set • {client_id}: (number) @@ -1453,6 +1561,30 @@ set_loclist({opts}) *vim.lsp.diagnostic.set_loclist()* • {workspace}: (boolean, default false) • Set the list with workspace diagnostics +set_qflist({opts}) *vim.lsp.diagnostic.set_qflist()* + Sets the quickfix list + + Parameters: ~ + {opts} table|nil Configuration table. Keys: + • {open}: (boolean, default true) + • Open quickfix list after set + + • {client_id}: (number) + • If nil, will consider all clients attached to + buffer. + + • {severity}: (DiagnosticSeverity) + • Exclusive severity to consider. Overrides + {severity_limit} + + • {severity_limit}: (DiagnosticSeverity) + • Limit severity of diagnostics found. E.g. + "Warning" means { "Error", "Warning" } will be + valid. + + • {workspace}: (boolean, default true) + • Set the list with workspace diagnostics + *vim.lsp.diagnostic.set_signs()* set_signs({diagnostics}, {bufnr}, {client_id}, {sign_ns}, {opts}) Set signs for given diagnostics @@ -1609,21 +1741,29 @@ save({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.save()* ============================================================================== Lua module: vim.lsp.handlers *lsp-handlers* - *vim.lsp.handlers.progress_handler()* -progress_handler({_}, {_}, {params}, {client_id}) - See also: ~ - https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand + *vim.lsp.handlers.hover()* +hover({_}, {method}, {result}, {_}, {_}, {config}) + |lsp-handler| for the method "textDocument/hover" > + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( + vim.lsp.handlers.hover, { + -- Use a sharp border with `FloatBorder` highlights + border = "single" + } + ) +< - *vim.lsp.handlers.signature_help()* -signature_help({_}, {method}, {result}, {_}, {bufnr}, {config}) Parameters: ~ {config} table Configuration table. • border: (default=nil) • Add borders to the floating window • See |vim.api.nvim_open_win()| - See also: ~ - https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration@seehttps://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition@seehttps://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition@seehttps://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation|lsp-handler| for the method "textDocument/signatureHelp"> + *vim.lsp.handlers.signature_help()* +signature_help({_}, {method}, {result}, {client_id}, {bufnr}, {config}) + |lsp-handler| for the method "textDocument/signatureHelp". The + active parameter is highlighted with + |hl-LspSignatureActiveParameter|. > vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( vim.lsp.handlers.signature_help, { @@ -1633,6 +1773,12 @@ signature_help({_}, {method}, {result}, {_}, {bufnr}, {config}) ) < + Parameters: ~ + {config} table Configuration table. + • border: (default=nil) + • Add borders to the floating window + • See |vim.api.nvim_open_win()| + ============================================================================== Lua module: vim.lsp.util *lsp-util* @@ -1659,6 +1805,9 @@ apply_text_edits({text_edits}, {bufnr}) {text_edits} (table) list of `TextEdit` objects {buf_nr} (number) Buffer id + See also: ~ + https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit + *vim.lsp.util.apply_workspace_edit()* apply_workspace_edit({workspace_edit}) Applies a `WorkspaceEdit` . @@ -1687,6 +1836,9 @@ buf_highlight_references({bufnr}, {references}) {references} List of `DocumentHighlight` objects to highlight + See also: ~ + https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight + buf_lines({bufnr}) *vim.lsp.util.buf_lines()* TODO: Documentation @@ -1756,7 +1908,7 @@ convert_input_to_markdown_lines({input}, {contents}) https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover *vim.lsp.util.convert_signature_help_to_markdown_lines()* -convert_signature_help_to_markdown_lines({signature_help}, {ft}) +convert_signature_help_to_markdown_lines({signature_help}, {ft}, {triggers}) Converts `textDocument/SignatureHelp` response to markdown lines. @@ -1765,6 +1917,9 @@ convert_signature_help_to_markdown_lines({signature_help}, {ft}) {ft} optional filetype that will be use as the `lang` for the label markdown code block + {triggers} optional list of trigger characters from + the lsp server. used to better determine + parameter offsets Return: ~ list of lines of converted markdown. @@ -1834,6 +1989,9 @@ get_lines({uri}, {rows}) *vim.lsp.util.get_lines()* Return: ~ table<number string> a table mapping rows to lines +get_markdown_fences() *vim.lsp.util.get_markdown_fences()* + TODO: Documentation + get_progress_messages() *vim.lsp.util.get_progress_messages()* TODO: Documentation @@ -1886,14 +2044,14 @@ make_floating_popup_options({width}, {height}, {opts}) *vim.lsp.util.make_formatting_params()* make_formatting_params({options}) - Creates a `FormattingOptions` object for the current buffer - and cursor position. + Creates a `DocumentFormattingParams` object for the current + buffer and cursor position. Parameters: ~ {options} Table with valid `FormattingOptions` entries Return: ~ - `FormattingOptions object + `DocumentFormattingParams` object See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 10d503e180..64c0d96aed 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1306,6 +1306,7 @@ completion can be enabled: -complete=highlight highlight groups -complete=history :history suboptions -complete=locale locale names (as output of locale -a) + -complete=lua Lua expression -complete=mapclear buffer argument -complete=mapping mapping name -complete=menu menus diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt index 5885b20ab7..6dbc54463c 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/nvim_terminal_emulator.txt @@ -324,12 +324,10 @@ This works slightly differently: mode with <Esc>, then you can move around in the buffer, copy/paste, etc. Go back to editing the gdb command with any command that starts Insert mode, such as `a` or `i`. -- The program being debugged will run in a separate window. On MS-Windows - this is a new console window. On Unix, if the |+terminal| feature is - available a Terminal window will be opened to run the debugged program in. +- A separate :terminal window will be opened to run the debugged program in. *termdebug_use_prompt* -Prompt mode can be used even when the |+terminal| feature is present with: > +Prompt mode can be used with: > let g:termdebug_use_prompt = 1 < diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 791fb8664e..f0ce15ac0f 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1038,7 +1038,12 @@ A jump table for the options with a short description can be found at |Q_op|. continuation (positive). sbr Display the 'showbreak' value before applying the additional indent. - The default value for min is 20 and shift is 0. + list:{n} Adds an additional indent for lines that match a + numbered or bulleted list (using the + 'formatlistpat' setting). + list:-1 Uses the length of a match with 'formatlistpat' + for indentation. + The default value for min is 20, shift and list is 0. *'browsedir'* *'bsdir'* 'browsedir' 'bsdir' string (default: "last") @@ -1802,13 +1807,30 @@ A jump table for the options with a short description can be found at |Q_op|. *'cursorline'* *'cul'* *'nocursorline'* *'nocul'* 'cursorline' 'cul' boolean (default off) local to window - Highlight the screen line of the cursor with CursorLine - |hl-CursorLine|. Useful to easily spot the cursor. Will make screen - redrawing slower. + Highlight the text line of the cursor with CursorLine |hl-CursorLine|. + Useful to easily spot the cursor. Will make screen redrawing slower. When Visual mode is active the highlighting isn't used to make it easier to see the selected text. + *'cursorlineopt'* *'culopt'* +'cursorlineopt' 'culopt' string (default: "number,line") + local to window + Comma separated list of settings for how 'cursorline' is displayed. + Valid values: + "line" Highlight the text line of the cursor with + CursorLine |hl-CursorLine|. + "screenline" Highlight only the screen line of the cursor with + CursorLine |hl-CursorLine|. + "number" Highlight the line number of the cursor with + CursorLineNr |hl-CursorLineNr|. + + Special value: + "both" Alias for the values "line,number". + + "line" and "screenline" cannot be used together. + + *'debug'* 'debug' string (default "") global @@ -2138,8 +2160,7 @@ A jump table for the options with a short description can be found at |Q_op|. global or local to buffer |global-local| External program to use for "=" command. When this option is empty the internal formatting functions are used; either 'lisp', 'cindent' - or 'indentexpr'. When Vim was compiled without internal formatting, - the "indent" program is used. + or 'indentexpr'. Environment variables are expanded |:set_env|. See |option-backslash| about including spaces and backslashes. This option cannot be set from a |modeline| or in the |sandbox|, for @@ -4540,11 +4561,6 @@ A jump table for the options with a short description can be found at |Q_op|. List of items that control the format of the output of |:hardcopy|. See |popt-option|. - *'prompt'* *'noprompt'* -'prompt' boolean (default on) - global - When on a ":" prompt is used in Ex mode. - *'pumblend'* *'pb'* 'pumblend' 'pb' number (default 0) global @@ -7093,8 +7109,7 @@ A jump table for the options with a short description can be found at |Q_op|. Allows writing to any file with no need for "!" override. *'writebackup'* *'wb'* *'nowritebackup'* *'nowb'* -'writebackup' 'wb' boolean (default on with |+writebackup| feature, off - otherwise) +'writebackup' 'wb' boolean (default on) global Make a backup before overwriting a file. The backup is removed after the file was successfully written, unless the 'backup' option is diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt index e7de5b9ee3..d9320ad315 100644 --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -103,10 +103,9 @@ will use the "latin1" print character encoding file. When 'encoding' is set to a multibyte encoding, Vim will try to convert characters to the printing encoding for printing (if 'printencoding' is empty -then the conversion will be to latin1). Conversion to a printing encoding -other than latin1 will require Vim to be compiled with the |+iconv| feature. -If no conversion is possible then printing will fail. Any characters that -cannot be converted will be replaced with upside down question marks. +then the conversion will be to latin1). If no conversion is possible then +printing will fail. Any characters that cannot be converted will be replaced +with upside down question marks. Two print character encoding files are provided to support default Mac and HPUX character encodings and are used by default on these platforms. Code page @@ -176,9 +175,7 @@ the font. When omitted, the point size is 10. 'printheader' 'pheader' string (default "%<%f%h%m%=Page %N") global This defines the format of the header produced in |:hardcopy| output. The -option is defined in the same way as the 'statusline' option. If Vim has not -been compiled with the |+statusline| feature, this option has no effect and a -simple default header is used, which shows the page number. The same simple +option is defined in the same way as the 'statusline' option. The same simple header is used when this option is empty. *pmbcs-option* diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index fb20a583c9..77e69a3eea 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -659,6 +659,7 @@ Short explanation of each option: *option-list* 'cursorbind' 'crb' move cursor in window as it moves in other windows 'cursorcolumn' 'cuc' highlight the screen column of the cursor 'cursorline' 'cul' highlight the screen line of the cursor +'cursorlineopt' 'culopt' settings for 'cursorline' 'debug' set to "msg" to see all error messages 'define' 'def' pattern to be used to find a macro definition 'delcombine' 'deco' delete combining characters on their own @@ -809,7 +810,6 @@ Short explanation of each option: *option-list* 'printmbcharset' 'pmbcs' CJK character set to be used for :hardcopy 'printmbfont' 'pmbfn' font names to be used for CJK output of :hardcopy 'printoptions' 'popt' controls the format of :hardcopy output -'prompt' 'prompt' enable prompt in Ex mode 'pumheight' 'ph' maximum height of the popup menu 'pumwidth' 'pw' minimum width of the popup menu 'pythondll' name of the Python 2 dynamic library diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt deleted file mode 100644 index 6c2ceb45be..0000000000 --- a/runtime/doc/remote.txt +++ /dev/null @@ -1,189 +0,0 @@ -*remote.txt* Nvim - - - VIM REFERENCE MANUAL by Bram Moolenaar - - -Vim client-server communication *client-server* - - Type |gO| to see the table of contents. - -============================================================================== -1. Common functionality *clientserver* - -When compiled with the |+clientserver| option, Vim can act as a command -server. It accepts messages from a client and executes them. At the same -time, Vim can function as a client and send commands to a Vim server. - -The following command line arguments are available: - - argument meaning ~ - - --remote [+{cmd}] {file} ... *--remote* - Open the file list in a remote Vim. When - there is no Vim server, execute locally. - There is one optional init command: +{cmd}. - This must be an Ex command that can be - followed by "|". - The rest of the command line is taken as the - file list. Thus any non-file arguments must - come before this. - You cannot edit stdin this way |--|. - The remote Vim is raised. If you don't want - this use > - vim --remote-send "<C-\><C-N>:n filename<CR>" -< - --remote-silent [+{cmd}] {file} ... *--remote-silent* - As above, but don't complain if there is no - server and the file is edited locally. - --remote-wait [+{cmd}] {file} ... *--remote-wait* - As --remote, but wait for files to complete - (unload) in remote Vim. - --remote-wait-silent [+{cmd}] {file} ... *--remote-wait-silent* - As --remote-wait, but don't complain if there - is no server. - *--remote-tab* - --remote-tab Like --remote but open each file in a new - tabpage. - *--remote-tab-silent* - --remote-tab-silent Like --remote-silent but open each file in a - new tabpage. - *--remote-tab-wait* - --remote-tab-wait Like --remote-wait but open each file in a new - tabpage. - - *--remote-tab-wait-silent* - --remote-tab-wait-silent Like --remote-wait-silent but open each file - in a new tabpage. - *--remote-send* - --remote-send {keys} Send {keys} to server and exit. The {keys} - are not mapped. Special key names are - recognized, e.g., "<CR>" results in a CR - character. - *--remote-expr* - --remote-expr {expr} Evaluate {expr} in server and print the result - on stdout. - -Examples ~ - -Edit "file.txt" in an already running GVIM server: > - gvim --remote file.txt - -Edit "file.txt" in an already running server called FOOBAR: > - gvim --servername FOOBAR --remote file.txt - -Edit "file.txt" in server "FILES" if it exists, become server "FILES" -otherwise: > - gvim --servername FILES --remote-silent file.txt - -This doesn't work, all arguments after --remote will be used as file names: > - gvim --remote --servername FOOBAR file.txt - -Edit file "+foo" in a remote server (note the use of "./" to avoid the special -meaning of the leading plus): > - vim --remote ./+foo - -Tell the remote server "BLA" to write all files and exit: > - vim --servername BLA --remote-send '<C-\><C-N>:wqa<CR>' - - -SERVER NAME *client-server-name* - -By default Vim will try to register the name under which it was invoked (gvim, -egvim ...). This can be overridden with the --servername argument. If the -specified name is not available, a postfix is applied until a free name is -encountered, i.e. "gvim1" for the second invocation of gvim on a particular -X-server. The resulting name is available in the servername builtin variable -|v:servername|. The case of the server name is ignored, thus "gvim" and -"GVIM" are considered equal. - -When Vim is invoked with --remote, --remote-wait or --remote-send it will try -to locate the server name determined by the invocation name and --servername -argument as described above. If an exact match is not available, the first -server with the number postfix will be used. If a name with the number -postfix is specified with the --servername argument, it must match exactly. - -If no server can be located and --remote or --remote-wait was used, Vim will -start up according to the rest of the command line and do the editing by -itself. This way it is not necessary to know whether gvim is already started -when sending command to it. - -The --serverlist argument will cause Vim to print a list of registered command -servers on the standard output (stdout) and exit. - -Win32 Note: Making the Vim server go to the foreground doesn't always work, -because MS-Windows doesn't allow it. The client will move the server to the -foreground when using the --remote or --remote-wait argument and the server -name starts with "g". - - -REMOTE EDITING - -The --remote argument will cause a |:drop| command to be constructed from the -rest of the command line and sent as described above. -The --remote-wait argument does the same thing and additionally sets up to -wait for each of the files to have been edited. This uses the BufUnload -event, thus as soon as a file has been unloaded, Vim assumes you are done -editing it. -Note that the --remote and --remote-wait arguments will consume the rest of -the command line. I.e. all remaining arguments will be regarded as filenames. -You can not put options there! - - -FUNCTIONS - *E240* *E573* -There are a number of Vim functions for scripting the command server. See -the description in |eval.txt| or use CTRL-] on the function name to jump to -the full explanation. - - synopsis explanation ~ - remote_startserver( name) run a server - remote_expr( server, string, idvar) send expression - remote_send( server, string, idvar) send key sequence - serverlist() get a list of available servers - remote_peek( serverid, retvar) check for reply string - remote_read( serverid) read reply string - server2client( serverid, string) send reply string - remote_foreground( server) bring server to the front - -See also the explanation of |CTRL-\_CTRL-N|. Very useful as a leading key -sequence. -The {serverid} for server2client() can be obtained with expand("<client>") - -============================================================================== -2. X11 specific items *x11-clientserver* - *E247* *E248* *E251* *E258* *E277* - -The communication between client and server goes through the X server. The -display of the Vim server must be specified. The usual protection of the X -server is used, you must be able to open a window on the X server for the -communication to work. It is possible to communicate between different -systems. - -By default, a GUI Vim will register a name on the X-server by which it can be -addressed for subsequent execution of injected strings. Vim can also act as -a client and send strings to other instances of Vim on the same X11 display. - -When an X11 GUI Vim (gvim) is started, it will try to register a send-server -name on the 'VimRegistry' property on the root window. - -An empty --servername argument will cause the command server to be disabled. - -To send commands to a Vim server from another application, read the source -file src/if_xcmdsrv.c, it contains some hints about the protocol used. - -============================================================================== -3. Win32 specific items *w32-clientserver* - -Every Win32 Vim can work as a server, also in the console. You do not need a -version compiled with OLE. Windows messages are used, this works on any -version of MS-Windows. But only communication within one system is possible. - -Since MS-Windows messages are used, any other application should be able to -communicate with a Vim server. - -When using gvim, the --remote-wait only works properly this way: > - - start /w gvim --remote-wait file.txt -< - vim:tw=78:sw=4:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 6755747dcf..a91aa4d2a0 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -172,42 +172,34 @@ Using Vim scripts *using-scripts* For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. *:so* *:source* *load-vim-script* -:so[urce] {file} Runs vim or lua {file} +:so[urce] {file} Runs |Ex| commands or Lua code (".lua" files) read + from {file}. Triggers the |SourcePre| autocommand. - - Note: Only files ending with `.lua` is sourced as - lua file. Anything else is assumed to be vimscript. *:source!* -:so[urce]! {file} Read Vim commands from {file}. These are commands - that are executed from Normal mode, like you type - them. - When used after |:global|, |:argdo|, |:windo|, - |:bufdo|, in a loop or when another command follows - the display won't be updated while executing the - commands. +:so[urce]! {file} Runs |Normal-mode| commands read from {file}. When + used after |:global|, |:argdo|, |:windo|, |:bufdo|, in + a loop or when another command follows the display + won't be updated while executing the commands. Cannot be used in the |sandbox|. *:ru* *:runtime* :ru[ntime][!] [where] {file} .. - Source vim/lua {file} in each directory given by - 'runtimepath' and/or 'packpath'. The vim files are - executed in same mannar as |:source| and lua files - similarly as |:luafile|. There is no error - for non-existing files. + Sources |Ex| commands or Lua code (".lua" files) read + from {file} (a relative path) in each directory given + by 'runtimepath' and/or 'packpath'. + Ignores non-existing files. Example: > :runtime syntax/c.vim + :runtime syntax/c.lua -< There can be multiple {file} arguments, separated by - spaces. Each {file} is searched for in the first +< There can be multiple space-separated {file} + arguments. Each {file} is searched for in the first directory from 'runtimepath', then in the second - directory, etc. Use a backslash to include a space - inside {file} (although it's better not to use spaces - in file names, it causes trouble). + directory, etc. When [!] is included, all found files are sourced. - When it is not included only the first found file is - sourced. + Else only the first found file is sourced. When [where] is omitted only 'runtimepath' is used. Other values: @@ -911,11 +903,9 @@ OBSCURE Profiling *profile* *profiling* Profiling means that Vim measures the time that is spent on executing -functions and/or scripts. The |+profile| feature is required for this. -It is only included when Vim was compiled with "huge" features. +functions and/or scripts. -You can also use the |reltime()| function to measure time. This only requires -the |+reltime| feature, which is present more often. +You can also use the |reltime()| function to measure time. For profiling syntax highlighting see |:syntime|. diff --git a/runtime/doc/russian.txt b/runtime/doc/russian.txt index 776630a52b..a2bc9f3b5e 100644 --- a/runtime/doc/russian.txt +++ b/runtime/doc/russian.txt @@ -47,10 +47,6 @@ different codepages from http://www.sourceforge.net/projects/ruvim/ -Make sure that your Vim is at least 6.2.506 and use ruvim 0.5 or later for -automatic installs. Vim also needs to be compiled with |+gettext| feature for -user interface items translations to work. - After downloading an archive from RuVim project, unpack it into your $VIMRUNTIME directory. We recommend using UTF-8 archive. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 5431ce3bd8..80b8dd52ea 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -407,20 +407,18 @@ accordingly. Vim proceeds in this order: proceeding to load user configuration. 4. Load user config (execute Ex commands from files, environment, …). - An environment variable (e.g. $VIMINIT) is read as one Ex command - line, where multiple commands must be separated with '|' or <NL>. + $VIMINIT environment variable is read as one Ex command line (separate + multiple commands with '|' or <NL>). *config* *init.vim* *init.lua* *vimrc* *exrc* - A file that contains initialization commands is generically called - a "vimrc" or config file. It can be a Vimscript or Lua file named - "init.vim" or "init.lua" respectively. It is an error to use both at - the same time. Each line in a "init.vim" is executed as an Ex command - line. See also |vimrc-intro| and |base-directories|. + A file containing initialization commands is generically called + a "vimrc" or config file. It can be either Vimscript ("init.vim") or + Lua ("init.lua"), but not both. *E5422* + See also |vimrc-intro| and |base-directories|. 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 (or init.lua) + Unix ~/.config/nvim/init.vim (or init.lua) + Windows ~/AppData/Local/nvim/init.vim (or init.lua) + |$XDG_CONFIG_HOME| $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. @@ -470,14 +468,11 @@ accordingly. Vim proceeds in this order: This does the same as the command: > :runtime! plugin/**/*.vim :runtime! plugin/**/*.lua -< The result is that all directories in the 'runtimepath' option will be - searched for the "plugin" sub-directory and all files ending in ".vim" - and ".lua" will be sourced (in alphabetical order per directory), - also in subdirectories. First all the "*.vim" files will be sourced and - then all the "*.lua" files will be sourced. If two files with same - name but different extensions exists they will be treated in same - manner. For example when both "foo.vim" and "foo.lua" exists then - first "foo.vim" will be sourced then "foo.lua" will be sourced. +< The result is that all directories in 'runtimepath' will be searched + for the "plugin" sub-directory and all files ending in ".vim" or + ".lua" will be sourced (in alphabetical order per directory), + also in subdirectories. First "*.vim" are sourced, then "*.lua" files. + However, directories in 'runtimepath' ending in "after" are skipped here and only loaded after packages, see below. Loading plugins won't be done when: @@ -485,7 +480,6 @@ accordingly. Vim proceeds in this order: - The |--noplugin| command line argument is used. - The |--clean| command line argument is used. - The "-u NONE" command line argument is used |-u|. - - When Vim was compiled without the |+eval| feature. Note that using "-c 'set noloadplugins'" doesn't work, because the commands from the command line have not been executed yet. You can use "--cmd 'set noloadplugins'" or "--cmd 'set loadplugins'" |--cmd|. diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index bf649b5940..0cd3aed7a2 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -25,11 +25,15 @@ In the User Manual: ============================================================================== 1. Quick start *:syn-qstart* - *:syn-enable* *:syntax-enable* + *:syn-enable* *:syntax-enable* *:syn-on* *:syntax-on* This command switches on syntax highlighting: > :syntax enable +Alternatively: > + + :syntax on + What this command actually does is to execute the command > :source $VIMRUNTIME/syntax/syntax.vim @@ -42,19 +46,11 @@ are in the "/usr/vim/vim82/syntax" directory, set $VIMRUNTIME to This command also sources the |menu.vim| script when the GUI is running or will start soon. See |'go-M'| about avoiding that. - *:syn-on* *:syntax-on* -The `:syntax enable` command will keep most of your current color settings. -This allows using `:highlight` commands to set your preferred colors before or -after using this command. If you want Vim to overrule your settings with the -defaults, use: > - :syntax on -< *:hi-normal* *:highlight-normal* If you are running in the GUI, you can get white text on a black background with: > :highlight Normal guibg=Black guifg=White For a color terminal see |:hi-normal-cterm|. -For setting up your own colors syntax highlighting see |syncolor|. NOTE: The syntax files on MS-Windows have lines that end in <CR><NL>. The files for Unix end in <NL>. This means you should use the right type of @@ -277,12 +273,6 @@ located. This is used here as the variable |$VIMRUNTIME|. | +- Source first syntax/synload.vim in 'runtimepath' | | - | +- Setup the colors for syntax highlighting. If a color scheme is - | | defined it is loaded again with ":colors {name}". Otherwise - | | ":runtime! syntax/syncolor.vim" is used. ":syntax on" overrules - | | existing colors, ":syntax enable" only sets groups that weren't - | | set yet. - | | | +- Set up syntax autocmds to load the appropriate syntax file when | | the 'syntax' option is set. *synload-1* | | @@ -371,9 +361,6 @@ the desired value, or restored to their default by removing the variable using Remarks: - Some truly ancient browsers may not show the background colors. - From most browsers you can also print the file (in color)! -- The latest TOhtml may actually work with older versions of Vim, but some - features such as conceal support will not function, and the colors may be - incorrect for an old Vim without GUI support compiled in. Here is an example how to run the script over all .c and .h files from a Unix shell: > @@ -4745,8 +4732,7 @@ in their own color. This is basically the same as > :echo g:colors_name < In case g:colors_name has not been defined :colo will - output "default". When compiled without the |+eval| - feature it will output "unknown". + output "default". :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath' for the file "colors/{name}.(vim|lua)". The first one that @@ -5079,7 +5065,8 @@ Substitute |:substitute| replacement text highlighting LineNr Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. *hl-CursorLineNr* -CursorLineNr Like LineNr when 'cursorline' or 'relativenumber' is set for +CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' is + set to "number" or "both", or 'relativenumber' is set, for the cursor line. *hl-MatchParen* MatchParen The character under the cursor or just before it, if it @@ -5275,51 +5262,10 @@ back to their Vim default. Note that if you are using a color scheme, the colors defined by the color scheme for syntax highlighting will be lost. -What this actually does is: > - - let g:syntax_cmd = "reset" - runtime! syntax/syncolor.vim - -Note that this uses the 'runtimepath' option. - - *syncolor* -If you want to use different colors for syntax highlighting, you can add a Vim -script file to set these colors. Put this file in a directory in -'runtimepath' which comes after $VIMRUNTIME, so that your settings overrule -the default colors. This way these colors will be used after the ":syntax -reset" command. - -For Unix you can use the file ~/.config/nvim/after/syntax/syncolor.vim. -Example: > - - if &background == "light" - highlight comment ctermfg=darkgreen guifg=darkgreen - else - highlight comment ctermfg=green guifg=green - endif - - *E679* -Do make sure this syncolor.vim script does not use a "syntax on", set the -'background' option or uses a "colorscheme" command, because it results in an -endless loop. - Note that when a color scheme is used, there might be some confusion whether your defined colors are to be used or the colors from the scheme. This depends on the color scheme file. See |:colorscheme|. - *syntax_cmd* -The "syntax_cmd" variable is set to one of these values when the -syntax/syncolor.vim files are loaded: - "on" ":syntax on" command. Highlight colors are overruled but - links are kept - "enable" ":syntax enable" command. Only define colors for groups that - don't have highlighting yet. Use ":syntax default". - "reset" ":syntax reset" command or loading a color scheme. Define all - the colors. - "skip" Don't define colors. Used to skip the default settings when a - syncolor.vim file earlier in 'runtimepath' has already set - them. - ============================================================================== 16. Highlighting tags *tag-highlight* @@ -5404,9 +5350,6 @@ If your syntax causes redrawing to be slow, here are a few hints on making it faster. To see slowness switch on some features that usually interfere, such as 'relativenumber' and |folding|. -Note: this is only available when compiled with the |+profile| feature. -You many need to build Vim with "huge" features. - To find out what patterns are consuming most time, get an overview with this sequence: > :syntime on diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index 2c1b927e5a..4d938c4a23 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -367,11 +367,11 @@ be a bug. If you really want the old Vi behavior, set the 't' flag in 'cpoptions'. *tag-binary-search* -Vim uses binary searching in the tags file to find the desired tag quickly -(when enabled at compile time |+tag_binary|). But this only works if the -tags file was sorted on ASCII byte value. Therefore, if no match was found, -another try is done with a linear search. If you only want the linear search, -reset the 'tagbsearch' option. Or better: Sort the tags file! +Vim uses binary searching in the tags file to find the desired tag quickly. +But this only works if the tags file was sorted on ASCII byte value. +Therefore, if no match was found, another try is done with a linear search. +If you only want the linear search, reset the 'tagbsearch' option. Or better: +Sort the tags file! Note that the binary searching is disabled when not looking for a tag with a specific name. This happens when ignoring case and when a regular expression @@ -666,9 +666,6 @@ included files (recursively). This can be used to find the definition of a variable, function or macro. If you only want to search in the current buffer, use the commands listed at |pattern-searches|. -These commands are not available when the |+find_in_path| feature was disabled -at compile time. - When a line is encountered that includes another file, that file is searched before continuing in the current buffer. Files included by included files are also searched. When an include file could not be found it is silently diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt index b2ce6d670d..ef8d6b5ea9 100644 --- a/runtime/doc/testing.txt +++ b/runtime/doc/testing.txt @@ -30,8 +30,7 @@ New tests should be added as new style tests. These use functions such as |assert_equal()| to keep the test commands and the expected result in one place. *old-style-testing* -In some cases an old style test needs to be used. E.g. when testing Vim -without the |+eval| feature. +In some cases an old style test needs to be used. Find more information in the file src/testdir/README.txt. diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 416ea3a08a..906e2d716a 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -169,7 +169,7 @@ a tree, using a simple to write lisp-like format. See https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax for more information on how to write queries. -Note: The perdicates listed in the web page above differ from those Neovim +Note: The predicates listed in the web page above differ from those Neovim supports. See |lua-treesitter-predicates| for a complete list of predicates supported by Neovim. @@ -215,9 +215,9 @@ Here is a list of built-in predicates : ((identifier) @foo-bar (#contains @foo-bar "foo" "bar")) < `any-of?` *ts-predicate-any-of?* - Will check if the text is the same as any of the following + Will check if the text is the same as any of the following. This is the recommended way to check if the node matches one - of many keywords for exemple, as it has been optimized for + of many keywords for example, as it has been optimized for this. arguments : > ((identifier) @foo (#any-of? @foo "foo" "bar")) @@ -226,10 +226,22 @@ Here is a list of built-in predicates : Each predicate has a `not-` prefixed predicate that is just the negation of the predicate. + *vim.treesitter.query.add_predicate()* +vim.treesitter.query.add_predicate({name}, {handler}) + +This adds a predicate with the name {name} to be used in queries. +{handler} should be a function whose signature will be : > + handler(match, pattern, bufnr, predicate) +< + *vim.treesitter.query.list_predicates()* +vim.treesitter.query.list_predicates() + +This lists the currently available predicates to use in queries. + Treesitter Query Directive *lua-treesitter-directives* Treesitter queries can also contain `directives`. Directives store metadata for a node -or match and perform side effects. for example, the |set!| predicate sets metadata on +or match and perform side effects. For example, the |set!| predicate sets metadata on the match or node : > ((identifier) @foo (#set! "type" "parameter")) @@ -249,6 +261,21 @@ Here is a list of built-in directives: `({capture_id}, {start_row}, {start_col}, {end_row}, {end_col}, {key?})` The default key is "offset". + *vim.treesitter.query.add_directive()* +vim.treesitter.query.add_directive({name}, {handler}) + +This adds a directive with the name {name} to be used in queries. +{handler} should be a function whose signature will be : > + handler(match, pattern, bufnr, predicate, metadata) +Handlers can set match level data by setting directly on the metadata object `metadata.key = value` +Handlers can set node level data by using the capture id on the metadata table +`metadata[capture_id].key = value` + + *vim.treesitter.query.list_directives()* +vim.treesitter.query.list_directives() + +This lists the currently available directives to use in queries. + Treesitter syntax highlighting (WIP) *lua-treesitter-highlight* NOTE: This is a partially implemented feature, and not usable as a default @@ -294,6 +321,19 @@ identical identifiers, highlighting both as |hl-WarningMsg|: > ((binary_expression left: (identifier) @WarningMsg.left right: (identifier) @WarningMsg.right) (eq? @WarningMsg.left @WarningMsg.right)) < +Treesitter Highlighting Priority *lua-treesitter-highlight-priority* + +Tree-sitter uses |nvim_buf_set_extmark()| to set highlights with a default +priority of 100. This enables plugins to set a highlighting priority lower or +higher than tree-sitter. It is also possible to change the priority of an +individual query pattern manually by setting its `"priority"` metadata attribute: > + + ( + (super_important_node) @ImportantHighlight + ; Give the whole query highlight priority higher than the default (100) + (set! "priority" 105) + ) +< ============================================================================== Lua module: vim.treesitter *lua-treesitter-core* @@ -393,8 +433,13 @@ get_query_files({lang}, {query_name}, {is_included}) {is_included} Internal parameter, most of the time left as `nil` +list_directives() *list_directives()* + Return: ~ + The list of supported directives. + list_predicates() *list_predicates()* - TODO: Documentation + Return: ~ + The list of supported predicates. parse_query({lang}, {query}) *parse_query()* Parse {query} as a string. (If the query is in a file, the diff --git a/runtime/doc/usr_45.txt b/runtime/doc/usr_45.txt index bc95f3405e..3199c4d8ea 100644 --- a/runtime/doc/usr_45.txt +++ b/runtime/doc/usr_45.txt @@ -31,13 +31,6 @@ this command: > If it replies with "C", this means the default is being used, which is English. - Note: - Using different languages only works when Vim was compiled to handle - it. To find out if it works, use the ":version" command and check the - output for "+gettext" and "+multi_lang". If they are there, you are - OK. If you see "-gettext" or "-multi_lang" you will have to find - another Vim. - What if you would like your messages in a different language? There are several ways. Which one you should use depends on the capabilities of your system. diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 27c4b82aca..2c53620049 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -358,6 +358,14 @@ Startup: - works by default: "-" file is optional - works in more cases: |-Es|, file args +Syntax highlighting: + syncolor.vim has been removed. Nvim now sets up default highlighting groups + automatically for both light and dark backgrounds, regardless of whether or + not syntax highlighting is enabled. This means that |:syntax-on| and + |:syntax-enable| are now identical. Users who previously used an + after/syntax/syncolor.vim file should transition that file into a + colorscheme. |:colorscheme| + TUI: *:set-termcap* Start Nvim with 'verbose' level 3 to show terminal capabilities: > @@ -473,6 +481,7 @@ Options: 'maxmem' Nvim delegates memory-management to the OS. 'maxmemtot' Nvim delegates memory-management to the OS. 'maxcombine' (6 is always used) + *'prompt'* *'noprompt'* *'restorescreen'* *'rs'* *'norestorescreen'* *'nors'* 'shelltype' *'shortname'* *'sn'* *'noshortname'* *'nosn'* diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 2617d8ffc0..f012c7cb4b 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -646,6 +646,9 @@ au BufNewFile,BufRead *.mo,*.gdmo setf gdmo " Gedcom au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom +" Gemtext +au BufNewFile,BufRead *.gmi,*.gemini setf gemtext + " Gift (Moodle) autocmd BufRead,BufNewFile *.gift setf gift @@ -864,6 +867,9 @@ au BufNewFile,BufRead *.json-patch setf json " Jupyter Notebook is also json au BufNewFile,BufRead *.ipynb setf json +" JSONC +au BufNewFile,BufRead *.jsonc setf jsonc + " Kixtart au BufNewFile,BufRead *.kix setf kix @@ -1513,6 +1519,9 @@ au BufNewFile,BufRead *.sbt setf sbt " Scilab au BufNewFile,BufRead *.sci,*.sce setf scilab +" scdoc +au BufNewFile,BufRead *.scd setf scdoc + " SCSS au BufNewFile,BufRead *.scss setf scss diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index b1f935541c..f7d47c1030 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -494,7 +494,6 @@ local convert_value_to_lua = (function() for _, key_value_str in ipairs(comma_split) do local key, value = unpack(vim.split(key_value_str, ":")) key = vim.trim(key) - value = vim.trim(value) result[key] = value end diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 75faf9bcc7..87ecc3eeea 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -453,15 +453,7 @@ local function text_document_did_open_handler(bufnr, client) -- Next chance we get, we should re-do the diagnostics vim.schedule(function() - vim.lsp.handlers["textDocument/publishDiagnostics"]( - nil, - "textDocument/publishDiagnostics", - { - diagnostics = vim.lsp.diagnostic.get(bufnr, client.id), - uri = vim.uri_from_bufnr(bufnr), - }, - client.id - ) + vim.lsp.diagnostic.redraw(bufnr, client.id) end) end @@ -590,6 +582,10 @@ end --- as `initializationOptions`. See `initialize` in the LSP spec. --- --@param name (string, default=client-id) Name in log messages. +-- +--@param workspace_folders (table) List of workspace folders passed to the +--- language server. Defaults to root_dir if not set. See `workspaceFolders` in +--- the LSP spec --- --@param get_language_id function(bufnr, filetype) -> language ID as string. --- Defaults to the filetype. @@ -775,6 +771,14 @@ function lsp.start_client(config) off = 'off'; messages = 'messages'; verbose = 'verbose'; } local version = vim.version() + + if not config.workspace_folders then + config.workspace_folders = {{ + uri = vim.uri_from_fname(config.root_dir); + name = string.format("%s", config.root_dir); + }}; + end + local initialize_params = { -- The process Id of the parent process that started the server. Is null if -- the process has not been started by another process. If the parent @@ -815,10 +819,7 @@ function lsp.start_client(config) -- -- workspace folder in the user interface. -- name -- } - workspaceFolders = {{ - uri = vim.uri_from_fname(config.root_dir); - name = string.format("%s", config.root_dir); - }}; + workspaceFolders = config.workspace_folders, } if config.before_init then -- TODO(ashkan) handle errors here. diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index b13d662ccb..29f8d6c3bc 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -126,7 +126,7 @@ local function select_client(method) if #clients > 1 then local choices = {} - for k,v in ipairs(clients) do + for k,v in pairs(clients) do table.insert(choices, string.format("%d %s", k, v.name)) end local user_choice = vim.fn.confirm( @@ -204,9 +204,9 @@ function M.formatting_seq_sync(options, timeout_ms, order) local clients = vim.tbl_values(vim.lsp.buf_get_clients()); -- sort the clients according to `order` - for _, client_name in ipairs(order or {}) do + for _, client_name in pairs(order or {}) do -- if the client exists, move to the end of the list - for i, client in ipairs(clients) do + for i, client in pairs(clients) do if client.name == client_name then table.insert(clients, table.remove(clients, i)) break @@ -215,7 +215,7 @@ function M.formatting_seq_sync(options, timeout_ms, order) end -- loop through the clients and make synchronous formatting requests - for _, client in ipairs(clients) do + for _, client in pairs(clients) do if client.resolved_capabilities.document_formatting then local params = util.make_formatting_params(options) local result, err = client.request_sync("textDocument/formatting", params, timeout_ms, vim.api.nvim_get_current_buf()) @@ -286,7 +286,7 @@ local function pick_call_hierarchy_item(call_hierarchy_items) return call_hierarchy_items[1] end local items = {} - for i, item in ipairs(call_hierarchy_items) do + for i, item in pairs(call_hierarchy_items) do local entry = item.detail or item.name table.insert(items, string.format("%d. %s", i, entry)) end @@ -328,8 +328,8 @@ end --- function M.list_workspace_folders() local workspace_folders = {} - for _, client in ipairs(vim.lsp.buf_get_clients()) do - for _, folder in ipairs(client.workspaceFolders) do + for _, client in pairs(vim.lsp.buf_get_clients()) do + for _, folder in pairs(client.workspaceFolders) do table.insert(workspace_folders, folder.name) end end @@ -347,9 +347,9 @@ function M.add_workspace_folder(workspace_folder) return end local params = util.make_workspace_params({{uri = vim.uri_from_fname(workspace_folder); name = workspace_folder}}, {{}}) - for _, client in ipairs(vim.lsp.buf_get_clients()) do + for _, client in pairs(vim.lsp.buf_get_clients()) do local found = false - for _, folder in ipairs(client.workspaceFolders) do + for _, folder in pairs(client.workspaceFolders) do if folder.name == workspace_folder then found = true print(workspace_folder, "is already part of this workspace") @@ -371,8 +371,8 @@ function M.remove_workspace_folder(workspace_folder) vim.api.nvim_command("redraw") if not (workspace_folder and #workspace_folder > 0) then return end local params = util.make_workspace_params({{}}, {{uri = vim.uri_from_fname(workspace_folder); name = workspace_folder}}) - for _, client in ipairs(vim.lsp.buf_get_clients()) do - for idx, folder in ipairs(client.workspaceFolders) do + for _, client in pairs(vim.lsp.buf_get_clients()) do + for idx, folder in pairs(client.workspaceFolders) do if folder.name == workspace_folder then vim.lsp.buf_notify(0, 'workspace/didChangeWorkspaceFolders', params) client.workspaceFolders[idx] = nil @@ -422,6 +422,21 @@ function M.clear_references() util.buf_clear_references() end +--- Requests code actions from all clients and calls the handler exactly once +--- with all aggregated results +--@private +local function code_action_request(params) + local bufnr = vim.api.nvim_get_current_buf() + local method = 'textDocument/codeAction' + vim.lsp.buf_request_all(bufnr, method, params, function(results) + local actions = {} + for _, r in pairs(results) do + vim.list_extend(actions, r.result or {}) + end + vim.lsp.handlers[method](nil, method, actions, nil, bufnr) + end) +end + --- Selects a code action from the input list that is available at the current --- cursor position. -- @@ -432,7 +447,7 @@ function M.code_action(context) context = context or { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() } local params = util.make_range_params() params.context = context - request('textDocument/codeAction', params) + code_action_request(params) end --- Performs |vim.lsp.buf.code_action()| for a given range. @@ -447,7 +462,7 @@ function M.range_code_action(context, start_pos, end_pos) context = context or { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() } local params = util.make_given_range_params(start_pos, end_pos) params.context = context - request('textDocument/codeAction', params) + code_action_request(params) end --- Executes an LSP server command. diff --git a/runtime/lua/vim/lsp/codelens.lua b/runtime/lua/vim/lsp/codelens.lua index fbd37e3830..fe581e42ad 100644 --- a/runtime/lua/vim/lsp/codelens.lua +++ b/runtime/lua/vim/lsp/codelens.lua @@ -111,15 +111,19 @@ function M.display(lenses, bufnr, client_id) local ns = namespaces[client_id] local num_lines = api.nvim_buf_line_count(bufnr) for i = 0, num_lines do - local line_lenses = lenses_by_lnum[i] + local line_lenses = lenses_by_lnum[i] or {} api.nvim_buf_clear_namespace(bufnr, ns, i, i + 1) local chunks = {} - for _, lens in pairs(line_lenses or {}) do + local num_line_lenses = #line_lenses + for j, lens in ipairs(line_lenses) do local text = lens.command and lens.command.title or 'Unresolved lens ...' table.insert(chunks, {text, 'LspCodeLens' }) + if j < num_line_lenses then + table.insert(chunks, {' | ', 'LspCodeLensSeparator' }) + end end if #chunks > 0 then - api.nvim_buf_set_virtual_text(bufnr, ns, i, chunks, {}) + api.nvim_buf_set_extmark(bufnr, ns, i, 0, { virt_text = chunks }) end end end @@ -175,12 +179,12 @@ local function resolve_lenses(lenses, bufnr, client_id, callback) -- Eager display to have some sort of incremental feedback -- Once all lenses got resolved there will be a full redraw for all lenses -- So that multiple lens per line are properly displayed - api.nvim_buf_set_virtual_text( + api.nvim_buf_set_extmark( bufnr, ns, lens.range.start.line, - {{ lens.command.title, 'LspCodeLens' },}, - {} + 0, + { virt_text = {{ lens.command.title, 'LspCodeLens' }} } ) end countdown() diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 64dde78f17..5efd8d74a7 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -203,8 +203,13 @@ local bufnr_and_client_cacher_mt = { -- Diagnostic Saving & Caching {{{ local _diagnostic_cleanup = setmetatable({}, bufnr_and_client_cacher_mt) local diagnostic_cache = setmetatable({}, bufnr_and_client_cacher_mt) +local diagnostic_cache_extmarks = setmetatable({}, bufnr_and_client_cacher_mt) local diagnostic_cache_lines = setmetatable({}, bufnr_and_client_cacher_mt) local diagnostic_cache_counts = setmetatable({}, bufnr_and_client_cacher_mt) +local diagnostic_attached_buffers = {} + +-- Disabled buffers and clients +local diagnostic_disabled = setmetatable({}, bufnr_and_client_cacher_mt) local _bufs_waiting_to_update = setmetatable({}, bufnr_and_client_cacher_mt) @@ -761,17 +766,20 @@ function M.set_virtual_text(diagnostics, bufnr, client_id, diagnostic_ns, opts) local virt_texts = M.get_virtual_text_chunks_for_line(bufnr, line, line_diagnostics, opts) if virt_texts then - api.nvim_buf_set_virtual_text(bufnr, diagnostic_ns, line, virt_texts, {}) + api.nvim_buf_set_extmark(bufnr, diagnostic_ns, line, 0, { + virt_text = virt_texts, + }) end end end ---- Default function to get text chunks to display using `nvim_buf_set_virtual_text`. +--- Default function to get text chunks to display using |nvim_buf_set_extmark()|. ---@param bufnr number The buffer to display the virtual text in ---@param line number The line number to display the virtual text on ---@param line_diags Diagnostic[] The diagnostics associated with the line ---@param opts table See {opts} from |vim.lsp.diagnostic.set_virtual_text()| ----@return table chunks, as defined by |nvim_buf_set_virtual_text()| +---@return an array of [text, hl_group] arrays. This can be passed directly to +--- the {virt_text} option of |nvim_buf_set_extmark()|. function M.get_virtual_text_chunks_for_line(bufnr, line, line_diags, opts) assert(bufnr or line) @@ -814,10 +822,7 @@ end ---@param diagnostic_ns number|nil Associated diagnostic namespace ---@param sign_ns number|nil Associated sign namespace function M.clear(bufnr, client_id, diagnostic_ns, sign_ns) - validate { bufnr = { bufnr, 'n' } } - - bufnr = (bufnr == 0 and api.nvim_get_current_buf()) or bufnr - + bufnr = get_bufnr(bufnr) if client_id == nil then return vim.lsp.for_each_buffer_client(bufnr, function(_, iter_client_id, _) return M.clear(bufnr, iter_client_id) @@ -826,6 +831,7 @@ function M.clear(bufnr, client_id, diagnostic_ns, sign_ns) diagnostic_ns = diagnostic_ns or M._get_diagnostic_namespace(client_id) sign_ns = sign_ns or M._get_sign_namespace(client_id) + diagnostic_cache_extmarks[bufnr][client_id] = {} assert(bufnr, "bufnr is required") assert(diagnostic_ns, "Need diagnostic_ns, got nil") @@ -1038,9 +1044,61 @@ function M.on_publish_diagnostics(_, _, params, client_id, _, config) M.display(diagnostics, bufnr, client_id, config) end +-- restores the extmarks set by M.display +--- @param last number last line that was changed +-- @private +local function restore_extmarks(bufnr, last) + for client_id, extmarks in pairs(diagnostic_cache_extmarks[bufnr]) do + local ns = M._get_diagnostic_namespace(client_id) + local extmarks_current = api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {details = true}) + local found = {} + for _, extmark in ipairs(extmarks_current) do + -- nvim_buf_set_lines will move any extmark to the line after the last + -- nvim_buf_set_text will move any extmark to the last line + if extmark[2] ~= last + 1 then + found[extmark[1]] = true + end + end + for _, extmark in ipairs(extmarks) do + if not found[extmark[1]] then + local opts = extmark[4] + opts.id = extmark[1] + -- HACK: end_row should be end_line + if opts.end_row then + opts.end_line = opts.end_row + opts.end_row = nil + end + pcall(api.nvim_buf_set_extmark, bufnr, ns, extmark[2], extmark[3], opts) + end + end + end +end + +-- caches the extmarks set by M.display +-- @private +local function save_extmarks(bufnr, client_id) + bufnr = bufnr == 0 and api.nvim_get_current_buf() or bufnr + if not diagnostic_attached_buffers[bufnr] then + api.nvim_buf_attach(bufnr, false, { + on_lines = function(_, _, _, _, _, last) + restore_extmarks(bufnr, last - 1) + end, + on_detach = function() + diagnostic_cache_extmarks[bufnr] = nil + end}) + diagnostic_attached_buffers[bufnr] = true + end + local ns = M._get_diagnostic_namespace(client_id) + diagnostic_cache_extmarks[bufnr][client_id] = api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {details = true}) +end + --@private --- Display diagnostics for the buffer, given a configuration. function M.display(diagnostics, bufnr, client_id, config) + if diagnostic_disabled[bufnr][client_id] then + return + end + config = vim.lsp._with_extend('vim.lsp.diagnostic.on_publish_diagnostics', { signs = true, underline = true, @@ -1108,7 +1166,45 @@ function M.display(diagnostics, bufnr, client_id, config) if signs_opts then M.set_signs(diagnostics, bufnr, client_id, nil, signs_opts) end + + -- cache extmarks + save_extmarks(bufnr, client_id) +end + +--- Redraw diagnostics for the given buffer and client +--- +--- This calls the "textDocument/publishDiagnostics" handler manually using +--- the cached diagnostics already received from the server. This can be useful +--- for redrawing diagnostics after making changes in diagnostics +--- configuration. |lsp-handler-configuration| +--- +--- @param bufnr (optional, number): Buffer handle, defaults to current +--- @param client_id (optional, number): Redraw diagnostics for the given +--- client. The default is to redraw diagnostics for all attached +--- clients. +function M.redraw(bufnr, client_id) + bufnr = get_bufnr(bufnr) + if not client_id then + return vim.lsp.for_each_buffer_client(bufnr, function(client) + M.redraw(bufnr, client.id) + end) + end + + -- We need to invoke the publishDiagnostics handler directly instead of just + -- calling M.display so that we can preserve any custom configuration options + -- the user may have set with vim.lsp.with. + vim.lsp.handlers["textDocument/publishDiagnostics"]( + nil, + "textDocument/publishDiagnostics", + { + uri = vim.uri_from_bufnr(bufnr), + diagnostics = M.get(bufnr, client_id), + }, + client_id, + bufnr + ) end + -- }}} -- Diagnostic User Functions {{{ @@ -1156,7 +1252,7 @@ function M.show_line_diagnostics(opts, bufnr, line_nr, client_id) table.insert(lines, prefix..message_lines[1]) table.insert(highlights, {#prefix, hiname}) for j = 2, #message_lines do - table.insert(lines, message_lines[j]) + table.insert(lines, string.rep(' ', #prefix) .. message_lines[j]) table.insert(highlights, {0, hiname}) end end @@ -1190,10 +1286,10 @@ function M.reset(client_id, buffer_client_map) end) end ---- Sets the location list +--- Gets diagnostics, converts them to quickfix/location list items, and applies the item_handler callback to the items. +---@param item_handler function Callback to apply to the diagnostic items +---@param command string|nil Command to execute after applying the item_handler ---@param opts table|nil Configuration table. Keys: ---- - {open_loclist}: (boolean, default true) ---- - Open loclist after set --- - {client_id}: (number) --- - If nil, will consider all clients attached to buffer. --- - {severity}: (DiagnosticSeverity) @@ -1202,9 +1298,8 @@ end --- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid. --- - {workspace}: (boolean, default false) --- - Set the list with workspace diagnostics -function M.set_loclist(opts) +local function apply_to_diagnostic_items(item_handler, command, opts) opts = opts or {} - local open_loclist = if_nil(opts.open_loclist, true) local current_bufnr = api.nvim_get_current_buf() local diags = opts.workspace and M.get_all(opts.client_id) or { [current_bufnr] = M.get(current_bufnr, opts.client_id) @@ -1221,11 +1316,89 @@ function M.set_loclist(opts) return true end local items = util.diagnostics_to_items(diags, predicate) - local win_id = vim.api.nvim_get_current_win() - util.set_loclist(items, win_id) - if open_loclist then - vim.cmd [[lopen]] + item_handler(items) + if command then + vim.cmd(command) + end +end + +--- Sets the quickfix list +---@param opts table|nil Configuration table. Keys: +--- - {open}: (boolean, default true) +--- - Open quickfix list after set +--- - {client_id}: (number) +--- - If nil, will consider all clients attached to buffer. +--- - {severity}: (DiagnosticSeverity) +--- - Exclusive severity to consider. Overrides {severity_limit} +--- - {severity_limit}: (DiagnosticSeverity) +--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid. +--- - {workspace}: (boolean, default true) +--- - Set the list with workspace diagnostics +function M.set_qflist(opts) + opts = opts or {} + opts.workspace = if_nil(opts.workspace, true) + local open_qflist = if_nil(opts.open, true) + local command = open_qflist and [[copen]] or nil + apply_to_diagnostic_items(util.set_qflist, command, opts) +end + +--- Sets the location list +---@param opts table|nil Configuration table. Keys: +--- - {open}: (boolean, default true) +--- - Open loclist after set +--- - {client_id}: (number) +--- - If nil, will consider all clients attached to buffer. +--- - {severity}: (DiagnosticSeverity) +--- - Exclusive severity to consider. Overrides {severity_limit} +--- - {severity_limit}: (DiagnosticSeverity) +--- - Limit severity of diagnostics found. E.g. "Warning" means { "Error", "Warning" } will be valid. +--- - {workspace}: (boolean, default false) +--- - Set the list with workspace diagnostics +function M.set_loclist(opts) + opts = opts or {} + local open_loclist = if_nil(opts.open, true) + local command = open_loclist and [[lopen]] or nil + apply_to_diagnostic_items(util.set_loclist, command, opts) +end + +--- Disable diagnostics for the given buffer and client +--- @param bufnr (optional, number): Buffer handle, defaults to current +--- @param client_id (optional, number): Disable diagnostics for the given +--- client. The default is to disable diagnostics for all attached +--- clients. +-- Note that when diagnostics are disabled for a buffer, the server will still +-- send diagnostic information and the client will still process it. The +-- diagnostics are simply not displayed to the user. +function M.disable(bufnr, client_id) + if not client_id then + return vim.lsp.for_each_buffer_client(bufnr, function(client) + M.disable(bufnr, client.id) + end) + end + + diagnostic_disabled[bufnr][client_id] = true + M.clear(bufnr, client_id) +end + +--- Enable diagnostics for the given buffer and client +--- @param bufnr (optional, number): Buffer handle, defaults to current +--- @param client_id (optional, number): Enable diagnostics for the given +--- client. The default is to enable diagnostics for all attached +--- clients. +function M.enable(bufnr, client_id) + if not client_id then + return vim.lsp.for_each_buffer_client(bufnr, function(client) + M.enable(bufnr, client.id) + end) end + + if not diagnostic_disabled[bufnr][client_id] then + return + end + + diagnostic_disabled[bufnr][client_id] = nil + + M.redraw(bufnr, client_id) end -- }}} diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 41852b9d88..b7f1ea0ab6 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -17,15 +17,12 @@ local function err_message(...) api.nvim_command("redraw") end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand -M['workspace/executeCommand'] = function(err, _) - if err then - error("Could not execute code action: "..err.message) - end +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand +M['workspace/executeCommand'] = function() + -- Error handling is done implicitly by wrapping all handlers; see end of this file end --- @msg of type ProgressParams --- Basically a token of type number/string +--@private local function progress_handler(_, _, params, client_id) local client = vim.lsp.get_client_by_id(client_id) local client_name = client and client.name or string.format("id=%d", client_id) @@ -61,10 +58,10 @@ local function progress_handler(_, _, params, client_id) vim.api.nvim_command("doautocmd <nomodeline> User LspProgressUpdate") end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress M['$/progress'] = progress_handler ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_workDoneProgress_create +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_workDoneProgress_create M['window/workDoneProgress/create'] = function(_, _, params, client_id) local client = vim.lsp.get_client_by_id(client_id) local token = params.token -- string or number @@ -76,7 +73,7 @@ M['window/workDoneProgress/create'] = function(_, _, params, client_id) return vim.NIL end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessageRequest +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessageRequest M['window/showMessageRequest'] = function(_, _, params) local actions = params.actions @@ -97,7 +94,7 @@ M['window/showMessageRequest'] = function(_, _, params) end end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#client_registerCapability +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#client_registerCapability M['client/registerCapability'] = function(_, _, _, client_id) local warning_tpl = "The language server %s triggers a registerCapability ".. "handler despite dynamicRegistration set to false. ".. @@ -109,7 +106,7 @@ M['client/registerCapability'] = function(_, _, _, client_id) return vim.NIL end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction M['textDocument/codeAction'] = function(_, _, actions) if actions == nil or vim.tbl_isempty(actions) then print("No code actions available") @@ -143,7 +140,7 @@ M['textDocument/codeAction'] = function(_, _, actions) end end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_applyEdit M['workspace/applyEdit'] = function(_, _, workspace_edit) if not workspace_edit then return end -- TODO(ashkan) Do something more with label? @@ -157,14 +154,13 @@ M['workspace/applyEdit'] = function(_, _, workspace_edit) } end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_configuration -M['workspace/configuration'] = function(err, _, params, client_id) +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_configuration +M['workspace/configuration'] = function(_, _, params, client_id) local client = vim.lsp.get_client_by_id(client_id) if not client then err_message("LSP[id=", client_id, "] client has shut down after sending the message") return end - if err then error(vim.inspect(err)) end if not params.items then return {} end @@ -191,50 +187,64 @@ M['textDocument/codeLens'] = function(...) return require('vim.lsp.codelens').on_codelens(...) end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references -M['textDocument/references'] = function(_, _, result) - if not result then return end - util.set_qflist(util.locations_to_items(result)) - api.nvim_command("copen") -end ---@private ---- Prints given list of symbols to the quickfix list. ---@param _ (not used) ---@param _ (not used) ---@param result (list of Symbols) LSP method name ---@param result (table) result of LSP method; a location or a list of locations. ----(`textDocument/definition` can return `Location` or `Location[]` -local symbol_handler = function(_, _, result, _, bufnr) - if not result or vim.tbl_isempty(result) then return end - util.set_qflist(util.symbols_to_items(result, bufnr)) - api.nvim_command("copen") +--@private +--- Return a function that converts LSP responses to list items and opens the list +--- +--- The returned function has an optional {config} parameter that accepts a table +--- with the following keys: +--- +--- loclist: (boolean) use the location list (default is to use the quickfix list) +--- +--- @param map_result function `((resp, bufnr) -> list)` to convert the response +--- @param entity name of the resource used in a `not found` error message +local function response_to_list(map_result, entity) + return function(_, _, result, _, bufnr, config) + if not result or vim.tbl_isempty(result) then + vim.notify('No ' .. entity .. ' found') + else + config = config or {} + if config.loclist then + util.set_loclist(map_result(result, bufnr)) + api.nvim_command("lopen") + else + util.set_qflist(map_result(result, bufnr)) + api.nvim_command("copen") + end + end + end end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol -M['textDocument/documentSymbol'] = symbol_handler ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol -M['workspace/symbol'] = symbol_handler ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename + +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references +M['textDocument/references'] = response_to_list(util.locations_to_items, 'references') + +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol +M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols') + +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol +M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols') + +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename M['textDocument/rename'] = function(_, _, result) if not result then return end util.apply_workspace_edit(result) end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting -M['textDocument/rangeFormatting'] = function(_, _, result) +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rangeFormatting +M['textDocument/rangeFormatting'] = function(_, _, result, _, bufnr) if not result then return end - util.apply_text_edits(result) + util.apply_text_edits(result, bufnr) end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting -M['textDocument/formatting'] = function(_, _, result) +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting +M['textDocument/formatting'] = function(_, _, result, _, bufnr) if not result then return end - util.apply_text_edits(result) + util.apply_text_edits(result, bufnr) end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion M['textDocument/completion'] = function(_, _, result) if vim.tbl_isempty(result or {}) then return end local row, col = unpack(api.nvim_win_get_cursor(0)) @@ -276,7 +286,7 @@ function M.hover(_, method, result, _, _, config) return util.open_floating_preview(markdown_lines, "markdown", config) end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_hover M['textDocument/hover'] = M.hover --@private @@ -306,16 +316,17 @@ local function location_handler(_, method, result) end end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_declaration M['textDocument/declaration'] = location_handler ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_definition M['textDocument/definition'] = location_handler ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_typeDefinition M['textDocument/typeDefinition'] = location_handler ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_implementation M['textDocument/implementation'] = location_handler ---- |lsp-handler| for the method "textDocument/signatureHelp" +--- |lsp-handler| for the method "textDocument/signatureHelp". +--- The active parameter is highlighted with |hl-LspSignatureActiveParameter|. --- <pre> --- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with( --- vim.lsp.handlers.signature_help, { @@ -328,29 +339,39 @@ M['textDocument/implementation'] = location_handler --- - border: (default=nil) --- - Add borders to the floating window --- - See |vim.api.nvim_open_win()| -function M.signature_help(_, method, result, _, bufnr, config) +function M.signature_help(_, method, result, client_id, bufnr, config) config = config or {} config.focus_id = method -- When use `autocmd CompleteDone <silent><buffer> lua vim.lsp.buf.signature_help()` to call signatureHelp handler -- If the completion item doesn't have signatures It will make noise. Change to use `print` that can use `<silent>` to ignore if not (result and result.signatures and result.signatures[1]) then - print('No signature help available') + if config.silent ~= true then + print('No signature help available') + end return end + local client = vim.lsp.get_client_by_id(client_id) + local triggers = client.resolved_capabilities.signature_help_trigger_characters local ft = api.nvim_buf_get_option(bufnr, 'filetype') - local lines = util.convert_signature_help_to_markdown_lines(result, ft) + local lines, hl = util.convert_signature_help_to_markdown_lines(result, ft, triggers) lines = util.trim_empty_lines(lines) if vim.tbl_isempty(lines) then - print('No signature help available') + if config.silent ~= true then + print('No signature help available') + end return end - return util.open_floating_preview(lines, "markdown", config) + local fbuf, fwin = util.open_floating_preview(lines, "markdown", config) + if hl then + api.nvim_buf_add_highlight(fbuf, -1, "LspSignatureActiveParameter", 0, unpack(hl)) + end + return fbuf, fwin end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp M['textDocument/signatureHelp'] = M.signature_help ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentHighlight M['textDocument/documentHighlight'] = function(_, _, result, _, bufnr, _) if not result then return end util.buf_highlight_references(bufnr, result) @@ -383,13 +404,13 @@ local make_call_hierarchy_handler = function(direction) end end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy/incomingCalls +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy_incomingCalls M['callHierarchy/incomingCalls'] = make_call_hierarchy_handler('from') ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy/outgoingCalls +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#callHierarchy_outgoingCalls M['callHierarchy/outgoingCalls'] = make_call_hierarchy_handler('to') ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window/logMessage +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_logMessage M['window/logMessage'] = function(_, _, result, client_id) local message_type = result.type local message = result.message @@ -410,7 +431,7 @@ M['window/logMessage'] = function(_, _, result, client_id) return result end ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window/showMessage +--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessage M['window/showMessage'] = function(_, _, result, client_id) local message_type = result.type local message = result.message @@ -436,7 +457,14 @@ for k, fn in pairs(M) do }) if err then - return err_message(tostring(err)) + local client = vim.lsp.get_client_by_id(client_id) + local client_name = client and client.name or string.format("client_id=%d", client_id) + -- LSP spec: + -- interface ResponseError: + -- code: integer; + -- message: string; + -- data?: string | number | boolean | array | object | null; + return err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) end return fn(err, method, params, client_id, bufnr, config) diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua index 471a311c16..73fafb9715 100644 --- a/runtime/lua/vim/lsp/log.lua +++ b/runtime/lua/vim/lsp/log.lua @@ -17,7 +17,7 @@ local current_log_level = log.levels.WARN local log_date_format = "%FT%H:%M:%S%z" do - local path_sep = vim.loop.os_uname().sysname == "Windows" and "\\" or "/" + local path_sep = vim.loop.os_uname().version:match("Windows") and "\\" or "/" --@private local function path_join(...) return table.concat(vim.tbl_flatten{...}, path_sep) diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index 7e43eb84de..6d02b9ba74 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -691,10 +691,11 @@ function protocol.make_client_capabilities() signatureHelp = { dynamicRegistration = false; signatureInformation = { + activeParameterSupport = true; documentationFormat = { protocol.MarkupKind.Markdown; protocol.MarkupKind.PlainText }; - -- parameterInformation = { - -- labelOffsetSupport = false; - -- }; + parameterInformation = { + labelOffsetSupport = true; + }; }; }; references = { diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 195e3a0e65..d682fdc17e 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -240,6 +240,7 @@ end --- Applies a list of text edits to a buffer. --@param text_edits (table) list of `TextEdit` objects --@param buf_nr (number) Buffer id +---@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textEdit function M.apply_text_edits(text_edits, bufnr) if not next(text_edits) then return end if not api.nvim_buf_is_loaded(bufnr) then @@ -810,16 +811,16 @@ function M.convert_input_to_markdown_lines(input, contents) -- If it's plaintext, then wrap it in a <text></text> block -- Some servers send input.value as empty, so let's ignore this :( - input.value = input.value or '' + local value = input.value or '' if input.kind == "plaintext" then -- wrap this in a <text></text> block so that stylize_markdown -- can properly process it as plaintext - input.value = string.format("<text>\n%s\n</text>", input.value or "") + value = string.format("<text>\n%s\n</text>", value) end - -- assert(type(input.value) == 'string') - list_extend(contents, split_lines(input.value)) + -- assert(type(value) == 'string') + list_extend(contents, split_lines(value)) -- MarkupString variation 2 elseif input.language then -- Some servers send input.value as empty, so let's ignore this :( @@ -845,9 +846,10 @@ end --- --@param signature_help Response of `textDocument/SignatureHelp` --@param ft optional filetype that will be use as the `lang` for the label markdown code block +--@param triggers optional list of trigger characters from the lsp server. used to better determine parameter offsets --@returns list of lines of converted markdown. --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp -function M.convert_signature_help_to_markdown_lines(signature_help, ft) +function M.convert_signature_help_to_markdown_lines(signature_help, ft, triggers) if not signature_help.signatures then return end @@ -856,6 +858,7 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft) --=== 0`. Whenever possible implementors should make an active decision about --the active signature and shouldn't rely on a default value. local contents = {} + local active_hl local active_signature = signature_help.activeSignature or 0 -- If the activeSignature is not inside the valid range, then clip it. if active_signature >= #signature_help.signatures then @@ -875,11 +878,17 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft) M.convert_input_to_markdown_lines(signature.documentation, contents) end if signature.parameters and #signature.parameters > 0 then - local active_parameter = signature_help.activeParameter or 0 - -- If the activeParameter is not inside the valid range, then clip it. + local active_parameter = (signature.activeParameter or signature_help.activeParameter or 0) + if active_parameter < 0 + then active_parameter = 0 + end + + -- If the activeParameter is > #parameters, then set it to the last + -- NOTE: this is not fully according to the spec, but a client-side interpretation if active_parameter >= #signature.parameters then - active_parameter = 0 + active_parameter = #signature.parameters - 1 end + local parameter = signature.parameters[active_parameter + 1] if parameter then --[=[ @@ -900,13 +909,35 @@ function M.convert_signature_help_to_markdown_lines(signature_help, ft) documentation?: string | MarkupContent; } --]=] - -- TODO highlight parameter + if parameter.label then + if type(parameter.label) == "table" then + active_hl = parameter.label + else + local offset = 1 + -- try to set the initial offset to the first found trigger character + for _, t in ipairs(triggers or {}) do + local trigger_offset = signature.label:find(t, 1, true) + if trigger_offset and (offset == 1 or trigger_offset < offset) then + offset = trigger_offset + end + end + for p, param in pairs(signature.parameters) do + offset = signature.label:find(param.label, offset, true) + if not offset then break end + if p == active_parameter + 1 then + active_hl = {offset - 1, offset + #parameter.label - 1} + break + end + offset = offset + #param.label + 1 + end + end + end if parameter.documentation then M.convert_input_to_markdown_lines(parameter.documentation, contents) end end end - return contents + return contents, active_hl end --- Creates a table with sensible default options for a floating window. The @@ -942,7 +973,7 @@ function M.make_floating_popup_options(width, height, opts) row = -get_border_size(opts).height end - if vim.fn.wincol() + width <= api.nvim_get_option('columns') then + if vim.fn.wincol() + width + (opts.offset_x or 0) <= api.nvim_get_option('columns') then anchor = anchor..'W' col = 0 else @@ -960,6 +991,7 @@ function M.make_floating_popup_options(width, height, opts) style = 'minimal', width = width, border = opts.border or default_border, + zindex = opts.zindex or 50, } end @@ -1129,6 +1161,8 @@ function M.stylize_markdown(bufnr, contents, opts) -- Clean up contents = M._trim(contents, opts) + -- Insert blank line separator after code block? + local add_sep = opts.separator == nil and true or opts.separator local stripped = {} local highlights = {} -- keep track of lnums that contain markdown @@ -1155,9 +1189,24 @@ function M.stylize_markdown(bufnr, contents, opts) start = start + 1; finish = #stripped; }) + -- add a separator, but not on the last line + if add_sep and i < #contents then + table.insert(stripped, "---") + markdown_lines[#stripped] = true + end else - table.insert(stripped, line) - markdown_lines[#stripped] = true + -- strip any emty lines or separators prior to this separator in actual markdown + if line:match("^---+$") then + while markdown_lines[#stripped] and (stripped[#stripped]:match("^%s*$") or stripped[#stripped]:match("^---+$")) do + markdown_lines[#stripped] = false + table.remove(stripped, #stripped) + end + end + -- add the line if its not an empty line following a separator + if not (line:match("^%s*$") and markdown_lines[#stripped] and stripped[#stripped]:match("^---+$")) then + table.insert(stripped, line) + markdown_lines[#stripped] = true + end i = i + 1 end end @@ -1165,7 +1214,7 @@ function M.stylize_markdown(bufnr, contents, opts) -- Compute size of float needed to show (wrapped) lines opts.wrap_at = opts.wrap_at or (vim.wo["wrap"] and api.nvim_win_get_width(0)) - local width, height = M._make_floating_popup_size(stripped, opts) + local width = M._make_floating_popup_size(stripped, opts) local sep_line = string.rep("─", math.min(width, opts.wrap_at or width)) @@ -1175,26 +1224,6 @@ function M.stylize_markdown(bufnr, contents, opts) end end - -- Insert blank line separator after code block - local insert_separator = opts.separator - if insert_separator == nil then insert_separator = true end - if insert_separator then - local offset = 0 - for _, h in ipairs(highlights) do - h.start = h.start + offset - h.finish = h.finish + offset - -- check if a seperator already exists and use that one instead of creating a new one - if h.finish + 1 <= #stripped then - if stripped[h.finish + 1] ~= sep_line then - table.insert(stripped, h.finish + 1, sep_line) - offset = offset + 1 - height = height + 1 - end - end - end - end - - vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, stripped) local idx = 1 @@ -1455,6 +1484,7 @@ do --[[ References ]] --- --@param bufnr buffer id --@param references List of `DocumentHighlight` objects to highlight + ---@see https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#documentHighlight function M.buf_highlight_references(bufnr, references) validate { bufnr = {bufnr, 'n', true} } for _, reference in ipairs(references) do @@ -1689,14 +1719,14 @@ end function M.trim_empty_lines(lines) local start = 1 for i = 1, #lines do - if #lines[i] > 0 then + if lines[i] ~= nil and #lines[i] > 0 then start = i break end end local finish = 1 for i = #lines, 1, -1 do - if #lines[i] > 0 then + if lines[i] ~= nil and #lines[i] > 0 then finish = i break end @@ -1838,10 +1868,10 @@ function M.get_effective_tabstop(bufnr) return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop end ---- Creates a `FormattingOptions` object for the current buffer and cursor position. +--- Creates a `DocumentFormattingParams` object for the current buffer and cursor position. --- --@param options Table with valid `FormattingOptions` entries ---@returns `FormattingOptions object +--@returns `DocumentFormattingParams` object --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_formatting function M.make_formatting_params(options) validate { options = {options, 't', true} } diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 0a663628a5..33c2b2c46c 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -200,6 +200,12 @@ function vim.tbl_isempty(t) return next(t) == nil end +--- we only merge empty tables or tables that are not a list +--@private +local function can_merge(v) + return type(v) == "table" and (vim.tbl_isempty(v) or not vim.tbl_islist(v)) +end + local function tbl_extend(behavior, deep_extend, ...) if (behavior ~= 'error' and behavior ~= 'keep' and behavior ~= 'force') then error('invalid "behavior": '..tostring(behavior)) @@ -219,8 +225,8 @@ local function tbl_extend(behavior, deep_extend, ...) vim.validate{["after the second argument"] = {tbl,'t'}} if tbl then for k, v in pairs(tbl) do - if type(v) == 'table' and deep_extend and not vim.tbl_islist(v) then - ret[k] = tbl_extend(behavior, true, ret[k] or vim.empty_dict(), v) + if deep_extend and can_merge(v) and can_merge(ret[k]) then + ret[k] = tbl_extend(behavior, true, ret[k], v) elseif behavior ~= 'force' and ret[k] ~= nil then if behavior == 'error' then error('key found in more than one map: '..k) diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 84b6a5f135..e003cf577a 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -22,8 +22,6 @@ local _link_default_highlight_once = function(from, to) return from end --- These are conventions defined by nvim-treesitter, though it --- needs to be user extensible also. TSHighlighter.hl_map = { ["error"] = "Error", @@ -116,7 +114,7 @@ function TSHighlighterQuery:_get_hl_from_capture(capture) -- From "Normal.left" only keep "Normal" return vim.split(name, '.', true)[1], true else - return TSHighlighter.hl_map[name] or name, false + return TSHighlighter.hl_map[name] or 0, false end end @@ -248,7 +246,7 @@ local function on_line_impl(self, buf, line) end while line >= state.next_row do - local capture, node = state.iter() + local capture, node, metadata = state.iter() if capture == nil then break end @@ -260,7 +258,7 @@ local function on_line_impl(self, buf, line) { end_line = end_row, end_col = end_col, hl_group = hl, ephemeral = true, - priority = 100 -- Low but leaves room below + priority = tonumber(metadata.priority) or 100 -- Low but leaves room below }) end if start_row > line then diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index b81eb18945..4ecd91d295 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -351,7 +351,12 @@ function M.add_directive(name, handler, force) directive_handlers[name] = handler end ---- Returns the list of currently supported predicates +--- @return The list of supported directives. +function M.list_directives() + return vim.tbl_keys(directive_handlers) +end + +--- @return The list of supported predicates. function M.list_predicates() return vim.tbl_keys(predicate_handlers) end diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index f1a12c72ec..82c9a31464 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -52,7 +52,7 @@ end --@private local function is_windows_file_uri(uri) - return uri:match('^file:///[a-zA-Z]:') ~= nil + return uri:match('^file:/+[a-zA-Z]:') ~= nil end --- Get a URI from a file path. @@ -74,7 +74,7 @@ local function uri_from_fname(path) return table.concat(uri_parts) end -local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*)://.*' +local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*' --- Get a URI from a bufnr --@param bufnr (number): Buffer number @@ -100,10 +100,10 @@ local function uri_to_fname(uri) uri = uri_decode(uri) -- TODO improve this. if is_windows_file_uri(uri) then - uri = uri:gsub('^file:///', '') + uri = uri:gsub('^file:/+', '') uri = uri:gsub('/', '\\') else - uri = uri:gsub('^file://', '') + uri = uri:gsub('^file:/+', '/') end return uri end diff --git a/runtime/nvim.appdata.xml b/runtime/nvim.appdata.xml index e99c76a930..099c9a57c0 100644 --- a/runtime/nvim.appdata.xml +++ b/runtime/nvim.appdata.xml @@ -26,6 +26,7 @@ </screenshots> <releases> + <release date="2021-07-02" version="0.5.0"/> <release date="2020-08-04" version="0.4.4"/> <release date="2019-11-06" version="0.4.3"/> <release date="2019-09-15" version="0.4.2"/> diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 633cb9e509..d4c10f7afa 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -440,6 +440,9 @@ if has("syntax") call append("$", "cursorline\thighlight the screen line of the cursor") call append("$", "\t(local to window)") call <SID>BinOptionL("cul") + call append("$", "cursorlineopt\tspecifies which area 'cursorline' highlights") + call append("$", "\t(local to window)") + call <SID>OptionL("culopt") call append("$", "colorcolumn\tcolumns to highlight") call append("$", "\t(local to window)") call <SID>OptionL("cc") diff --git a/runtime/syntax/syncolor.vim b/runtime/syntax/syncolor.vim deleted file mode 100644 index 5b907a3b83..0000000000 --- a/runtime/syntax/syncolor.vim +++ /dev/null @@ -1,87 +0,0 @@ -" Vim syntax support file -" Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2020 Feb 13 - -" This file sets up the default methods for highlighting. -" It is loaded from "synload.vim" and from Vim for ":syntax reset". -" Also used from init_highlight(). - -if !exists("syntax_cmd") || syntax_cmd == "on" - " ":syntax on" works like in Vim 5.7: set colors but keep links - command -nargs=* SynColor hi <args> - command -nargs=* SynLink hi link <args> -else - if syntax_cmd == "enable" - " ":syntax enable" keeps any existing colors - command -nargs=* SynColor hi def <args> - command -nargs=* SynLink hi def link <args> - elseif syntax_cmd == "reset" - " ":syntax reset" resets all colors to the default - command -nargs=* SynColor hi <args> - command -nargs=* SynLink hi! link <args> - else - " User defined syncolor file has already set the colors. - finish - endif -endif - -" Many terminals can only use six different colors (plus black and white). -" Therefore the number of colors used is kept low. It doesn't look nice with -" too many colors anyway. -" Careful with "cterm=bold", it changes the color to bright for some terminals. -" There are two sets of defaults: for a dark and a light background. -if &background == "dark" - SynColor Comment term=bold cterm=NONE ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#80a0ff guibg=NONE - SynColor Constant term=underline cterm=NONE ctermfg=Magenta ctermbg=NONE gui=NONE guifg=#ffa0a0 guibg=NONE - SynColor Special term=bold cterm=NONE ctermfg=LightRed ctermbg=NONE gui=NONE guifg=Orange guibg=NONE - SynColor Identifier term=underline cterm=bold ctermfg=Cyan ctermbg=NONE gui=NONE guifg=#40ffff guibg=NONE - SynColor Statement term=bold cterm=NONE ctermfg=Yellow ctermbg=NONE gui=bold guifg=#ffff60 guibg=NONE - SynColor PreProc term=underline cterm=NONE ctermfg=LightBlue ctermbg=NONE gui=NONE guifg=#ff80ff guibg=NONE - SynColor Type term=underline cterm=NONE ctermfg=LightGreen ctermbg=NONE gui=bold guifg=#60ff60 guibg=NONE - SynColor Underlined term=underline cterm=underline ctermfg=LightBlue gui=underline guifg=#80a0ff - SynColor Ignore term=NONE cterm=NONE ctermfg=black ctermbg=NONE gui=NONE guifg=bg guibg=NONE -else - SynColor Comment term=bold cterm=NONE ctermfg=DarkBlue ctermbg=NONE gui=NONE guifg=Blue guibg=NONE - SynColor Constant term=underline cterm=NONE ctermfg=DarkRed ctermbg=NONE gui=NONE guifg=Magenta guibg=NONE - " #6a5acd is SlateBlue - SynColor Special term=bold cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a5acd guibg=NONE - SynColor Identifier term=underline cterm=NONE ctermfg=DarkCyan ctermbg=NONE gui=NONE guifg=DarkCyan guibg=NONE - SynColor Statement term=bold cterm=NONE ctermfg=Brown ctermbg=NONE gui=bold guifg=Brown guibg=NONE - " #6a0dad is Purple - SynColor PreProc term=underline cterm=NONE ctermfg=DarkMagenta ctermbg=NONE gui=NONE guifg=#6a0dad guibg=NONE - SynColor Type term=underline cterm=NONE ctermfg=DarkGreen ctermbg=NONE gui=bold guifg=SeaGreen guibg=NONE - SynColor Underlined term=underline cterm=underline ctermfg=DarkMagenta gui=underline guifg=SlateBlue - SynColor Ignore term=NONE cterm=NONE ctermfg=white ctermbg=NONE gui=NONE guifg=bg guibg=NONE -endif -SynColor Error term=reverse cterm=NONE ctermfg=White ctermbg=Red gui=NONE guifg=White guibg=Red -SynColor Todo term=standout cterm=NONE ctermfg=Black ctermbg=Yellow gui=NONE guifg=Blue guibg=Yellow - -" Common groups that link to default highlighting. -" You can specify other highlighting easily. -SynLink String Constant -SynLink Character Constant -SynLink Number Constant -SynLink Boolean Constant -SynLink Float Number -SynLink Function Identifier -SynLink Conditional Statement -SynLink Repeat Statement -SynLink Label Statement -SynLink Operator Statement -SynLink Keyword Statement -SynLink Exception Statement -SynLink Include PreProc -SynLink Define PreProc -SynLink Macro PreProc -SynLink PreCondit PreProc -SynLink StorageClass Type -SynLink Structure Type -SynLink Typedef Type -SynLink Tag Special -SynLink SpecialChar Special -SynLink Delimiter Special -SynLink SpecialComment Special -SynLink Debug Special - -delcommand SynColor -delcommand SynLink diff --git a/runtime/syntax/synload.vim b/runtime/syntax/synload.vim index 3863a84c1a..bfcd3b06da 100644 --- a/runtime/syntax/synload.vim +++ b/runtime/syntax/synload.vim @@ -14,13 +14,6 @@ endif " let others know that syntax has been switched on let syntax_on = 1 -" Set the default highlighting colors. Use a color scheme if specified. -if exists("colors_name") - exe "colors " . colors_name -else - runtime! syntax/syncolor.vim -endif - " Line continuation is used here, remove 'C' from 'cpoptions' let s:cpo_save = &cpo set cpo&vim |