diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/doc/api.txt | 49 | ||||
| -rw-r--r-- | runtime/doc/eval.txt | 32 | ||||
| -rw-r--r-- | runtime/doc/lsp.txt | 16 | ||||
| -rw-r--r-- | runtime/doc/options.txt | 16 | ||||
| -rw-r--r-- | runtime/doc/quickref.txt | 1 | ||||
| -rw-r--r-- | runtime/doc/syntax.txt | 64 | ||||
| -rw-r--r-- | runtime/doc/vim_diff.txt | 8 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp.lua | 10 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 47 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 4 | ||||
| -rw-r--r-- | runtime/optwin.vim | 3 | ||||
| -rw-r--r-- | runtime/syntax/syncolor.vim | 89 | ||||
| -rw-r--r-- | runtime/syntax/synload.vim | 5 |
13 files changed, 126 insertions, 218 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 4dcf5b7bbc..c525ea7a3a 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -2290,7 +2290,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 @@ -2427,44 +2436,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/eval.txt b/runtime/doc/eval.txt index e32691dfb4..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 @@ -4308,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 @@ -4399,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 @@ -4742,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 @@ -6350,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 @@ -9299,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/lsp.txt b/runtime/doc/lsp.txt index c750a65c10..7daab4d6f1 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1487,6 +1487,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 diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index ab2230641d..5292847240 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1802,13 +1802,23 @@ 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: "both") + local to window + Settings for how 'cursorline' is displayed. Valid values: + "line" Highlight the text line of the cursor with + CursorLine |hl-CursorLine|. + "number" Highlight the line number of the cursor with + CursorLineNr |hl-CursorLineNr|. + "both" Highlight as both "line" and "number" are set. + + *'debug'* 'debug' string (default "") global diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index c19b05f6c7..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 diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 6c51f37ae5..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* | | @@ -5075,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 @@ -5271,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* diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index a259afded0..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: > diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index f5aefc8260..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 diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 246665602d..120320becc 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -1168,6 +1168,40 @@ function M.display(diagnostics, bufnr, client_id, config) 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 {{{ @@ -1361,18 +1395,7 @@ function M.enable(bufnr, client_id) diagnostic_disabled[bufnr][client_id] = nil - -- 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", - { - diagnostics = M.get(bufnr, client_id), - uri = vim.uri_from_bufnr(bufnr), - }, - client_id - ) + M.redraw(bufnr, client_id) end -- }}} diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a77c88e2dc..b7f1ea0ab6 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -457,12 +457,14 @@ for k, fn in pairs(M) do }) if err then + 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(tostring(err.code) .. ': ' .. err.message) + return err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) end return fn(err, method, params, client_id, bufnr, config) 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 27cc3360c4..0000000000 --- a/runtime/syntax/syncolor.vim +++ /dev/null @@ -1,89 +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 - -let did_syncolor = 1 - -" 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 aee9ba8b8e..bfcd3b06da 100644 --- a/runtime/syntax/synload.vim +++ b/runtime/syntax/synload.vim @@ -14,11 +14,6 @@ endif " let others know that syntax has been switched on let syntax_on = 1 -" Set the default highlighting colors -if !exists("colors_name") && !exists("did_syncolor") - runtime! syntax/syncolor.vim -endif - " Line continuation is used here, remove 'C' from 'cpoptions' let s:cpo_save = &cpo set cpo&vim |