diff options
Diffstat (limited to 'runtime')
94 files changed, 2147 insertions, 670 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index aacecc521e..c52def1051 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2022 Jan 31 +" Last Change: 2022 Mar 05 " These functions are moved here from runtime/filetype.vim to make startup " faster. @@ -211,6 +211,10 @@ func dist#ft#EuphoriaCheck() endfunc func dist#ft#DtraceCheck() + if did_filetype() + " Filetype was already detected + return + endif let lines = getline(1, min([line("$"), 100])) if match(lines, '^module\>\|^import\>') > -1 " D files often start with a module and/or import statement. diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 2f35179338..6022e05c22 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -301,7 +301,7 @@ function! s:check_python() abort call health#report_info(printf('Using: g:%s = "%s"', host_prog_var, get(g:, host_prog_var))) endif - let [pyname, pythonx_errors] = provider#pythonx#Detect(3) + let [pyname, pythonx_warnings] = provider#pythonx#Detect(3) if empty(pyname) call health#report_warn('No Python executable found that can `import neovim`. ' @@ -311,8 +311,9 @@ function! s:check_python() abort endif " No Python executable could `import neovim`, or host_prog_var was used. - if !empty(pythonx_errors) - call health#report_error('Python provider error:', pythonx_errors) + if !empty(pythonx_warnings) + call health#report_warn(pythonx_warnings, ['See :help provider-python for more information.', + \ 'You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim']) elseif !empty(pyname) && empty(python_exe) if !exists('g:'.host_prog_var) @@ -573,7 +574,8 @@ function! s:check_ruby() abort \ ['Run `gem install neovim` to ensure the neovim RubyGem is installed.', \ 'Run `gem environment` to ensure the gem bin directory is in $PATH.', \ 'If you are using rvm/rbenv/chruby, try "rehashing".', - \ 'See :help g:ruby_host_prog for non-standard gem installations.']) + \ 'See :help g:ruby_host_prog for non-standard gem installations.', + \ 'You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim']) return endif call health#report_info('Host: '. host) @@ -634,7 +636,8 @@ function! s:check_node() abort if empty(host) call health#report_warn('Missing "neovim" npm (or yarn) package.', \ ['Run in shell: npm install -g neovim', - \ 'Run in shell (if you use yarn): yarn global add neovim']) + \ 'Run in shell (if you use yarn): yarn global add neovim', + \ 'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim']) return endif call health#report_info('Nvim node.js host: '. host) @@ -683,14 +686,15 @@ function! s:check_perl() abort return endif - let [perl_exec, perl_errors] = provider#perl#Detect() + let [perl_exec, perl_warnings] = provider#perl#Detect() if empty(perl_exec) - if !empty(perl_errors) - call health#report_error('perl provider error:', perl_errors) - else + if !empty(perl_warnings) + call health#report_warn(perl_warnings, ['See :help provider-perl for more information.', + \ 'You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim']) + else call health#report_warn('No usable perl executable found') endif - return + return endif call health#report_info('perl executable: '. perl_exec) diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 5b299b322c..048f898e62 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -56,7 +56,7 @@ function! provider#pythonx#DetectByModule(module, major_version) abort endfor " No suitable Python executable found. - return ['', 'provider/pythonx: Could not load Python '.a:major_version.":\n".join(errors, "\n")] + return ['', 'Could not load Python '.a:major_version.":\n".join(errors, "\n")] endfunction " Returns array: [prog_exitcode, prog_version] @@ -99,7 +99,7 @@ function! provider#pythonx#CheckForModule(prog, module, major_version) abort endif if prog_exitcode == 2 - return [0, prog_path.' does not have the "' . a:module . '" module. :help provider-python'] + return [0, prog_path.' does not have the "' . a:module . '" module.'] elseif prog_exitcode == 127 " This can happen with pyenv's shims. return [0, prog_path . ' does not exist: ' . prog_version] diff --git a/runtime/compiler/jest.vim b/runtime/compiler/jest.vim index fee70b7c55..a4bb549de1 100644 --- a/runtime/compiler/jest.vim +++ b/runtime/compiler/jest.vim @@ -1,7 +1,7 @@ " Vim compiler file " Compiler: Jest " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2018 May 15 +" Last Change: 2021 Nov 20 if exists("current_compiler") finish @@ -15,12 +15,14 @@ endif let s:cpo_save = &cpo set cpo&vim -" CompilerSet makeprg=npx\ jest\ --no-colors +" CompilerSet makeprg=npx\ --no-install\ jest\ --no-colors CompilerSet makeprg=jest\ --no-colors -CompilerSet errorformat=%E\ \ ●\ %m, +CompilerSet errorformat=%-A\ \ ●\ Console, + \%E\ \ ●\ %m, \%Z\ %\\{4}%.%#Error:\ %f:\ %m\ (%l:%c):%\\=, \%Z\ %\\{6}at\ %\\S%#\ (%f:%l:%c), + \%Z\ %\\{6}at\ %\\S%#\ %f:%l:%c, \%+C\ %\\{4}%\\w%.%#, \%+C\ %\\{4}%[-+]%.%#, \%-C%.%#, diff --git a/runtime/compiler/sml.vim b/runtime/compiler/sml.vim index c7e1b1bf16..a0b13b6c8a 100644 --- a/runtime/compiler/sml.vim +++ b/runtime/compiler/sml.vim @@ -1,7 +1,7 @@ " Vim compiler file " Compiler: SML/NJ Compiler " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2020 Feb 10 +" Last Change: 2022 Feb 09 if exists("current_compiler") finish @@ -16,10 +16,10 @@ let s:cpo_save = &cpo set cpo&vim CompilerSet makeprg=sml -CompilerSet errorformat=%f:%l.%c-%\\d%\\+.%\\d%\\+\ %trror:\ %m, +CompilerSet errorformat=%f:%l.%c-%e.%k\ %trror:\ %m, \%f:%l.%c\ %trror:\ %m, - \%trror:\ %m - \%f:%l.%c-%\\d%\\+.%\\d%\\+\ %tarning:\ %m, + \%trror:\ %m, + \%f:%l.%c-%e.%k\ %tarning:\ %m, \%f:%l.%c\ %tarning:\ %m, \%tarning:\ %m, \%-G%.%# diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 7a5aeee603..4af13a3bbf 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -594,7 +594,8 @@ nvim__id_float({flt}) *nvim__id_float()* its argument. nvim__inspect_cell({grid}, {row}, {col}) *nvim__inspect_cell()* - TODO: Documentation + NB: if your UI doesn't use hlstate, this will not return + hlstate first time. nvim__runtime_inspect() *nvim__runtime_inspect()* TODO: Documentation @@ -651,6 +652,9 @@ nvim_add_user_command({name}, {command}, {*opts}) that contains the following keys: • args: (string) The args passed to the command, if any |<args>| + • fargs: (table) The args split by unescaped + whitespace (when more than one argument is + allowed), if any |<f-args>| • bang: (boolean) "true" if the command was executed with a ! modifier |<bang>| • line1: (number) The starting line of the @@ -706,7 +710,7 @@ nvim_call_atomic({calls}) *nvim_call_atomic()* be returned. nvim_chan_send({chan}, {data}) *nvim_chan_send()* - Send data to channel `id` . For a job, it writes it to the + Send data to channel `id`. For a job, it writes it to the stdin of the process. For the stdio channel |channel-stdio|, it writes to Nvim's stdout. For an internal terminal instance (|nvim_open_term()|) it writes directly to terminal output. @@ -846,7 +850,7 @@ nvim_exec_lua({code}, {args}) *nvim_exec_lua()* inside the chunk. The chunk can return a value. Only statements are executed. To evaluate an expression, - prefix it with `return` : return my_function(...) + prefix it with `return`: return my_function(...) Parameters: ~ {code} Lua code to execute @@ -1129,13 +1133,13 @@ nvim_get_option_value({name}, {*opts}) *nvim_get_option_value()* Option value nvim_get_proc({pid}) *nvim_get_proc()* - Gets info describing process `pid` . + Gets info describing process `pid`. Return: ~ Map of process properties, or NIL if process not found. nvim_get_proc_children({pid}) *nvim_get_proc_children()* - Gets the immediate children of process `pid` . + Gets the immediate children of process `pid`. Return: ~ Array of child process ids, empty if process not found. @@ -1244,8 +1248,8 @@ nvim_input_mouse({button}, {action}, {modifier}, {grid}, {row}, {col}) nvim_list_bufs() *nvim_list_bufs()* Gets the current list of buffer handles - Includes unlisted (unloaded/deleted) buffers, like `:ls!` . - Use |nvim_buf_is_loaded()| to check if a buffer is loaded. + Includes unlisted (unloaded/deleted) buffers, like `:ls!`. Use + |nvim_buf_is_loaded()| to check if a buffer is loaded. Return: ~ List of buffer handles @@ -1354,7 +1358,7 @@ nvim_paste({data}, {crlf}, {phase}) *nvim_paste()* Errors ('nomodifiable', `vim.paste()` failure, …) are reflected in `err` but do not affect the return value (which - is strictly decided by `vim.paste()` ). On error, subsequent + is strictly decided by `vim.paste()`). On error, subsequent calls are ignored ("drained") until the next paste is initiated (phase 1 or -1). @@ -1431,7 +1435,7 @@ nvim_select_popupmenu_item({item}, {insert}, {finish}, {opts}) {insert} Whether the selection should be inserted in the buffer. {finish} Finish the completion and dismiss the popupmenu. - Implies `insert` . + Implies `insert`. {opts} Optional parameters. Reserved for future use. *nvim_set_client_info()* @@ -1541,23 +1545,24 @@ nvim_set_current_win({window}) *nvim_set_current_win()* {window} Window handle nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()* - Set a highlight group. - - Parameters: ~ - {ns_id} number of namespace for this highlight. Use value - 0 to set a highlight group in the global ( - `:highlight` ) namespace. - {name} highlight group name, like ErrorMsg - {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` - `ctermfg` : sets foreground of cterm color - `ctermbg` : sets background of cterm color - `cterm` : cterm attribute map. sets attributed - for cterm colors. similer to `hi cterm` Note: by - default cterm attributes are same as attributes - of gui color + Sets a highlight group. + + Parameters: ~ + {ns_id} Namespace id for this highlight + |nvim_create_namespace()|. Use 0 to set a + highlight group globally |:highlight|. + {name} Highlight group name, e.g. "ErrorMsg" + {val} Highlight definition map, like |synIDattr()|. In + addition, the following keys are recognized: + • default: Don't override existing definition + |:hi-default| + • ctermfg: Sets foreground of cterm color + |highlight-ctermfg| + • ctermbg: Sets background of cterm color + |highlight-ctermbg| + • cterm: cterm attribute map, like + |highlight-args|. Note: Attributes default to + those set for `gui` if not set. nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()* Sets a global |mapping| for the given mode. @@ -1584,7 +1589,7 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()* {rhs} Right-hand-side |{rhs}| of the mapping. {opts} Optional parameters map. Accepts all |:map-arguments| as keys excluding |<buffer>| but - including |noremap| and "desc". |desc| can be used + including |noremap| and "desc". "desc" can be used to give a description to keymap. When called from Lua, also accepts a "callback" key that takes a Lua function to call when the mapping is executed. @@ -1626,7 +1631,7 @@ nvim_set_vvar({name}, {value}) *nvim_set_vvar()* {value} Variable value nvim_strwidth({text}) *nvim_strwidth()* - Calculates the number of display cells occupied by `text` . + Calculates the number of display cells occupied by `text`. <Tab> counts as one cell. Parameters: ~ @@ -1878,9 +1883,10 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* {buffer} Buffer handle, or 0 for current buffer {send_buffer} True if the initial notification should contain the whole buffer: first - notification will be `nvim_buf_lines_event` - . Else the first notification will be - `nvim_buf_changedtick_event` . Not for Lua + notification will be + `nvim_buf_lines_event`. Else the first + notification will be + `nvim_buf_changedtick_event`. Not for Lua callbacks. {opts} Optional parameters. • on_lines: Lua callback invoked on change. @@ -1936,7 +1942,7 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* • utf_sizes: include UTF-32 and UTF-16 size of the replaced region, as args to - `on_lines` . + `on_lines`. • preview: also attach to command preview (i.e. 'inccommand') events. @@ -2152,6 +2158,29 @@ nvim_buf_get_option({buffer}, {name}) *nvim_buf_get_option()* Return: ~ Option value + *nvim_buf_get_text()* +nvim_buf_get_text({buffer}, {start_row}, {start_col}, {end_row}, {end_col}, + {opts}) + Gets a range from the buffer. + + This differs from |nvim_buf_get_lines()| in that it allows + retrieving only portions of a line. + + Indexing is zero-based. Column indices are end-exclusive. + + Prefer |nvim_buf_get_lines()| when retrieving entire lines. + + Parameters: ~ + {buffer} Buffer handle, or 0 for current buffer + {start_row} First line index + {start_col} Starting byte offset of first line + {end_row} Last line index + {end_col} Ending byte offset of last line (exclusive) + {opts} Optional parameters. Currently unused. + + Return: ~ + Array of lines, or empty array for unloaded buffer. + nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()* Gets a buffer-scoped (b:) variable. @@ -2328,7 +2357,7 @@ nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, {col_start}, namespace. All highlights in the same namespace can then be cleared with single call to |nvim_buf_clear_namespace()|. If the highlight never will be deleted by an API call, pass - `ns_id = -1` . + `ns_id = -1`. As a shorthand, `ns_id = 0` can be used to create a new namespace for the highlight, the allocated id is then @@ -2408,8 +2437,8 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts}) nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {}) < - If `end` is less than `start` , traversal works backwards. - (Useful with `limit` , to get the first marks prior to a given + If `end` is less than `start`, traversal works backwards. + (Useful with `limit`, to get the first marks prior to a given position.) Example: @@ -2756,7 +2785,7 @@ nvim_win_hide({window}) *nvim_win_hide()* |:hide| with a |window-ID|). Like |:hide| the buffer becomes hidden unless another window - is editing it, or 'bufhidden' is `unload` , `delete` or `wipe` + is editing it, or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to |:close| or |nvim_win_close|, which will close the buffer. @@ -3004,7 +3033,7 @@ nvim_win_set_config({window}, {*config}) *nvim_win_set_config()* layouts). When reconfiguring a floating window, absent option keys will - not be changed. `row` / `col` and `relative` must be + not be changed. `row`/`col` and `relative` must be reconfigured together. Parameters: ~ @@ -3083,6 +3112,135 @@ nvim_tabpage_set_var({tabpage}, {name}, {value}) ============================================================================== +Autocmd Functions *api-autocmd* + +nvim_create_augroup({name}, {*opts}) *nvim_create_augroup()* + Create or get an augroup. + + To get an existing augroup ID, do: > + local id = vim.api.nvim_create_augroup(name, { + clear = false + }) +< + + Parameters: ~ + {name} String: The name of the augroup to create + {opts} Parameters + • clear (bool): Whether to clear existing commands + or not. Defaults to true. See |autocmd-groups| + + Return: ~ + opaque value to use with nvim_del_augroup_by_id + +nvim_create_autocmd({event}, {*opts}) *nvim_create_autocmd()* + Create an autocmd. + + Examples: + • event: "pat1,pat2,pat3", + • event: "pat1" + • event: { "pat1" } + • event: { "pat1", "pat2", "pat3" } + + Parameters: ~ + {event} The event or events to register this autocmd + Required keys: event: string | ArrayOf(string) + + Parameters: ~ + {opts} Optional Parameters: + • callback: (string|function) + • (string): The name of the viml function to + execute when triggering this autocmd + • (function): The lua function to execute when + triggering this autocmd + • NOTE: Cannot be used with {command} + + • command: (string) command + • vimscript command + • NOTE: Cannot be used with {callback} Eg. + command = "let g:value_set = v:true" + + • pattern: (string|table) + • pattern or patterns to match against + • defaults to "*". + • NOTE: Cannot be used with {buffer} + + • buffer: (bufnr) + • create a |autocmd-buflocal| autocmd. + • NOTE: Cannot be used with {pattern} + + • group: (string|int) The augroup name or id + • once: (boolean) - See |autocmd-once| + • nested: (boolean) - See |autocmd-nested| + • desc: (string) - Description of the autocmd + + Return: ~ + opaque value to use with nvim_del_autocmd + +nvim_del_augroup_by_id({id}) *nvim_del_augroup_by_id()* + Delete an augroup by {id}. {id} can only be returned when + augroup was created with |nvim_create_augroup|. + + NOTE: behavior differs from augroup-delete. + + When deleting an augroup, autocmds contained by this augroup + will also be deleted and cleared. This augroup will no longer + exist + +nvim_del_augroup_by_name({name}) *nvim_del_augroup_by_name()* + Delete an augroup by {name}. + + NOTE: behavior differs from augroup-delete. + + When deleting an augroup, autocmds contained by this augroup + will also be deleted and cleared. This augroup will no longer + exist + +nvim_del_autocmd({id}) *nvim_del_autocmd()* + Delete an autocmd by {id}. Autocmds only return IDs when + created via the API. Will not error if called and no autocmds + match the {id}. + + Parameters: ~ + {id} Integer The ID returned by nvim_create_autocmd + +nvim_do_autocmd({event}, {*opts}) *nvim_do_autocmd()* + Do one autocmd. + + Parameters: ~ + {event} The event or events to execute + {opts} Optional Parameters: + • buffer (number) - buffer number + • NOTE: Cannot be used with {pattern} + + • pattern (string|table) - optional, defaults to + "*". + • NOTE: Cannot be used with {buffer} + + • group (string|int) - autocmd group name or id + • modeline (boolean) - Default true, see + |<nomodeline>| + +nvim_get_autocmds({*opts}) *nvim_get_autocmds()* + Get autocmds that match the requirements passed to {opts}. + + Parameters: ~ + {opts} Optional Parameters: + • event : Name or list of name of events to match + against + • group (string|int): Name or id of group to match + against + • pattern: Pattern or list of patterns to match + against. Cannot be used with {buffer} + • buffer: Buffer number or list of buffer numbers + for buffer local autocommands + |autocmd-buflocal|. Cannot be used with + {pattern} + + Return: ~ + A list of autocmds that match + + +============================================================================== UI Functions *api-ui* nvim_ui_attach({width}, {height}, {options}) *nvim_ui_attach()* diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index ed75acf36e..ab0b0cd07c 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -525,8 +525,19 @@ DirChanged After the |current-directory| was changed. "global" to trigger on `:cd` "auto" to trigger on 'autochdir'. Sets these |v:event| keys: - cwd: current working directory - scope: "global", "tabpage", "window" + cwd: current working directory + scope: "global", "tabpage", "window" + changed_window: v:true if we fired the event + switching window (or tab) + <afile> is set to the new directory name. + Non-recursive (event cannot trigger itself). + *DirChangedPre* +DirChangedPre When the |current-directory| is going to be + changed, as with |DirChanged|. + The pattern is like with |DirChanged|. + Sets these |v:event| keys: + directory: new working directory + scope: "global", "tabpage", "window" changed_window: v:true if we fired the event switching window (or tab) <afile> is set to the new directory name. @@ -663,15 +674,19 @@ FuncUndefined When a user function is used but it isn't alternative is to use an autoloaded function. See |autoload-functions|. *UIEnter* -UIEnter After a UI connects via |nvim_ui_attach()|, - after VimEnter. Can be used for GUI-specific - configuration. +UIEnter After a UI connects via |nvim_ui_attach()|, or + after builtin TUI is started, after |VimEnter|. Sets these |v:event| keys: - chan + chan: 0 for builtin TUI + 1 for |--embed| + |channel-id| of the UI otherwise *UILeave* -UILeave After a UI disconnects from Nvim. +UILeave After a UI disconnects from Nvim, or after + builtin TUI is stopped, after |VimLeave|. Sets these |v:event| keys: - chan + chan: 0 for builtin TUI + 1 for |--embed| + |channel-id| of the UI otherwise *InsertChange* InsertChange When typing <Insert> while in Insert or Replace mode. The |v:insertmode| variable @@ -1064,7 +1079,7 @@ WinLeave Before leaving a window. If the window to be executes the BufLeave autocommands before the WinLeave autocommands (but not for ":new"). Not used for ":qa" or ":q" when exiting Vim. - After WinClosed. + Before WinClosed. *WinNew* WinNew When a new window was created. Not done for the first window, when Vim has just started. @@ -1395,7 +1410,7 @@ Examples for reading and writing compressed files: > : autocmd BufReadPre,FileReadPre *.gz set bin : autocmd BufReadPost,FileReadPost *.gz '[,']!gunzip : autocmd BufReadPost,FileReadPost *.gz set nobin - : autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") + : autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " .. expand("%:r") : autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r : autocmd BufWritePost,FileWritePost *.gz !gzip <afile>:r @@ -1494,7 +1509,7 @@ To insert the current date and time in a *.html file when writing it: > : else : let l = line("$") : endif - : exe "1," . l . "g/Last modified: /s/Last modified: .*/Last modified: " . + : exe "1," .. l .. "g/Last modified: /s/Last modified: .*/Last modified: " .. : \ strftime("%Y %b %d") :endfun diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 35a232c0c2..9eec23b7b7 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -693,7 +693,7 @@ argv([{nr} [, {winid}]]) :let i = 0 :while i < argc() : let f = escape(fnameescape(argv(i)), '.') - : exe 'amenu Arg.' . f . ' :e ' . f . '<CR>' + : exe 'amenu Arg.' .. f .. ' :e ' .. f .. '<CR>' : let i = i + 1 :endwhile < Without the {nr} argument, or when {nr} is -1, a |List| with @@ -895,7 +895,7 @@ bufwinid({buf}) *bufwinid()* see |bufname()| above. If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: > - echo "A window containing buffer 1 is " . (bufwinid(1)) + echo "A window containing buffer 1 is " .. (bufwinid(1)) < Only deals with the current tab page. @@ -908,7 +908,7 @@ bufwinnr({buf}) *bufwinnr()* If buffer {buf} doesn't exist or there is no such window, -1 is returned. Example: > - echo "A window containing buffer 1 is " . (bufwinnr(1)) + echo "A window containing buffer 1 is " .. (bufwinnr(1)) < The number can be used with |CTRL-W_w| and ":wincmd w" |:wincmd|. @@ -955,7 +955,7 @@ byteidx({expr}, {nr}) *byteidx()* byteidxcomp({expr}, {nr}) *byteidxcomp()* Like byteidx(), except that a composing character is counted as a separate character. Example: > - let s = 'e' . nr2char(0x301) + let s = 'e' .. nr2char(0x301) echo byteidx(s, 1) echo byteidxcomp(s, 1) echo byteidxcomp(s, 2) @@ -1152,7 +1152,7 @@ col({expr}) The result is a Number, which is the byte index of the column col(".") column of cursor col("$") length of cursor line plus one col("'t") column of mark t - col("'" . markname) column of mark markname + col("'" .. markname) column of mark markname < The first column is 1. 0 is returned for an error. For an uppercase mark the column may actually be in another buffer. @@ -1161,7 +1161,7 @@ col({expr}) The result is a Number, which is the byte index of the column line. This can be used to obtain the column in Insert mode: > :imap <F2> <C-O>:let save_ve = &ve<CR> \<C-O>:set ve=all<CR> - \<C-O>:echo col(".") . "\n" <Bar> + \<C-O>:echo col(".") .. "\n" <Bar> \let &ve = save_ve<CR> < Can also be used as a |method|: > @@ -1284,7 +1284,7 @@ complete_info([{what}]) *complete_info()* < *confirm()* confirm({msg} [, {choices} [, {default} [, {type}]]]) - Confirm() offers the user a dialog, from which a choice can be + confirm() offers the user a dialog, from which a choice can be made. It returns the number of the choice. For the first choice this is 1. @@ -1807,6 +1807,7 @@ exists({expr}) The result is a Number, which is |TRUE| if {expr} is exists("$HOSTNAME") exists("*strftime") exists("*s:MyFunc") + exists("*MyFunc") exists("bufcount") exists(":Make") exists("#CursorHold") @@ -1898,12 +1899,12 @@ expand({string} [, {nosuf} [, {list}]]) *expand()* :e extension only Example: > - :let &tags = expand("%:p:h") . "/tags" + :let &tags = expand("%:p:h") .. "/tags" < Note that when expanding a string that starts with '%', '#' or '<', any following text is ignored. This does NOT work: > :let doesntwork = expand("%:h.bak") < Use this: > - :let doeswork = expand("%:h") . ".bak" + :let doeswork = expand("%:h") .. ".bak" < Also note that expanding "<cfile>" and others only returns the referenced file name without further expansion. If "<cfile>" is "~/.cshrc", you need to do another expand() to have the @@ -2239,7 +2240,7 @@ fnameescape({string}) *fnameescape()* and |:write|). And a "-" by itself (special after |:cd|). Example: > :let fname = '+some str%nge|name' - :exe "edit " . fnameescape(fname) + :exe "edit " .. fnameescape(fname) < results in executing: > edit \+some\ str\%nge\|name < @@ -2394,7 +2395,7 @@ function({name} [, {arglist}] [, {dict}]) < The Dictionary is only useful when calling a "dict" function. In that case the {dict} is passed in as "self". Example: > function Callback() dict - echo "called for " . self.name + echo "called for " .. self.name endfunction ... let context = {"name": "example"} @@ -2577,7 +2578,7 @@ getbufvar({buf}, {varname} [, {def}]) *getbufvar()* string is returned, there is no error message. Examples: > :let bufmodified = getbufvar(1, "&mod") - :echo "todo myvar = " . getbufvar("todo", "myvar") + :echo "todo myvar = " .. getbufvar("todo", "myvar") < Can also be used as a |method|: > GetBufnr()->getbufvar(varname) @@ -2638,9 +2639,9 @@ getchar([expr]) *getchar()* This example positions the mouse as it would normally happen: > let c = getchar() if c == "\<LeftMouse>" && v:mouse_win > 0 - exe v:mouse_win . "wincmd w" + exe v:mouse_win .. "wincmd w" exe v:mouse_lnum - exe "normal " . v:mouse_col . "|" + exe "normal " .. v:mouse_col .. "|" endif < There is no prompt, you will somehow have to make clear to the @@ -3038,10 +3039,16 @@ getloclist({nr} [, {what}]) *getloclist()* If the optional {what} dictionary argument is supplied, then returns the items listed in {what} as a dictionary. Refer to |getqflist()| for the supported items in {what}. - If {what} contains 'filewinid', then returns the id of the - window used to display files from the location list. This - field is applicable only when called from a location list - window. See |location-list-file-window| for more details. + + In addition to the items supported by |getqflist()| in {what}, + the following item is supported by |getloclist()|: + + filewinid id of the window used to display files + from the location list. This field is + applicable only when called from a + location list window. See + |location-list-file-window| for more + details. Returns a |Dictionary| with default values if there is no location list for the window {nr}. @@ -3217,6 +3224,9 @@ getqflist([{what}]) *getqflist()* nr get information for this quickfix list; zero means the current quickfix list and "$" means the last quickfix list + qfbufnr number of the buffer displayed in the quickfix + window. Returns 0 if the quickfix buffer is + not present. See |quickfix-buffer|. size number of entries in the quickfix list title get the list title |quickfix-title| winid get the quickfix |window-ID| @@ -3245,6 +3255,8 @@ getqflist([{what}]) *getqflist()* items quickfix list entries. If not present, set to an empty list. nr quickfix list number. If not present, set to 0 + qfbufnr number of the buffer displayed in the quickfix + window. If not present, set to 0. size number of entries in the quickfix list. If not present, set to 0. title quickfix list title text. If not present, set @@ -3373,7 +3385,7 @@ gettabwinvar({tabnr}, {winnr}, {varname} [, {def}]) *gettabwinvar()* empty string is returned, there is no error message. Examples: > :let list_is_on = gettabwinvar(1, 2, '&list') - :echo "myvar = " . gettabwinvar(3, 1, 'myvar') + :echo "myvar = " .. gettabwinvar(3, 1, 'myvar') < To obtain all window-local variables use: > gettabwinvar({tabnr}, {winnr}, '&') @@ -3488,7 +3500,7 @@ getwinvar({winnr}, {varname} [, {def}]) *getwinvar()* Like |gettabwinvar()| for the current tabpage. Examples: > :let list_is_on = getwinvar(2, '&list') - :echo "myvar = " . getwinvar(1, 'myvar') + :echo "myvar = " .. getwinvar(1, 'myvar') < Can also be used as a |method|: > GetWinnr()->getwinvar(varname) @@ -3757,7 +3769,7 @@ histdel({history} [, {item}]) *histdel()* The following three are equivalent: > :call histdel("search", histnr("search")) :call histdel("search", -1) - :call histdel("search", '^'.histget("search", -1).'$') + :call histdel("search", '^' .. histget("search", -1) .. '$') < To delete the last search pattern and use the last-but-one for the "n" command and 'hlsearch': > @@ -3776,7 +3788,7 @@ histget({history} [, {index}]) *histget()* Examples: Redo the second last search from history. > - :execute '/' . histget("search", -2) + :execute '/' .. histget("search", -2) < Define an Ex command ":H {num}" that supports re-execution of the {num}th entry from the output of |:history|. > @@ -3940,11 +3952,11 @@ input({opts}) let lvl = 0 while i < len(a:cmdline) if a:cmdline[i] is# '(' - call add(ret, [i, i + 1, 'RBP' . ((lvl % g:rainbow_levels) + 1)]) + call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) let lvl += 1 elseif a:cmdline[i] is# ')' let lvl -= 1 - call add(ret, [i, i + 1, 'RBP' . ((lvl % g:rainbow_levels) + 1)]) + call add(ret, [i, i + 1, 'RBP' .. ((lvl % g:rainbow_levels) + 1)]) endif let i += 1 endwhile @@ -3974,7 +3986,7 @@ input({opts}) |:execute| or |:normal|. Example with a mapping: > - :nmap \x :call GetFoo()<CR>:exe "/" . Foo<CR> + :nmap \x :call GetFoo()<CR>:exe "/" .. Foo<CR> :function GetFoo() : call inputsave() : let g:Foo = input("enter search pattern: ") @@ -4133,7 +4145,7 @@ items({dict}) *items()* order. Also see |keys()| and |values()|. Example: > for [key, value] in items(mydict) - echo key . ': ' . value + echo key .. ': ' .. value endfor < Can also be used as a |method|: > @@ -4269,7 +4281,7 @@ join({list} [, {sep}]) *join()* {sep} is omitted a single space is used. Note that {sep} is not added at the end. You might want to add it there too: > - let lines = join(mylist, "\n") . "\n" + let lines = join(mylist, "\n") .. "\n" < String items are used as-is. |Lists| and |Dictionaries| are converted into a string like with |string()|. The opposite function is |split()|. @@ -4418,7 +4430,7 @@ line({expr} [, {winid}]) *line()* line(".") line number of the cursor line(".", winid) idem, in window "winid" line("'t") line number of mark t - line("'" . marker) line number of mark marker + line("'" .. marker) line number of mark marker < To jump to the last known position when opening a file see |last-position-jump|. @@ -4519,7 +4531,7 @@ map({expr1}, {expr2}) *map()* the current item. For a |Blob| |v:key| has the index of the current byte. Example: > - :call map(mylist, '"> " . v:val . " <"') + :call map(mylist, '"> " .. v:val .. " <"') < This puts "> " before and " <" after each item in "mylist". Note that {expr2} is the result of an expression and is then @@ -4533,19 +4545,19 @@ map({expr1}, {expr2}) *map()* The function must return the new value of the item. Example that changes each value by "key-value": > func KeyValue(key, val) - return a:key . '-' . a:val + return a:key .. '-' .. a:val endfunc call map(myDict, function('KeyValue')) < It is shorter when using a |lambda|: > - call map(myDict, {key, val -> key . '-' . val}) + call map(myDict, {key, val -> key .. '-' .. val}) < If you do not use "val" you can leave it out: > - call map(myDict, {key -> 'item: ' . key}) + call map(myDict, {key -> 'item: ' .. key}) < If you do not use "key" you can use a short name: > - call map(myDict, {_, val -> 'item: ' . val}) + call map(myDict, {_, val -> 'item: ' .. val}) < The operation is done in-place. If you want a |List| or |Dictionary| to remain unmodified make a copy first: > - :let tlist = map(copy(mylist), ' v:val . "\t"') + :let tlist = map(copy(mylist), ' v:val .. "\t"') < Returns {expr1}, the |List|, |Blob| or |Dictionary| that was filtered. When an error is encountered while evaluating @@ -4611,7 +4623,7 @@ maparg({name} [, {mode} [, {abbr} [, {dict}]]]) *maparg()* then the global mappings. This function can be used to map a key even when it's already mapped, and have it do the original mapping too. Sketch: > - exe 'nnoremap <Tab> ==' . maparg('<Tab>', 'n') + exe 'nnoremap <Tab> ==' .. maparg('<Tab>', 'n') < Can also be used as a |method|: > GetKey()->maparg('n') @@ -4899,7 +4911,7 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()* empty list is returned. If length of {str} is greater than 256, then returns an empty list. - Refer to |fuzzy-match| for more information about fuzzy + Refer to |fuzzy-matching| for more information about fuzzy matching strings. Example: > @@ -5084,7 +5096,7 @@ mkdir({name} [, {path} [, {prot}]]) {prot} is applied for all parts of {name}. Thus if you create /tmp/foo/bar then /tmp/foo will be created with 0o700. Example: > - :call mkdir($HOME . "/tmp/foo/bar", "p", 0o700) + :call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700) < This function is not available in the |sandbox|. @@ -5584,7 +5596,7 @@ prompt_setcallback({buf}, {expr}) *prompt_setcallback()* stopinsert close else - call append(line('$') - 1, 'Entered: "' . a:text . '"') + call append(line('$') - 1, 'Entered: "' .. a:text .. '"') " Reset 'modified' to allow the buffer to be closed. set nomodified endif @@ -5731,7 +5743,7 @@ readdir({directory} [, {expr}]) function! s:tree(dir) return {a:dir : map(readdir(a:dir), \ {_, x -> isdirectory(x) ? - \ {x : s:tree(a:dir . '/' . x)} : x})} + \ {x : s:tree(a:dir .. '/' .. x)} : x})} endfunction echo s:tree(".") < @@ -5863,16 +5875,22 @@ reltimestr({time}) *reltimestr()* < *remote_expr()* *E449* remote_expr({server}, {string} [, {idvar} [, {timeout}]]) - Send the {string} to {server}. The string is sent as an - expression and the result is returned after evaluation. - The result must be a String or a |List|. A |List| is turned - into a String by joining the items with a line break in - between (not at the end), like with join(expr, "\n"). + Send the {string} to {server}. The {server} argument is a + string, also see |{server}|. + + The string is sent as an expression and the result is returned + after evaluation. The result must be a String or a |List|. A + |List| is turned into a String by joining the items with a + line break in between (not at the end), like with join(expr, + "\n"). + If {idvar} is present and not empty, it is taken as the name of a variable and a {serverid} for later use with |remote_read()| is stored there. + If {timeout} is given the read times out after this many seconds. Otherwise a timeout of 600 seconds is used. + See also |clientserver| |RemoteReply|. This function is not available in the |sandbox|. Note: Any errors will cause a local error message to be issued @@ -5890,7 +5908,7 @@ remote_expr({server}, {string} [, {idvar} [, {timeout}]]) remote_foreground({server}) *remote_foreground()* Move the Vim server with the name {server} to the foreground. - The {server} argument is a string. + The {server} argument is a string, also see |{server}|. This works like: > remote_expr({server}, "foreground()") < Except that on Win32 systems the client does the work, to work @@ -5913,7 +5931,7 @@ remote_peek({serverid} [, {retvar}]) *remote_peek()* This function is not available in the |sandbox|. Examples: > :let repl = "" - :echo "PEEK: ".remote_peek(id, "repl").": ".repl + :echo "PEEK: " .. remote_peek(id, "repl") .. ": " .. repl remote_read({serverid}, [{timeout}]) *remote_read()* Return the oldest available reply from {serverid} and consume @@ -5926,24 +5944,29 @@ remote_read({serverid}, [{timeout}]) *remote_read()* < *remote_send()* *E241* remote_send({server}, {string} [, {idvar}]) - Send the {string} to {server}. The string is sent as input - keys and the function returns immediately. At the Vim server - the keys are not mapped |:map|. + Send the {string} to {server}. The {server} argument is a + string, also see |{server}|. + + The string is sent as input keys and the function returns + immediately. At the Vim server the keys are not mapped + |:map|. + If {idvar} is present, it is taken as the name of a variable and a {serverid} for later use with remote_read() is stored there. + See also |clientserver| |RemoteReply|. This function is not available in the |sandbox|. Note: Any errors will be reported in the server and may mess up the display. Examples: > - :echo remote_send("gvim", ":DropAndReply ".file, "serverid"). + :echo remote_send("gvim", ":DropAndReply " .. file, "serverid") .. \ remote_read(serverid) :autocmd NONE RemoteReply * \ echo remote_read(expand("<amatch>")) - :echo remote_send("gvim", ":sleep 10 | echo ". + :echo remote_send("gvim", ":sleep 10 | echo " .. \ 'server2client(expand("<client>"), "HELLO")<CR>') < *remote_startserver()* *E941* *E942* @@ -5960,7 +5983,7 @@ remove({list}, {idx} [, {end}]) *remove()* points to an item before {idx} this is an error. See |list-index| for possible values of {idx} and {end}. Example: > - :echo "last item: " . remove(mylist, -1) + :echo "last item: " .. remove(mylist, -1) :call remove(mylist, 0, 9) < Use |delete()| to remove a file. @@ -5976,13 +5999,13 @@ remove({blob}, {idx} [, {end}]) byte as {end} a |Blob| with one byte is returned. When {end} points to a byte before {idx} this is an error. Example: > - :echo "last byte: " . remove(myblob, -1) + :echo "last byte: " .. remove(myblob, -1) :call remove(mylist, 0, 9) remove({dict}, {key}) Remove the entry from {dict} with key {key} and return it. Example: > - :echo "removed " . remove(dict, "one") + :echo "removed " .. remove(dict, "one") < If there is no {key} in {dict} this is an error. rename({from}, {to}) *rename()* @@ -6123,7 +6146,7 @@ screencol() *screencol()* column inside the command line, which is 1 when the command is executed. To get the cursor position in the file use one of the following mappings: > - nnoremap <expr> GG ":echom ".screencol()."\n" + nnoremap <expr> GG ":echom " .. screencol() .. "\n" nnoremap <silent> GG :echom screencol()<CR> noremap GG <Cmd>echom screencol()<Cr> < @@ -6244,7 +6267,7 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]]) Example (goes over all files in the argument list): > :let n = 1 :while n <= argc() " loop over all files in arglist - : exe "argument " . n + : exe "argument " .. n : " start at the last char in the file and wrap for the : " first search to find match at start of file : normal G$ @@ -6328,11 +6351,11 @@ searchcount([{options}]) *searchcount()* return printf(' /%s [%d/%d]', @/, \ result.current, result.total) endfunction - let &statusline .= '%{LastSearchCount()}' + let &statusline ..= '%{LastSearchCount()}' " Or if you want to show the count only when " 'hlsearch' was on - " let &statusline .= + " let &statusline ..= " \ '%{v:hlsearch ? LastSearchCount() : ""}' < You can also update the search count, which can be useful in a @@ -6868,12 +6891,14 @@ setqflist({list} [, {action} [, {what}]]) *setqflist()* filename name of a file; only used when "bufnr" is not present or it is invalid. module name of a module; if given it will be used in - quickfix error window instead of the filename + quickfix error window instead of the filename. lnum line number in the file + end_lnum end of lines, if the item spans multiple lines pattern search pattern used to locate the error col column number vcol when non-zero: "col" is visual column when zero: "col" is byte index + end_col end column, if the item spans multiple columns nr error number text description of the error type single-character error type, 'E', 'W', etc. @@ -7134,10 +7159,10 @@ shellescape({string} [, {special}]) *shellescape()* inside single quotes. Example of use with a |:!| command: > - :exe '!dir ' . shellescape(expand('<cfile>'), 1) + :exe '!dir ' .. shellescape(expand('<cfile>'), 1) < This results in a directory listing for the file under the cursor. Example of use with |system()|: > - :call system("chmod +w -- " . shellescape(expand("%"))) + :call system("chmod +w -- " .. shellescape(expand("%"))) < See also |::S|. Can also be used as a |method|: > @@ -7829,7 +7854,7 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* When {sub} starts with "\=", the remainder is interpreted as an expression. See |sub-replace-expression|. Example: > :echo substitute(s, '%\(\x\x\)', - \ '\=nr2char("0x" . submatch(1))', 'g') + \ '\=nr2char("0x" .. submatch(1))', 'g') < When {sub} is a Funcref that function is called, with one optional argument. Example: > @@ -7837,7 +7862,7 @@ substitute({string}, {pat}, {sub}, {flags}) *substitute()* < The optional argument is a list which contains the whole matched string and up to nine submatches, like what |submatch()| returns. Example: > - :echo substitute(s, '%\(\x\x\)', {m -> '0x' . m[1]}, 'g') + :echo substitute(s, '%\(\x\x\)', {m -> '0x' .. m[1]}, 'g') < Can also be used as a |method|: > GetString()->substitute(pat, sub, flags) @@ -7925,8 +7950,11 @@ synIDattr({synID}, {what} [, {mode}]) *synIDattr()* "inverse" "1" if inverse (= reverse) "standout" "1" if standout "underline" "1" if underlined + "underlineline" "1" if double underlined "undercurl" "1" if undercurled - "strikethrough" "1" if struckthrough + "underdot" "1" if dotted underlined + "underdash" "1" if dashed underlined + "strikethrough" "1" if struckthrough Example (echoes the color of the syntax item under the cursor): > @@ -8075,15 +8103,15 @@ tabpagebuflist([{arg}]) *tabpagebuflist()* tabpagenr([{arg}]) *tabpagenr()* The result is a Number, which is the number of the current tab page. The first tab page has number 1. + The optional argument {arg} supports the following values: $ the number of the last tab page (the tab page count). - # the number of the last accessed tab page (where - |g<Tab>| goes to). If there is no previous - tab page, 0 is returned. + # the number of the last accessed tab page + (where |g<Tab>| goes to). If there is no + previous tab page, 0 is returned. The number can be used with the |:tab| command. - tabpagewinnr({tabarg} [, {arg}]) *tabpagewinnr()* Like |winnr()| but for tab page {tabarg}. {tabarg} specifies the number of tab page to be used. @@ -8155,7 +8183,7 @@ tempname() *tempname()* *temp-file-name* The result is a String, which is the name of a file that doesn't exist. It can be used for a temporary file. Example: > :let tmpfile = tempname() - :exe "redir > " . tmpfile + :exe "redir > " .. tmpfile < For Unix, the file will be in a private directory |tempfile|. For MS-Windows forward slashes are used when the 'shellslash' option is set or when 'shellcmdflag' starts with '-'. @@ -8331,7 +8359,7 @@ trim({text} [, {mask} [, {dir}]]) *trim()* Examples: > echo trim(" some text ") < returns "some text" > - echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") . "_TAIL" + echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") .. "_TAIL" < returns "RESERVE_TAIL" > echo trim("rm<Xrm<>X>rrm", "rm<>") < returns "Xrm<>X" (characters in the middle are not removed) > @@ -8509,7 +8537,7 @@ visualmode([{expr}]) *visualmode()* character-wise, line-wise, or block-wise Visual mode respectively. Example: > - :exe "normal " . visualmode() + :exe "normal " .. visualmode() < This enters the same Visual mode as before. It is also useful in scripts if you wish to act differently depending on the Visual mode that was used. @@ -8696,7 +8724,7 @@ winbufnr({nr}) The result is a Number, which is the number of the buffer window is returned. When window {nr} doesn't exist, -1 is returned. Example: > - :echo "The file in the current window is " . bufname(winbufnr(0)) + :echo "The file in the current window is " .. bufname(winbufnr(0)) < Can also be used as a |method|: > FindWindow()->winbufnr()->bufname() @@ -8721,7 +8749,7 @@ winheight({nr}) *winheight()* An existing window always has a height of zero or more. This excludes any window toolbar line. Examples: > - :echo "The current window has " . winheight(0) . " lines." + :echo "The current window has " .. winheight(0) .. " lines." < Can also be used as a |method|: > GetWinid()->winheight() @@ -8858,7 +8886,7 @@ winwidth({nr}) *winwidth()* returned. When window {nr} doesn't exist, -1 is returned. An existing window always has a width of zero or more. Examples: > - :echo "The current window has " . winwidth(0) . " columns." + :echo "The current window has " .. winwidth(0) .. " columns." :if winwidth(0) <= 50 : 50 wincmd | :endif diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index b4d3304880..86e19c5ec5 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -355,14 +355,14 @@ CTRL-A Add [count] to the number or alphabetic character at *v_CTRL-A* {Visual}CTRL-A Add [count] to the number or alphabetic character in - the highlighted text. {not in Vi} + the highlighted text. *v_g_CTRL-A* {Visual}g CTRL-A Add [count] to the number or alphabetic character in the highlighted text. If several lines are highlighted, each one will be incremented by an additional [count] (so effectively creating a - [count] incrementing sequence). {not in Vi} + [count] incrementing sequence). For Example, if you have this list of numbers: 1. ~ 1. ~ @@ -381,14 +381,14 @@ CTRL-X Subtract [count] from the number or alphabetic *v_CTRL-X* {Visual}CTRL-X Subtract [count] from the number or alphabetic - character in the highlighted text. {not in Vi} + character in the highlighted text. *v_g_CTRL-X* {Visual}g CTRL-X Subtract [count] from the number or alphabetic character in the highlighted text. If several lines are highlighted, each value will be decremented by an additional [count] (so effectively creating a [count] - decrementing sequence). {not in Vi} + decrementing sequence). The CTRL-A and CTRL-X commands work for (signed) decimal numbers, unsigned binary/octal/hexadecimal numbers and alphabetic characters. @@ -906,7 +906,7 @@ Consider using a character like "@" or ":". There is no problem if the result of the expression contains the separation character. Examples: > - :s@\n@\="\r" . expand("$HOME") . "\r"@ + :s@\n@\="\r" .. expand("$HOME") .. "\r"@ This replaces an end-of-line with a new line containing the value of $HOME. > s/E/\="\<Char-0x20ac>"/g @@ -1018,7 +1018,7 @@ inside of strings can change! Also see 'softtabstop' option. > in [range] (default: current line |cmdline-ranges|), [into register x]. - *p* *put* *E353* + *p* *put* *E353* *E1240* ["x]p Put the text [from register x] after the cursor [count] times. @@ -1065,7 +1065,7 @@ inside of strings can change! Also see 'softtabstop' option. > the command. You need to escape the '|' and '"' characters to prevent them from terminating the command. Example: > - :put ='path' . \",/test\" + :put ='path' .. \",/test\" < If there is no expression after '=', Vim uses the previous expression. You can see it with ":dis =". diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index e14427494d..d4bed7a5f2 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -229,12 +229,12 @@ prompt. > call chansend(g:shell_job, [a:text, '']) endfunc - " Function handling output from the shell: Added above the prompt. + " Function handling output from the shell: Add it above the prompt. func GotOutput(channel, msg, name) call append(line("$") - 1, a:msg) endfunc - " Function handling the shell exit: close the window. + " Function handling the shell exits: close the window. func JobExit(job, status, event) quit! endfunc diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index f2f6ebb2c9..9fa2034718 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -207,7 +207,7 @@ CTRL-\ e {expr} *c_CTRL-\_e* Example: > :cmap <F7> <C-\>eAppendSome()<CR> :func AppendSome() - :let cmd = getcmdline() . " Some()" + :let cmd = getcmdline() .. " Some()" :" place the cursor on the ) :call setcmdpos(strlen(cmd)) :return cmd @@ -679,7 +679,7 @@ If more line specifiers are given than required for the command, the first one(s) will be ignored. Line numbers may be specified with: *:range* *{address}* - {number} an absolute line number + {number} an absolute line number *E1247* . the current line *:.* $ the last line in the file *:$* % equal to 1,$ (the entire file) *:%* diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 178b0dc62b..cc146fcf6e 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -204,7 +204,7 @@ Docstring format: - Use `<pre>` for code samples. Example: the help for |vim.paste()| is generated from a docstring decorating -vim.paste in src/nvim/lua/vim.lua like this: > +vim.paste in runtime/lua/vim/_editor.lua like this: > --- Paste handler, invoked by |nvim_paste()| when a conforming UI --- (such as the |TUI|) pastes text into the editor. diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt index 19db3158be..32936a7ee6 100644 --- a/runtime/doc/diagnostic.txt +++ b/runtime/doc/diagnostic.txt @@ -39,16 +39,18 @@ modify the diagnostics for a buffer (e.g. |vim.diagnostic.set()|) then it requires a namespace. *diagnostic-structure* -A diagnostic is a Lua table with the following keys: +A diagnostic is a Lua table with the following keys. Required keys are +indicated with (*): bufnr: Buffer number - lnum: The starting line of the diagnostic + lnum(*): The starting line of the diagnostic end_lnum: The final line of the diagnostic - col: The starting column of the diagnostic + col(*): The starting column of the diagnostic end_col: The final column of the diagnostic severity: The severity of the diagnostic |vim.diagnostic.severity| - message: The diagnostic text + message(*): The diagnostic text source: The source of the diagnostic + code: The diagnostic code user_data: Arbitrary data plugins or users can add Diagnostics use the same indexing as the rest of the Nvim API (i.e. 0-based @@ -72,7 +74,7 @@ Functions that take a severity as an optional parameter (e.g. 2. A table with a "min" or "max" key (or both): > - vim.diagnostic.get(0, { severity = {min=vim.diagnostic.severity.WARN}) + vim.diagnostic.get(0, { severity = {min=vim.diagnostic.severity.WARN} }) The latter form allows users to specify a range of severities. @@ -326,11 +328,11 @@ config({opts}, {namespace}) *vim.diagnostic.config()* Note: Each of the configuration options below accepts one of the following: - • `false` : Disable this feature - • `true` : Enable this feature, use default settings. - • `table` : Enable this feature with overrides. Use an + • `false`: Disable this feature + • `true`: Enable this feature, use default settings. + • `table`: Enable this feature with overrides. Use an empty table to use default values. - • `function` : Function with signature (namespace, bufnr) + • `function`: Function with signature (namespace, bufnr) that returns any of the above. Parameters: ~ diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt index abe99102ee..9c5792dd43 100644 --- a/runtime/doc/diff.txt +++ b/runtime/doc/diff.txt @@ -371,13 +371,13 @@ Example (this does almost the same as 'diffexpr' being empty): > function MyDiff() let opt = "" if &diffopt =~ "icase" - let opt = opt . "-i " + let opt = opt .. "-i " endif if &diffopt =~ "iwhite" - let opt = opt . "-b " + let opt = opt .. "-b " endif - silent execute "!diff -a --binary " . opt . v:fname_in . " " . v:fname_new . - \ " > " . v:fname_out + silent execute "!diff -a --binary " .. opt .. v:fname_in .. " " .. v:fname_new .. + \ " > " .. v:fname_out redraw! endfunction @@ -427,8 +427,8 @@ Example (this does the same as 'patchexpr' being empty): > set patchexpr=MyPatch() function MyPatch() - :call system("patch -o " . v:fname_out . " " . v:fname_in . - \ " < " . v:fname_diff) + :call system("patch -o " .. v:fname_out .. " " .. v:fname_in .. + \ " < " .. v:fname_diff) endfunction Make sure that using the "patch" program doesn't have unwanted side effects. diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt index 3d0287b0cd..1cc8c21462 100644 --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -196,7 +196,7 @@ If you want to keep the changed buffer without saving it, switch on the Edit {file} always. Discard any changes to the current buffer. Also see |++opt| and |+cmd|. - + *:edit_#* *:e#* :e[dit] [++opt] [+cmd] #[count] Edit the [count]th buffer (as shown by |:files|). This command does the same as [count] CTRL-^. But ":e @@ -356,7 +356,7 @@ as a wildcard when "[" is in the 'isfname' option. A simple way to avoid this is to use "path\[[]abc]", this matches the file "path\[abc]". *starstar-wildcard* -Expanding "**" is possible on Unix, Win32, Mac OS/X and a few other systems. +Expanding "**" is possible on Unix, Win32, macOS and a few other systems. This allows searching a directory tree. This goes up to 100 directories deep. Note there are some commands where this works slightly differently, see |file-searching|. @@ -411,9 +411,9 @@ does apply like to other wildcards. Environment variables in the expression are expanded when evaluating the expression, thus this works: > - :e `=$HOME . '/.vimrc'` + :e `=$HOME .. '/.vimrc'` This does not work, $HOME is inside a string and used literally: > - :e `='$HOME' . '/.vimrc'` + :e `='$HOME' .. '/.vimrc'` If the expression returns a string then names are to be separated with line breaks. When the result is a |List| then each item is used as a name. Line @@ -1450,6 +1450,11 @@ If you don't get warned often enough you can use the following command. if it exists now. Once a file has been checked the timestamp is reset, you will not be warned again. + Syntax highlighting, marks, diff status, + 'fileencoding', 'fileformat' and 'binary' options + are not changed. See |v:fcs_choice| to reload these + too (for example, if a code formatting tools has + changed the file). :[N]checkt[ime] {filename} :[N]checkt[ime] [N] @@ -1490,7 +1495,7 @@ which version of the file you want to keep. The accuracy of the time check depends on the filesystem. On Unix it is usually sub-second. With old file sytems and on MS-Windows it is normally one -second. Use has('nanotime') check if sub-second time stamp checks are +second. Use `has('nanotime')` to check if sub-second time stamp checks are available. There is one situation where you get the message while there is nothing wrong: @@ -1570,10 +1575,8 @@ There are three different types of searching: /u/user_x/include < Note: If your 'path' setting includes a non-existing directory, Vim will - skip the non-existing directory, but continues searching in the parent of - the non-existing directory if upwards searching is used. E.g. when - searching "../include" and that doesn't exist, and upward searching is - used, also searches in "..". + skip the non-existing directory, and also does not search in the parent of + the non-existing directory if upwards searching is used. 3) Combined up/downward search: If Vim's current path is /u/user_x/work/release and you do > diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fc788fba59..ca2334500c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -402,7 +402,7 @@ It is also possible to put remaining items in a List variable: > :for [i, j; rest] in listlist : call Doit(i, j) : if !empty(rest) - : echo "remainder: " . string(rest) + : echo "remainder: " .. string(rest) : endif :endfor @@ -430,11 +430,11 @@ Functions that are useful with a List: > :let list = split("a b c") " create list from items in a string :let string = join(list, ', ') " create string from list items :let s = string(list) " String representation of list - :call map(list, '">> " . v:val') " prepend ">> " to each item + :call map(list, '">> " .. v:val') " prepend ">> " to each item Don't forget that a combination of features can make things simple. For example, to add up all the numbers in a list: > - :exe 'let sum = ' . join(nrlist, '+') + :exe 'let sum = ' .. join(nrlist, '+') 1.4 Dictionaries ~ @@ -496,7 +496,7 @@ turn the Dictionary into a List and pass it to |:for|. Most often you want to loop over the keys, using the |keys()| function: > :for key in keys(mydict) - : echo key . ': ' . mydict[key] + : echo key .. ': ' .. mydict[key] :endfor The List of keys is unsorted. You may want to sort them first: > @@ -504,13 +504,13 @@ The List of keys is unsorted. You may want to sort them first: > To loop over the values use the |values()| function: > :for v in values(mydict) - : echo "value: " . v + : echo "value: " .. v :endfor If you want both the key and the value use the |items()| function. It returns a List in which each item is a List with two items, the key and the value: > :for [key, value] in items(mydict) - : echo key . ': ' . value + : echo key .. ': ' .. value :endfor @@ -605,7 +605,7 @@ Functions that can be used with a Dictionary: > :let small = min(dict) " minimum value in dict :let xs = count(dict, 'x') " count nr of times 'x' appears in dict :let s = string(dict) " String representation of dict - :call map(dict, '">> " . v:val') " prepend ">> " to each item + :call map(dict, '">> " .. v:val') " prepend ">> " to each item 1.5 Blobs ~ @@ -840,7 +840,7 @@ Example: > All expressions within one level are parsed from left to right. -expr1 *expr1* *trinary* *E109* +expr1 *expr1* *ternary* *E109* ----- expr2 ? expr1 : expr1 @@ -1362,7 +1362,7 @@ option *expr-option* *E112* *E113* &l:option local option value Examples: > - echo "tabstop is " . &tabstop + echo "tabstop is " .. &tabstop if &insertmode Any option name can be used here. See |options|. When using the local value @@ -1637,7 +1637,7 @@ maintain a counter: > echo "script executed for the first time" else let s:counter = s:counter + 1 - echo "script executed " . s:counter . " times now" + echo "script executed " .. s:counter .. " times now" endif Note that this means that filetype plugins don't get a different set of script @@ -1651,6 +1651,7 @@ Some variables can be set by the user, but the type cannot be changed. *v:argv* *argv-variable* v:argv The command line arguments Vim was invoked with. This is a list of strings. The first item is the Vim command. + See |v:progpath| for the command with full path. *v:beval_col* *beval_col-variable* v:beval_col The number of the column, over which the mouse pointer is. @@ -1736,7 +1737,7 @@ v:completed_item *v:count* *count-variable* v:count The count given for the last Normal mode command. Can be used to get the count before a mapping. Read-only. Example: > - :map _x :<C-U>echo "the count is " . v:count<CR> + :map _x :<C-U>echo "the count is " .. v:count<CR> < Note: The <C-U> is required to remove the line range that you get when typing ':' after a count. When there are two counts, as in "3d2w", they are multiplied, @@ -1882,6 +1883,11 @@ v:fcs_choice What should happen after a |FileChangedShell| event was do with the affected buffer: reload Reload the buffer (does not work if the file was deleted). + edit Reload the buffer and detect the + values for options such as + 'fileformat', 'fileencoding', 'binary' + (does not work if the file was + deleted). ask Ask the user what to do, as if there was no autocommand. Except that when only the timestamp changed nothing @@ -2022,6 +2028,9 @@ v:null Special value used to put "null" in JSON and NIL in msgpack. used as a String (e.g. in |expr5| with string concatenation operator) and to zero when used as a Number (e.g. in |expr5| or |expr7| when used with numeric operators). Read-only. + In some places `v:null` can be used for a List, Dict, etc. + that is not set. That is slightly different than an empty + List, Dict, etc. *v:numbermax* *numbermax-variable* v:numbermax Maximum value of a number. @@ -2526,9 +2535,9 @@ Example: > : echohl Title : echo a:title : echohl None - : echo a:0 . " items:" + : echo a:0 .. " items:" : for s in a:000 - : echon ' ' . s + : echon ' ' .. s : endfor :endfunction @@ -2567,7 +2576,7 @@ This function can then be called with: > this works: *function-range-example* > :function Mynumber(arg) - : echo line(".") . " " . a:arg + : echo line(".") .. " " .. a:arg :endfunction :1,5call Mynumber(getline(".")) < @@ -2578,7 +2587,7 @@ This function can then be called with: > Example of a function that handles the range itself: > :function Cont() range - : execute (a:firstline + 1) . "," . a:lastline . 's/^/\t\\ ' + : execute (a:firstline + 1) .. "," .. a:lastline .. 's/^/\t\\ ' :endfunction :4,8call Cont() < @@ -2740,7 +2749,7 @@ This does NOT work: > This cannot be used to add an item to a |List|. This cannot be used to set a byte in a String. You can do that like this: > - :let var = var[0:2] . 'X' . var[4:] + :let var = var[0:2] .. 'X' .. var[4:] < When {var-name} is a |Blob| then {idx} can be the length of the blob, in which case one byte is appended. @@ -2802,7 +2811,7 @@ This does NOT work: > is just like using the |:set| command: both the local value and the global value are changed. Example: > - :let &path = &path . ',/usr/local/include' + :let &path = &path .. ',/usr/local/include' :let &{option-name} .= {expr1} For a string option: Append {expr1} to the value. @@ -3057,14 +3066,17 @@ text... opposite of |:lockvar|. :if {expr1} *:if* *:end* *:endif* *:en* *E171* *E579* *E580* -:en[dif] Execute the commands until the next matching ":else" - or ":endif" if {expr1} evaluates to non-zero. +:en[dif] Execute the commands until the next matching `:else` + or `:endif` if {expr1} evaluates to non-zero. + Although the short forms work, it is recommended to + always use `:endif` to avoid confusion and to make + auto-indenting work properly. From Vim version 4.5 until 5.0, every Ex command in - between the ":if" and ":endif" is ignored. These two + between the `:if` and `:endif` is ignored. These two commands were just to allow for future expansions in a backward compatible way. Nesting was allowed. Note - that any ":else" or ":elseif" was ignored, the "else" + that any `:else` or `:elseif` was ignored, the `else` part was not executed either. You can use this to remain compatible with older @@ -3073,32 +3085,32 @@ text... : version-5-specific-commands :endif < The commands still need to be parsed to find the - "endif". Sometimes an older Vim has a problem with a - new command. For example, ":silent" is recognized as - a ":substitute" command. In that case ":execute" can + `endif`. Sometimes an older Vim has a problem with a + new command. For example, `:silent` is recognized as + a `:substitute` command. In that case `:execute` can avoid problems: > :if version >= 600 : execute "silent 1,$delete" :endif < - NOTE: The ":append" and ":insert" commands don't work - properly in between ":if" and ":endif". + NOTE: The `:append` and `:insert` commands don't work + properly in between `:if` and `:endif`. *:else* *:el* *E581* *E583* -:el[se] Execute the commands until the next matching ":else" - or ":endif" if they previously were not being +:el[se] Execute the commands until the next matching `:else` + or `:endif` if they previously were not being executed. *:elseif* *:elsei* *E582* *E584* -:elsei[f] {expr1} Short for ":else" ":if", with the addition that there - is no extra ":endif". +:elsei[f] {expr1} Short for `:else` `:if`, with the addition that there + is no extra `:endif`. :wh[ile] {expr1} *:while* *:endwhile* *:wh* *:endw* *E170* *E585* *E588* *E733* -:endw[hile] Repeat the commands between ":while" and ":endwhile", +:endw[hile] Repeat the commands between `:while` and `:endwhile`, as long as {expr1} evaluates to non-zero. When an error is detected from a command inside the - loop, execution continues after the "endwhile". + loop, execution continues after the `endwhile`. Example: > :let lnum = 1 :while lnum <= line("$") @@ -3106,16 +3118,16 @@ text... :let lnum = lnum + 1 :endwhile < - NOTE: The ":append" and ":insert" commands don't work - properly inside a ":while" and ":for" loop. + NOTE: The `:append` and `:insert` commands don't work + properly inside a `:while` and `:for` loop. :for {var} in {object} *:for* *E690* *E732* :endfo[r] *:endfo* *:endfor* - Repeat the commands between ":for" and ":endfor" for + Repeat the commands between `:for` and `:endfor` for each item in {object}. {object} can be a |List| or a |Blob|. Variable {var} is set to the value of each item. When an error is detected for a command inside - the loop, execution continues after the "endfor". + the loop, execution continues after the `endfor`. Changing {object} inside the loop affects what items are used. Make a copy if this is unwanted: > :for item in copy(mylist) @@ -3139,7 +3151,7 @@ text... :for [{var1}, {var2}, ...] in {listlist} :endfo[r] - Like ":for" above, but each item in {listlist} must be + Like `:for` above, but each item in {listlist} must be a list, of which each item is assigned to {var1}, {var2}, etc. Example: > :for [lnum, col] in [[1, 3], [2, 5], [3, 8]] @@ -3147,38 +3159,39 @@ text... :endfor < *:continue* *:con* *E586* -:con[tinue] When used inside a ":while" or ":for" loop, jumps back +:con[tinue] When used inside a `:while` or `:for` loop, jumps back to the start of the loop. - If it is used after a |:try| inside the loop but - before the matching |:finally| (if present), the - commands following the ":finally" up to the matching - |:endtry| are executed first. This process applies to - all nested ":try"s inside the loop. The outermost - ":endtry" then jumps back to the start of the loop. + + If it is used after a `:try` inside the loop but + before the matching `:finally` (if present), the + commands following the `:finally` up to the matching + `:endtry` are executed first. This process applies to + all nested `:try`s inside the loop. The outermost + `:endtry` then jumps back to the start of the loop. *:break* *:brea* *E587* -:brea[k] When used inside a ":while" or ":for" loop, skips to - the command after the matching ":endwhile" or - ":endfor". - If it is used after a |:try| inside the loop but - before the matching |:finally| (if present), the - commands following the ":finally" up to the matching - |:endtry| are executed first. This process applies to - all nested ":try"s inside the loop. The outermost - ":endtry" then jumps to the command after the loop. +:brea[k] When used inside a `:while` or `:for` loop, skips to + the command after the matching `:endwhile` or + `:endfor`. + If it is used after a `:try` inside the loop but + before the matching `:finally` (if present), the + commands following the `:finally` up to the matching + `:endtry` are executed first. This process applies to + all nested `:try`s inside the loop. The outermost + `:endtry` then jumps to the command after the loop. :try *:try* *:endt* *:endtry* *E600* *E601* *E602* :endt[ry] Change the error handling for the commands between - ":try" and ":endtry" including everything being - executed across ":source" commands, function calls, + `:try` and `:endtry` including everything being + executed across `:source` commands, function calls, or autocommand invocations. When an error or interrupt is detected and there is - a |:finally| command following, execution continues - after the ":finally". Otherwise, or when the - ":endtry" is reached thereafter, the next - (dynamically) surrounding ":try" is checked for - a corresponding ":finally" etc. Then the script + a `:finally` command following, execution continues + after the `:finally`. Otherwise, or when the + `:endtry` is reached thereafter, the next + (dynamically) surrounding `:try` is checked for + a corresponding `:finally` etc. Then the script processing is terminated. Whether a function definition has an "abort" argument does not matter. Example: > @@ -3186,9 +3199,9 @@ text... echomsg "not reached" < Moreover, an error or interrupt (dynamically) inside - ":try" and ":endtry" is converted to an exception. It - can be caught as if it were thrown by a |:throw| - command (see |:catch|). In this case, the script + `:try` and `:endtry` is converted to an exception. It + can be caught as if it were thrown by a `:throw` + command (see `:catch`). In this case, the script processing is not terminated. The value "Vim:Interrupt" is used for an interrupt @@ -3204,22 +3217,22 @@ text... try | edit | catch /^Vim(edit):E\d\+/ | echo "error" | endtry < *:cat* *:catch* *E603* *E604* *E605* -:cat[ch] /{pattern}/ The following commands until the next |:catch|, - |:finally|, or |:endtry| that belongs to the same - |:try| as the ":catch" are executed when an exception +:cat[ch] /{pattern}/ The following commands until the next `:catch`, + `:finally`, or `:endtry` that belongs to the same + `:try` as the `:catch` are executed when an exception matching {pattern} is being thrown and has not yet - been caught by a previous ":catch". Otherwise, these + been caught by a previous `:catch`. Otherwise, these commands are skipped. When {pattern} is omitted all errors are caught. Examples: > - :catch /^Vim:Interrupt$/ " catch interrupts (CTRL-C) - :catch /^Vim\%((\a\+)\)\=:E/ " catch all Vim errors - :catch /^Vim\%((\a\+)\)\=:/ " catch errors and interrupts - :catch /^Vim(write):/ " catch all errors in :write - :catch /^Vim\%((\a\+)\)\=:E123/ " catch error E123 - :catch /my-exception/ " catch user exception - :catch /.*/ " catch everything - :catch " same as /.*/ + :catch /^Vim:Interrupt$/ " catch interrupts (CTRL-C) + :catch /^Vim\%((\a\+)\)\=:E/ " catch all Vim errors + :catch /^Vim\%((\a\+)\)\=:/ " catch errors and interrupts + :catch /^Vim(write):/ " catch all errors in :write + :catch /^Vim\%((\a\+)\)\=:E123:/ " catch error E123 + :catch /my-exception/ " catch user exception + :catch /.*/ " catch everything + :catch " same as /.*/ < Another character can be used instead of / around the {pattern}, so long as it does not have a special @@ -3232,27 +3245,27 @@ text... locales. *:fina* *:finally* *E606* *E607* -:fina[lly] The following commands until the matching |:endtry| +:fina[lly] The following commands until the matching `:endtry` are executed whenever the part between the matching - |:try| and the ":finally" is left: either by falling - through to the ":finally" or by a |:continue|, - |:break|, |:finish|, or |:return|, or by an error or - interrupt or exception (see |:throw|). + `:try` and the `:finally` is left: either by falling + through to the `:finally` or by a `:continue`, + `:break`, `:finish`, or `:return`, or by an error or + interrupt or exception (see `:throw`). *:th* *:throw* *E608* :th[row] {expr1} The {expr1} is evaluated and thrown as an exception. - If the ":throw" is used after a |:try| but before the - first corresponding |:catch|, commands are skipped - until the first ":catch" matching {expr1} is reached. - If there is no such ":catch" or if the ":throw" is - used after a ":catch" but before the |:finally|, the - commands following the ":finally" (if present) up to - the matching |:endtry| are executed. If the ":throw" - is after the ":finally", commands up to the ":endtry" - are skipped. At the ":endtry", this process applies - again for the next dynamically surrounding ":try" + If the `:throw` is used after a `:try` but before the + first corresponding `:catch`, commands are skipped + until the first `:catch` matching {expr1} is reached. + If there is no such `:catch` or if the `:throw` is + used after a `:catch` but before the `:finally`, the + commands following the `:finally` (if present) up to + the matching `:endtry` are executed. If the `:throw` + is after the `:finally`, commands up to the `:endtry` + are skipped. At the `:endtry`, this process applies + again for the next dynamically surrounding `:try` (which may be found in a calling function or sourcing - script), until a matching ":catch" has been found. + script), until a matching `:catch` has been found. If the exception is not caught, the command processing is terminated. Example: > @@ -3267,7 +3280,7 @@ text... Also see |:comment|. Use "\n" to start a new line. Use "\r" to move the cursor to the first column. - Uses the highlighting set by the |:echohl| command. + Uses the highlighting set by the `:echohl` command. Cannot be followed by a comment. Example: > :echo "the value of 'shell' is" &shell @@ -3276,9 +3289,9 @@ text... And since Vim mostly postpones redrawing until it's finished with a sequence of commands this happens quite often. To avoid that a command from before the - ":echo" causes a redraw afterwards (redraws are often + `:echo` causes a redraw afterwards (redraws are often postponed until you type something), force a redraw - with the |:redraw| command. Example: > + with the `:redraw` command. Example: > :new | redraw | echo "there is a new window" < *:echo-self-refer* When printing nested containers echo prints second @@ -3297,13 +3310,13 @@ text... *:echon* :echon {expr1} .. Echoes each {expr1}, without anything added. Also see |:comment|. - Uses the highlighting set by the |:echohl| command. + Uses the highlighting set by the `:echohl` command. Cannot be followed by a comment. Example: > :echon "the value of 'shell' is " &shell < - Note the difference between using ":echo", which is a - Vim command, and ":!echo", which is an external shell + Note the difference between using `:echo`, which is a + Vim command, and `:!echo`, which is an external shell command: > :!echo % --> filename < The arguments of ":!" are expanded, see |:_%|. > @@ -3319,8 +3332,8 @@ text... *:echoh* *:echohl* :echoh[l] {name} Use the highlight group {name} for the following - |:echo|, |:echon| and |:echomsg| commands. Also used - for the |input()| prompt. Example: > + `:echo`, `:echon` and `:echomsg` commands. Also used + for the `input()` prompt. Example: > :echohl WarningMsg | echo "Don't panic!" | echohl None < Don't forget to set the group back to "None", otherwise all following echo's will be highlighted. @@ -3329,14 +3342,14 @@ text... :echom[sg] {expr1} .. Echo the expression(s) as a true message, saving the message in the |message-history|. Spaces are placed between the arguments as with the - |:echo| command. But unprintable characters are + `:echo` command. But unprintable characters are displayed, not interpreted. - The parsing works slightly different from |:echo|, - more like |:execute|. All the expressions are first + The parsing works slightly different from `:echo`, + more like `:execute`. All the expressions are first evaluated and concatenated before echoing anything. If expressions does not evaluate to a Number or String, string() is used to turn it into a string. - Uses the highlighting set by the |:echohl| command. + Uses the highlighting set by the `:echohl` command. Example: > :echomsg "It's a Zizzer Zazzer Zuzz, as you can plainly see." < See |:echo-redraw| to avoid the message disappearing @@ -3346,12 +3359,12 @@ text... message in the |message-history|. When used in a script or function the line number will be added. Spaces are placed between the arguments as with the - |:echomsg| command. When used inside a try conditional, + `:echomsg` command. When used inside a try conditional, the message is raised as an error exception instead (see |try-echoerr|). Example: > :echoerr "This script just failed!" -< If you just want a highlighted message use |:echohl|. +< If you just want a highlighted message use `:echohl`. And to get a beep: > :exe "normal \<Esc>" < @@ -3656,7 +3669,7 @@ exception most recently caught as long it is not finished. :function! Caught() : if v:exception != "" - : echo 'Caught "' . v:exception . '" in ' . v:throwpoint + : echo 'Caught "' .. v:exception .. '" in ' .. v:throwpoint : else : echo 'Nothing caught' : endif @@ -4059,8 +4072,8 @@ a script in order to catch unexpected things. :catch /^Vim:Interrupt$/ : echo "Script interrupted" :catch /.*/ - : echo "Internal error (" . v:exception . ")" - : echo " - occurred at " . v:throwpoint + : echo "Internal error (" .. v:exception .. ")" + : echo " - occurred at " .. v:throwpoint :endtry :" end of script @@ -4256,7 +4269,7 @@ parentheses can be cut out from |v:exception| with the ":substitute" command. :function! CheckRange(a, func) : if a:a < 0 - : throw "EXCEPT:MATHERR:RANGE(" . a:func . ")" + : throw "EXCEPT:MATHERR:RANGE(" .. a:func .. ")" : endif :endfunction : @@ -4283,7 +4296,7 @@ parentheses can be cut out from |v:exception| with the ":substitute" command. : try : execute "write" fnameescape(a:file) : catch /^Vim(write):/ - : throw "EXCEPT:IO(" . getcwd() . ", " . a:file . "):WRITEERR" + : throw "EXCEPT:IO(" .. getcwd() .. ", " .. a:file .. "):WRITEERR" : endtry :endfunction : @@ -4302,9 +4315,9 @@ parentheses can be cut out from |v:exception| with the ":substitute" command. : let dir = substitute(v:exception, '.*(\(.\+\),\s*.\+).*', '\1', "") : let file = substitute(v:exception, '.*(.\+,\s*\(.\+\)).*', '\1', "") : if file !~ '^/' - : let file = dir . "/" . file + : let file = dir .. "/" .. file : endif - : echo 'I/O error for "' . file . '"' + : echo 'I/O error for "' .. file .. '"' : :catch /^EXCEPT/ : echo "Unspecified error" @@ -4372,7 +4385,7 @@ clauses, however, is executed. : echo "inner finally" : endtry :catch - : echo 'outer catch-all caught "' . v:exception . '"' + : echo 'outer catch-all caught "' .. v:exception .. '"' : finally : echo "outer finally" :endtry @@ -4434,7 +4447,7 @@ Printing in Binary ~ : let n = a:nr : let r = "" : while n - : let r = '01'[n % 2] . r + : let r = '01'[n % 2] .. r : let n = n / 2 : endwhile : return r @@ -4445,7 +4458,7 @@ Printing in Binary ~ :func String2Bin(str) : let out = '' : for ix in range(strlen(a:str)) - : let out = out . '-' . Nr2Bin(char2nr(a:str[ix])) + : let out = out .. '-' .. Nr2Bin(char2nr(a:str[ix])) : endfor : return out[1:] :endfunc diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 5486c87af9..bd3acfcac7 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -140,7 +140,8 @@ variables can be used to overrule the filetype used for certain extensions: *.asm g:asmsyntax |ft-asm-syntax| *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax| *.bas g:filetype_bas |ft-basic-syntax| - *.fs g:filetype_fs |ft-forth-syntax| + *.frm g:filetype_frm |ft-form-syntax| + *.fs g:filetype_fs |ft-forth-syntax| *.i g:filetype_i |ft-progress-syntax| *.inc g:filetype_inc *.m g:filetype_m |ft-mathematica-syntax| diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt index 8bc47a3b10..9e3d78faff 100644 --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -497,7 +497,7 @@ Note the use of backslashes to avoid some characters to be interpreted by the :function MyFoldText() : let line = getline(v:foldstart) : let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g') - : return v:folddashes . sub + : return v:folddashes .. sub :endfunction Evaluating 'foldtext' is done in the |sandbox|. The current window is set to diff --git a/runtime/doc/ft_raku.txt b/runtime/doc/ft_raku.txt index 00b140ee9c..3d1179ed4e 100644 --- a/runtime/doc/ft_raku.txt +++ b/runtime/doc/ft_raku.txt @@ -47,20 +47,20 @@ Numbers, subscripts and superscripts are available with 's' and 'S': But some don't come defined by default. Those are digraph definitions you can add in your ~/.vimrc file. > - exec 'digraph \\ '.char2nr('∖') - exec 'digraph \< '.char2nr('≼') - exec 'digraph \> '.char2nr('≽') - exec 'digraph (L '.char2nr('⊈') - exec 'digraph )L '.char2nr('⊉') - exec 'digraph (/ '.char2nr('⊄') - exec 'digraph )/ '.char2nr('⊅') - exec 'digraph )/ '.char2nr('⊅') - exec 'digraph U+ '.char2nr('⊎') - exec 'digraph 0- '.char2nr('⊖') + exec 'digraph \\ ' .. char2nr('∖') + exec 'digraph \< ' .. char2nr('≼') + exec 'digraph \> ' .. char2nr('≽') + exec 'digraph (L ' .. char2nr('⊈') + exec 'digraph )L ' .. char2nr('⊉') + exec 'digraph (/ ' .. char2nr('⊄') + exec 'digraph )/ ' .. char2nr('⊅') + exec 'digraph )/ ' .. char2nr('⊅') + exec 'digraph U+ ' .. char2nr('⊎') + exec 'digraph 0- ' .. char2nr('⊖') " Euler's constant - exec 'digraph ne '.char2nr('𝑒') + exec 'digraph ne ' .. char2nr('𝑒') " Raku's atomic operations marker - exec 'digraph @@ '.char2nr('⚛') + exec 'digraph @@ ' .. char2nr('⚛') Alternatively, you can write Insert mode abbreviations that convert ASCII- based operators into their single-character Unicode equivalent. > diff --git a/runtime/doc/ft_rust.txt b/runtime/doc/ft_rust.txt index ff2e0ca56f..5c8782ec7a 100644 --- a/runtime/doc/ft_rust.txt +++ b/runtime/doc/ft_rust.txt @@ -26,7 +26,7 @@ behavior of the plugin. g:rustc_path~ Set this option to the path to rustc for use in the |:RustRun| and |:RustExpand| commands. If unset, "rustc" will be located in $PATH: > - let g:rustc_path = $HOME."/bin/rustc" + let g:rustc_path = $HOME .. "/bin/rustc" < *g:rustc_makeprg_no_percent* @@ -87,7 +87,7 @@ g:rust_bang_comment_leader~ g:ftplugin_rust_source_path~ Set this option to a path that should be prepended to 'path' for Rust source files: > - let g:ftplugin_rust_source_path = $HOME.'/dev/rust' + let g:ftplugin_rust_source_path = $HOME .. '/dev/rust' < *g:rustfmt_command* diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt index 53a99a9e1d..fccbbce17f 100644 --- a/runtime/doc/ft_sql.txt +++ b/runtime/doc/ft_sql.txt @@ -109,8 +109,8 @@ must be configurable. The filetype plugin attempts to define many of the standard objects, plus many additional ones. In order to make this as flexible as possible, you can override the list of objects from within your |vimrc| with the following: > - let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' . - \ ',schema,service,publication,database,datatype,domain' . + let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' .. + \ ',schema,service,publication,database,datatype,domain' .. \ ',index,subscription,synchronization,view,variable' The following |Normal| mode and |Visual| mode maps have been created which use @@ -131,10 +131,10 @@ Repeatedly pressing ]} will cycle through each of these create statements: > create index i1 on t1 (c1); The default setting for g:ftplugin_sql_objects is: > - let g:ftplugin_sql_objects = 'function,procedure,event,' . - \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' . - \ 'table,trigger' . - \ ',schema,service,publication,database,datatype,domain' . + let g:ftplugin_sql_objects = 'function,procedure,event,' .. + \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' .. + \ 'table,trigger' .. + \ ',schema,service,publication,database,datatype,domain' .. \ ',index,subscription,synchronization,view,variable' The above will also handle these cases: > diff --git a/runtime/doc/if_pyth.txt b/runtime/doc/if_pyth.txt index afdf039aa8..9b434e61d7 100644 --- a/runtime/doc/if_pyth.txt +++ b/runtime/doc/if_pyth.txt @@ -658,7 +658,7 @@ To see what version of Python is being used: > *has-pythonx* To check if `pyx*` functions and commands are available: > if has('pythonx') - echo 'pyx* commands are available. (Python ' . &pyx . ')' + echo 'pyx* commands are available. (Python ' .. &pyx .. ')' endif ============================================================================== diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index e3bc3d5437..572b4e3f93 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -353,6 +353,7 @@ tag char note action in Normal mode ~ register x] |Y| ["x]Y yank N lines [into register x]; synonym for "yy" + Note: Mapped to "y$" by default. |default-mappings| |ZZ| ZZ write if buffer changed and close window |ZQ| ZQ close window without writing |[| [{char} square bracket command (see |[| below) @@ -430,6 +431,7 @@ tag char note action in Normal mode ~ |<C-LeftMouse>| <C-LeftMouse> ":ta" to the keyword at the mouse click |<C-Right>| <C-Right> 1 same as "w" |<C-RightMouse>| <C-RightMouse> same as "CTRL-T" +|<C-Tab>| <C-Tab> same as "g<Tab>" |<Del>| ["x]<Del> 2 same as "x" |N<Del>| {count}<Del> remove the last digit from {count} |<Down>| <Down> 1 same as "j" @@ -576,7 +578,7 @@ tag command action in Normal mode ~ following the file name. |CTRL-W_gt| CTRL-W g t same as `gt`: go to next tab page |CTRL-W_gT| CTRL-W g T same as `gT`: go to previous tab page -|CTRL-W_g<Tab>| CTRL-W g <Tab> same as `g<Tab>` : go to last accessed tab +|CTRL-W_g<Tab>| CTRL-W g <Tab> same as |g<Tab>|: go to last accessed tab page |CTRL-W_h| CTRL-W h go to Nth left window (stop at first window) |CTRL-W_i| CTRL-W i split window and jump to declaration of diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index ae2b9c4418..d9aecfe4fd 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -269,8 +269,8 @@ start allow backspacing over the start position of insert; CTRL-W and When 'backspace' is empty, Vi compatible backspacing is used. You cannot backspace over autoindent, before column 1 or before where insert started. -For backwards compatibility the values "0", "1" and "2" are also allowed, see -|'backspace'|. +For backwards compatibility the values "0", "1", "2" and "3" are also allowed, +see |'backspace'|. If the 'backspace' option does contain "eol" and the cursor is in column 1 when one of the three keys is used, the current line is joined with the @@ -798,6 +798,7 @@ CTRL-X CTRL-K Search the files given with the 'dictionary' option the 'dictionary' option is empty. For suggestions where to find a list of words, see the 'dictionary' option. + 'ignorecase', 'smartcase' and 'infercase' apply. CTRL-K or CTRL-N Search forward for next matching keyword. This @@ -864,7 +865,7 @@ Groß): > else let res = [] let h = '' - for l in split(system('aiksaurus '.shellescape(a:base)), '\n') + for l in split(system('aiksaurus ' .. shellescape(a:base)), '\n') if l[:3] == '=== ' let h = substitute(l[4:], ' =*$', '', '') elseif l[0] =~ '\a' @@ -1199,7 +1200,7 @@ An example that completes the names of the months: > " find months matching with "a:base" let res = [] for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base + if m =~ '^' .. a:base call add(res, m) endif endfor @@ -1221,7 +1222,7 @@ The same, but now pretending searching for matches is slow: > else " find months matching with "a:base" for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base + if m =~ '^' .. a:base call complete_add(m) endif sleep 300m " simulate searching for next match diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index d717759444..a9ebcd27ae 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -355,8 +355,8 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method *lsp-handler-resolution* Handlers can be set by: -- Setting a field in |vim.lsp.handlers|. *vim.lsp.handlers* - |vim.lsp.handlers| is a global table that contains the default mapping of +- Setting a field in vim.lsp.handlers. *vim.lsp.handlers* + vim.lsp.handlers is a global table that contains the default mapping of |lsp-method| names to |lsp-handlers|. To override the handler for the `"textDocument/definition"` method: > @@ -563,7 +563,7 @@ buf_request_all({bufnr}, {method}, {params}, {callback}) Return: ~ (function) A function that will cancel all requests which - is the same as the one returned from `buf_request` . + is the same as the one returned from `buf_request`. *vim.lsp.buf_request_sync()* buf_request_sync({bufnr}, {method}, {params}, {timeout_ms}) @@ -600,9 +600,9 @@ client() *vim.lsp.client* {handler} is not specified, If one is not found there, then an error will occur. Returns: {status}, {[client_id]}. {status} is a boolean indicating if the - notification was successful. If it is `false` , then it + notification was successful. If it is `false`, then it will always be `false` (the client has shutdown). If - {status} is `true` , the function returns {request_id} as + {status} is `true`, the function returns {request_id} as the second result. You can use this with `client.cancel_request(request_id)` to cancel the request. • request_sync(method, params, timeout_ms, bufnr) Sends a @@ -612,13 +612,13 @@ client() *vim.lsp.client* `err` and `result` come from the |lsp-handler|. On timeout, cancel or error, returns `(nil, err)` where `err` is a string describing the failure reason. If the request - was unsuccessful returns `nil` . + was unsuccessful returns `nil`. • notify(method, params) Sends a notification to an LSP server. Returns: a boolean to indicate if the notification was successful. If it is false, then it will always be false (the client has shutdown). • cancel_request(id) Cancels a request with a given request - id. Returns: same as `notify()` . + id. Returns: same as `notify()`. • stop([force]) Stops a client, optionally with force. By default, it will just ask the server to shutdown without force. If you request to stop a client which has @@ -639,14 +639,14 @@ client() *vim.lsp.client* interaction with the client. See |vim.lsp.rpc.start()|. • {offset_encoding} (string): The encoding used for communicating with the server. You can modify this in the - `config` 's `on_init` method before text is sent to the + `config`'s `on_init` method before text is sent to the server. • {handlers} (table): The handlers used by the client as described in |lsp-handler|. • {requests} (table): The current pending requests in flight to the server. Entries are key-value pairs with the key being the request ID while the value is a table with - `type` , `bufnr` , and `method` key-value pairs. `type` is + `type`, `bufnr`, and `method` key-value pairs. `type` is either "pending" for an active request, or "cancel" for a cancel request. • {config} (table): copy of the table that was passed by the @@ -655,7 +655,7 @@ client() *vim.lsp.client* sent on `initialize` describing the server's capabilities. • {resolved_capabilities} (table): Normalized table of capabilities that we have detected based on the initialize - response from the server in `server_capabilities` . + response from the server in `server_capabilities`. client_is_stopped({client_id}) *vim.lsp.client_is_stopped()* Checks whether a client is stopped. @@ -775,7 +775,7 @@ start_client({config}) *vim.lsp.start_client()* initiates the LSP client. {cmd_cwd} (string, default=|getcwd()|) Directory to launch the `cmd` - process. Not related to `root_dir` . + 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 @@ -800,15 +800,15 @@ start_client({config}) *vim.lsp.start_client()* its result. • Note: To send an empty dictionary use - `{[vim.type_idx]=vim.types.dictionary}` - , else it will be encoded as an + `{[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 + `workspace/configuration`. Keys are case-sensitive. {commands} table Table that maps string of clientside commands to user-defined @@ -821,7 +821,7 @@ start_client({config}) *vim.lsp.start_client()* action, code lenses, ...) triggers the command. {init_options} Values to pass in the initialization - request as `initializationOptions` . + request as `initializationOptions`. See `initialize` in the LSP spec. {name} (string, default=client-id) Name in log messages. @@ -976,7 +976,7 @@ code_action({context}) *vim.lsp.buf.code_action()* • only: (string|nil) LSP `CodeActionKind` used to filter the code actions. Most language servers support values like `refactor` or - `quickfix` . + `quickfix`. See also: ~ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction @@ -1007,7 +1007,7 @@ definition() *vim.lsp.buf.definition()* document_highlight() *vim.lsp.buf.document_highlight()* Send request to the server to resolve document highlights for the current text document position. This request can be - triggered by a key mapping or by events such as `CursorHold` , + triggered by a key mapping or by events such as `CursorHold`, e.g.: > autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() @@ -1124,7 +1124,7 @@ range_code_action({context}, {start_pos}, {end_pos}) • only: (string|nil) LSP `CodeActionKind` used to filter the code actions. Most language servers support values like - `refactor` or `quickfix` . + `refactor` or `quickfix`. {start_pos} ({number, number}, optional) mark-indexed position. Defaults to the start of the last visual selection. @@ -1246,8 +1246,8 @@ display({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.display()* Display the lenses using virtual text Parameters: ~ - {lenses} table of lenses to display ( `CodeLens[] | - null` ) + {lenses} table of lenses to display (`CodeLens[] | + null`) {bufnr} number {client_id} number @@ -1259,7 +1259,7 @@ get({bufnr}) *vim.lsp.codelens.get()* current buffer. Return: ~ - table ( `CodeLens[]` ) + table (`CodeLens[]`) *vim.lsp.codelens.on_codelens()* on_codelens({err}, {result}, {ctx}, {_}) @@ -1281,8 +1281,8 @@ save({lenses}, {bufnr}, {client_id}) *vim.lsp.codelens.save()* Store lenses for a specific buffer and client Parameters: ~ - {lenses} table of lenses to store ( `CodeLens[] | - null` ) + {lenses} table of lenses to store (`CodeLens[] | + null`) {bufnr} number {client_id} number @@ -1333,7 +1333,7 @@ Lua module: vim.lsp.util *lsp-util* *vim.lsp.util.apply_text_document_edit()* apply_text_document_edit({text_document_edit}, {index}, {offset_encoding}) - Applies a `TextDocumentEdit` , which is a list of changes to a + Applies a `TextDocumentEdit`, which is a list of changes to a single document. Parameters: ~ @@ -1360,7 +1360,7 @@ apply_text_edits({text_edits}, {bufnr}, {offset_encoding}) *vim.lsp.util.apply_workspace_edit()* apply_workspace_edit({workspace_edit}, {offset_encoding}) - Applies a `WorkspaceEdit` . + Applies a `WorkspaceEdit`. Parameters: ~ {workspace_edit} table `WorkspaceEdit` @@ -1408,13 +1408,13 @@ convert_input_to_markdown_lines({input}, {contents}) Converts any of `MarkedString` | `MarkedString[]` | `MarkupContent` into a list of lines containing valid markdown. Useful to populate the hover window for - `textDocument/hover` , for parsing the result of - `textDocument/signatureHelp` , and potentially others. + `textDocument/hover`, for parsing the result of + `textDocument/signatureHelp`, and potentially others. Parameters: ~ - {input} ( `MarkedString` | `MarkedString[]` | - `MarkupContent` ) - {contents} (table, optional, default `{}` ) List of + {input} (`MarkedString` | `MarkedString[]` | + `MarkupContent`) + {contents} (table, optional, default `{}`) List of strings to extend with converted lines Return: ~ @@ -1475,7 +1475,7 @@ jump_to_location({location}, {offset_encoding}) Jumps to a location. Parameters: ~ - {location} table ( `Location` | `LocationLink` ) + {location} table (`Location`|`LocationLink`) {offset_encoding} string utf-8|utf-16|utf-32 (required) Return: ~ @@ -1491,8 +1491,8 @@ locations_to_items({locations}, {offset_encoding}) |setqflist()| or |setloclist()|. Parameters: ~ - {locations} table list of `Location` s or - `LocationLink` s + {locations} table list of `Location`s or + `LocationLink`s {offset_encoding} string offset_encoding for locations utf-8|utf-16|utf-32 @@ -1526,7 +1526,7 @@ make_floating_popup_options({width}, {height}, {opts}) • border (string or table) override `border` • focusable (string or table) override `focusable` - • zindex (string or table) override `zindex` , + • zindex (string or table) override `zindex`, defaults to 50 Return: ~ @@ -1566,7 +1566,7 @@ make_given_range_params({start_pos}, {end_pos}, {bufnr}, {offset_encoding}) Return: ~ { textDocument = { uri = `current_file_uri` }, range = { - start = `start_position` , end = `end_position` } } + start = `start_position`, end = `end_position` } } *vim.lsp.util.make_position_params()* make_position_params({window}, {offset_encoding}) @@ -1590,9 +1590,9 @@ make_position_params({window}, {offset_encoding}) make_range_params({window}, {offset_encoding}) Using the current position in the current buffer, creates an object that can be used as a building block for several LSP - requests, such as `textDocument/codeAction` , - `textDocument/colorPresentation` , - `textDocument/rangeFormatting` . + requests, such as `textDocument/codeAction`, + `textDocument/colorPresentation`, + `textDocument/rangeFormatting`. Parameters: ~ {window} (optional, number): window handle or 0 @@ -1603,7 +1603,7 @@ make_range_params({window}, {offset_encoding}) Return: ~ { textDocument = { uri = `current_file_uri` }, range = { - start = `current_position` , end = `current_position` } } + start = `current_position`, end = `current_position` } } *vim.lsp.util.make_text_document_params()* make_text_document_params({bufnr}) @@ -1657,8 +1657,8 @@ open_floating_preview({contents}, {syntax}, {opts}) closes the floating window • focusable: (boolean, default true) Make float focusable - • focus: (boolean, default true) If `true` , - and if {focusable} is also `true` , focus an + • focus: (boolean, default true) If `true`, + and if {focusable} is also `true`, focus an existing floating window with the same {focus_id} @@ -1757,7 +1757,7 @@ text_document_completion_list_to_complete_items({result}, {prefix}) Parameters: ~ {result} The result of a `textDocument/completion` call, e.g. from |vim.lsp.buf.completion()|, which may - be one of `CompletionItem[]` , `CompletionList` + be one of `CompletionItem[]`, `CompletionList` or `null` {prefix} (string) the prefix to filter the completion items diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 1a2d845281..93386ddfe9 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -568,6 +568,26 @@ Example: TCP echo-server *tcp-server* end) print('TCP echo-server listening on port: '..server:getsockname().port) + +Multithreading *lua-loop-threading* + +Plugins can perform work in separate (os-level) threads using the threading +APIs in luv, for instance `vim.loop.new_thread`. Note that every thread +gets its own separate lua interpreter state, with no access to lua globals +in the main thread. Neither can the state of the editor (buffers, windows, +etc) be directly accessed from threads. + +A subset of the `vim.*` API is available in threads. This includes: + +- `vim.loop` with a separate event loop per thread. +- `vim.mpack` and `vim.json` (useful for serializing messages between threads) +- `require` in threads can use lua packages from the global |lua-package-path| +- `print()` and `vim.inspect` +- `vim.diff` +- most utility functions in `vim.*` for working with pure lua values + like `vim.split`, `vim.tbl_*`, `vim.list_*`, and so on. +- `vim.is_thread()` returns true from a non-main thread. + ------------------------------------------------------------------------------ VIM.HIGHLIGHT *lua-highlight* @@ -595,13 +615,33 @@ vim.highlight.on_yank({opts}) *vim.highlight.on_yank()* - {on_visual} highlight when yanking visual selection (default `true`) - {event} event structure (default |v:event|) -vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclusive}) +vim.highlight.range({bufnr}, {ns}, {hlgroup}, {start}, {finish}, {opts}) *vim.highlight.range()* - Highlights the range between {start} and {finish} (tuples of {line,col}) - in buffer {bufnr} with the highlight group {higroup} using the namespace - {ns}. Optional arguments are the type of range (characterwise, linewise, - or blockwise, see |setreg|; default to characterwise) and whether the - range is inclusive (default false). + + Apply highlight group to range of text. + + Parameters: ~ + {bufnr} buffer number + {ns} namespace for highlights + {hlgroup} highlight group name + {start} starting position (tuple {line,col}) + {finish} finish position (tuple {line,col}) + {opts} optional parameters: + • `regtype`: type of range (characterwise, linewise, + or blockwise, see |setreg|), default `'v'` + • `inclusive`: range includes end position, default + `false` + • `priority`: priority of highlight, default + `vim.highlight.user` (see below) + +vim.highlight.priorities *vim.highlight.priorities* + + Table with default priorities used for highlighting: + • `syntax`: `50`, used for standard syntax highlighting + • `treesitter`: `100`, used for tree-sitter-based highlighting + • `diagnostics`: `150`, used for code analysis such as diagnostics + • `user`: `200`, used for user-triggered highlights such as LSP + document symbols or `on_yank` autocommands ------------------------------------------------------------------------------ VIM.REGEX *lua-regex* @@ -1043,7 +1083,7 @@ from within Lua. `vim.opt.wildignore = '*.o,*.a,__pycache__'` However, vim.opt also supports a more elegent way of setting - list-style options, but using lua tables: + list-style options by using lua tables: `vim.opt.wildignore = { '*.o', '*.a', '__pycache__' }` To replicate the behavior of |:set+=|, use: > @@ -1378,7 +1418,7 @@ deep_equal({a}, {b}) *vim.deep_equal()* {b} second value Return: ~ - `true` if values are equals, else `false` . + `true` if values are equals, else `false`. deepcopy({orig}) *vim.deepcopy()* Returns a deep copy of the given object. Non-table objects are @@ -1395,7 +1435,7 @@ deepcopy({orig}) *vim.deepcopy()* New table of copied keys and (nested) values. endswith({s}, {suffix}) *vim.endswith()* - Tests if `s` ends with `suffix` . + Tests if `s` ends with `suffix`. Parameters: ~ {s} (string) a string @@ -1499,7 +1539,7 @@ split({s}, {sep}, {kwargs}) *vim.split()* |vim.gsplit()| startswith({s}, {prefix}) *vim.startswith()* - Tests if `s` starts with `prefix` . + Tests if `s` starts with `prefix`. Parameters: ~ {s} (string) a string @@ -1516,7 +1556,7 @@ tbl_add_reverse_lookup({o}) *vim.tbl_add_reverse_lookup()* {o} table The table to add the reverse to. tbl_contains({t}, {value}) *vim.tbl_contains()* - Checks if a list-like (vector) table contains `value` . + Checks if a list-like (vector) table contains `value`. Parameters: ~ {t} Table to check @@ -1526,7 +1566,7 @@ tbl_contains({t}, {value}) *vim.tbl_contains()* true if `t` contains `value` tbl_count({t}) *vim.tbl_count()* - Counts the number of non-nil values in table `t` . + Counts the number of non-nil values in table `t`. > vim.tbl_count({ a=1, b=2 }) => 2 @@ -1611,7 +1651,7 @@ tbl_islist({t}) *vim.tbl_islist()* {t} Table Return: ~ - `true` if array-like table, else `false` . + `true` if array-like table, else `false`. tbl_keys({t}) *vim.tbl_keys()* Return a list of all keys used in a table. However, the order @@ -1773,7 +1813,7 @@ input({opts}, {on_confirm}) *vim.ui.input()* Parameters: ~ {opts} table Additional options. See |input()| • prompt (string|nil) Text of the prompt. - Defaults to `Input:` . + Defaults to `Input:`. • default (string|nil) Default reply to the input • completion (string|nil) Specifies type of @@ -1816,16 +1856,16 @@ select({items}, {opts}, {on_choice}) *vim.ui.select()* Defaults to `Select one of:` • format_item (function item -> text) Function to format an individual item from - `items` . Defaults to `tostring` . + `items`. Defaults to `tostring`. • kind (string|nil) Arbitrary hint string indicating the item shape. Plugins reimplementing `vim.ui.select` may wish to use this to infer the structure or - semantics of `items` , or the context in + semantics of `items`, or the context in which select() was called. {on_choice} function ((item|nil, idx|nil) -> ()) Called once the user made a choice. `idx` is the - 1-based index of `item` within `item` . `nil` + 1-based index of `item` within `item`. `nil` if the user aborted the dialog. @@ -1950,9 +1990,9 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* vim.keymap.set('n', 'asdf', require('jkl').my_fun) < - the require('jkl') gets evaluated during this call in order to - access the function. If you want to avoid this cost at startup - you can wrap it in a function, for example: > + the require('jkl )` gets evaluated during this call in order to access the + function. If you want to avoid this cost at startup you can + wrap it in a function, for example: > vim.keymap.set('n', 'asdf', function() return require('jkl').my_fun() end) < @@ -1974,9 +2014,7 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* result of Lua expr maps. • remap: (boolean) Make the mapping recursive. This is the inverse of the "noremap" option from - |nvim_set_keymap()|. Default `true` if `lhs` is - a string starting with `<plug>` - (case-insensitive), `false` otherwise. + |nvim_set_keymap()|. Default `false`. See also: ~ |nvim_set_keymap()| diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 2d2795b1ca..b874d6dc61 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -65,6 +65,8 @@ modes. where the map command applies. Disallow mapping of {rhs}, to avoid nested and recursive mappings. Often used to redefine a command. + Note: When <Plug> appears in the {rhs} this part is + always applied even if remapping is disallowed. :unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap* @@ -285,7 +287,7 @@ Here is an example that inserts a list number that increases: > func ListItem() let g:counter += 1 - return g:counter . '. ' + return g:counter .. '. ' endfunc func ListReset() @@ -502,7 +504,9 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which is the start of the last selected Visual area in the current buffer |'<|. The |:filter| command can be used to select what mappings to list. The -pattern is matched against the {lhs} and {rhs} in the raw form. +pattern is matched against the {lhs} and {rhs} in the raw form. If a +description was added using |nvim_set_keymap()| or |nvim_buf_set_keymap()| +then the pattern is also matched against it. *:map-verbose* When 'verbose' is non-zero, listing a key map will also display where it was @@ -1487,12 +1491,12 @@ The valid escape sequences are Examples: > command! -nargs=+ -complete=file MyEdit \ for f in expand(<q-args>, 0, 1) | - \ exe '<mods> split ' . f | + \ exe '<mods> split ' .. f | \ endfor function! SpecialEdit(files, mods) for f in expand(a:files, 0, 1) - exe a:mods . ' split ' . f + exe a:mods .. ' split ' .. f endfor endfunction command! -nargs=+ -complete=file Sedit @@ -1568,7 +1572,7 @@ This will invoke: > : let i = 0 : while i < argc() : if filereadable(argv(i)) - : execute "e " . argv(i) + : execute "e " .. argv(i) : execute a:command : endif : let i = i + 1 diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index c473244827..20033bd76a 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -993,7 +993,7 @@ These commands are not marks themselves, but jump to a mark: :let lnum = line(".") :keepjumps normal gg :call SetLastChange() - :keepjumps exe "normal " . lnum . "G" + :keepjumps exe "normal " .. lnum .. "G" < Note that ":keepjumps" must be used for every command. When invoking a function the commands in that function diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 66048c2e5f..b2bbf5ddad 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -897,7 +897,7 @@ A jump table for the options with a short description can be found at |Q_op|. If you like to keep a lot of backups, you could use a BufWritePre autocommand to change 'backupext' just before writing the file to include a timestamp. > - :au BufWritePre * let &bex = '-' . strftime("%Y%b%d%X") . '~' + :au BufWritePre * let &bex = '-' .. strftime("%Y%b%d%X") .. '~' < Use 'backupdir' to put the backup in a different directory. *'backupskip'* *'bsk'* @@ -920,7 +920,7 @@ A jump table for the options with a short description can be found at |Q_op|. Note that environment variables are not expanded. If you want to use $HOME you must expand it explicitly, e.g.: > - :let backupskip = escape(expand('$HOME'), '\') . '/tmp/*' + :let backupskip = escape(expand('$HOME'), '\') .. '/tmp/*' < Note that the default also makes sure that "crontab -e" works (when a backup would be made by renaming the original file crontab won't see @@ -1185,7 +1185,7 @@ A jump table for the options with a short description can be found at |Q_op|. If the default value taken from $CDPATH is not what you want, include a modified version of the following command in your vimrc file to override it: > - :let &cdpath = ',' . substitute(substitute($CDPATH, '[, ]', '\\\0', 'g'), ':', ',', 'g') + :let &cdpath = ',' .. substitute(substitute($CDPATH, '[, ]', '\\\0', 'g'), ':', ',', 'g') < This option cannot be set from a |modeline| or in the |sandbox|, for security reasons. (parts of 'cdpath' can be passed to the shell to expand file names). @@ -1232,8 +1232,8 @@ A jump table for the options with a short description can be found at |Q_op|. set charconvert=CharConvert() fun CharConvert() system("recode " - \ . v:charconvert_from . ".." . v:charconvert_to - \ . " <" . v:fname_in . " >" v:fname_out) + \ .. v:charconvert_from .. ".." .. v:charconvert_to + \ .. " <" .. v:fname_in .. " >" .. v:fname_out) return v:shell_error endfun < The related Vim variables are: @@ -3058,7 +3058,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'guitablabel'* *'gtl'* 'guitablabel' 'gtl' string (default empty) global - When nonempty describes the text to use in a label of the GUI tab + When non-empty describes the text to use in a label of the GUI tab pages line. When empty and when the result is empty Vim will use a default label. See |setting-guitablabel| for more info. @@ -3075,7 +3075,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'guitabtooltip'* *'gtt'* 'guitabtooltip' 'gtt' string (default empty) global - When nonempty describes the text to use in a tooltip for the GUI tab + When non-empty describes the text to use in a tooltip for the GUI tab pages line. When empty Vim will use a default tooltip. This option is otherwise just like 'guitablabel' above. You can include a line break. Simplest method is to use |:let|: > @@ -3638,7 +3638,7 @@ A jump table for the options with a short description can be found at |Q_op|. global Language to use for menu translation. Tells which file is loaded from the "lang" directory in 'runtimepath': > - "lang/menu_" . &langmenu . ".vim" + "lang/menu_" .. &langmenu .. ".vim" < (without the spaces). For example, to always use the Dutch menus, no matter what $LANG is set to: > :set langmenu=nl_NL.ISO_8859-1 @@ -4542,7 +4542,7 @@ A jump table for the options with a short description can be found at |Q_op|. < To use an environment variable, you probably need to replace the separator. Here is an example to append $INCL, in which directory names are separated with a semi-colon: > - :let &path = &path . "," . substitute($INCL, ';', ',', 'g') + :let &path = &path .. "," .. substitute($INCL, ';', ',', 'g') < Replace the ';' with a ':' or whatever separator is used. Note that this doesn't work when $INCL contains a comma or white space. @@ -5926,7 +5926,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'statusline'* *'stl'* *E540* *E542* 'statusline' 'stl' string (default empty) global or local to window |global-local| - When nonempty, this option determines the content of the status line. + When non-empty, this option determines the content of the status line. Also see |status-line|. The option consists of printf style '%' items interspersed with @@ -6242,7 +6242,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'tabline'* *'tal'* 'tabline' 'tal' string (default empty) global - When nonempty, this option determines the content of the tab pages + When non-empty, this option determines the content of the tab pages line at the top of the Vim window. When empty Vim will use a default tab pages line. See |setting-tabline| for more info. @@ -6590,7 +6590,7 @@ A jump table for the options with a short description can be found at |Q_op|. This option cannot be set in a modeline when 'modelineexpr' is off. Example: > - :auto BufEnter * let &titlestring = hostname() . "/" . expand("%:p") + :auto BufEnter * let &titlestring = hostname() .. "/" .. expand("%:p") :set title titlestring=%<%F%=%l/%L-%P titlelen=70 < The value of 'titlelen' is used to align items in the middle or right of the available space. @@ -6736,8 +6736,8 @@ A jump table for the options with a short description can be found at |Q_op|. global When bigger than zero, Vim will give messages about what it is doing. Currently, these messages are given: - >= 1 When the shada file is read or written. - >= 2 When a file is ":source"'ed. + >= 1 Lua assignments to options,keymaps etc. + >= 2 When a file is ":source"'ed and when the shada file is read or written.. >= 3 UI info, terminal capabilities >= 4 Shell commands. >= 5 Every searched tags file and include file. diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt index 42005b0d78..680b853dab 100644 --- a/runtime/doc/pattern.txt +++ b/runtime/doc/pattern.txt @@ -153,9 +153,10 @@ index, on which the cursor is. This can look like this: > Note: the count does not take offset into account. When no match is found you get the error: *E486* Pattern not found -Note that for the |:global| command this behaves like a normal message, for Vi -compatibility. For the |:s| command the "e" flag can be used to avoid the -error message |:s_flags|. +Note that for the `:global` command, you get a normal message "Pattern not +found", for Vi compatibility. +For the |:s| command the "e" flag can be used to avoid the error message +|:s_flags|. *search-offset* *{offset}* These commands search for the specified pattern. With "/" and "?" an @@ -923,7 +924,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): update the matches. This means Syntax highlighting quickly becomes wrong. Example, to highlight the line where the cursor currently is: > - :exe '/\%' . line(".") . 'l.*' + :exe '/\%' .. line(".") .. 'l.*' < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. @@ -939,7 +940,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on): update the matches. This means Syntax highlighting quickly becomes wrong. Example, to highlight the column where the cursor currently is: > - :exe '/\%' . col(".") . 'c' + :exe '/\%' .. col(".") .. 'c' < When 'hlsearch' is set and you move the cursor around and make changes this will clearly show when the match is updated or not. Example for matching a single byte in column 44: > @@ -1422,7 +1423,7 @@ Finally, these constructs are unique to Perl: ":2match" for another plugin. ============================================================================== -11. Fuzzy matching *fuzzy-match* +11. Fuzzy matching *fuzzy-matching* Fuzzy matching refers to matching strings using a non-exact search string. Fuzzy matching will match a string, if all the characters in the search string diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 3ac61be6f2..8257152b11 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -968,7 +968,7 @@ itself: fun! NetReadFixup(method, line1, line2) if method == 3 " ftp (no <.netrc>) let fourblanklines= line2 - 3 - silent fourblanklines.",".line2."g/^\s*/d" + silent fourblanklines .. "," .. line2 .. "g/^\s*/d" endif endfunction endif @@ -1975,7 +1975,7 @@ To use this function, simply assign its output to |g:netrw_list_hide| option. > Example: let g:netrw_list_hide= netrw_gitignore#Hide('my_gitignore_file') Function can take additional files with git-ignore patterns. - Example: g:netrw_list_hide= netrw_gitignore#Hide() . '.*\.swp$' + Example: let g:netrw_list_hide= netrw_gitignore#Hide() .. '.*\.swp$' Combining 'netrw_gitignore#Hide' with custom patterns. < @@ -2824,7 +2824,7 @@ your browsing preferences. (see also: |netrw-settings|) Examples: let g:netrw_list_hide= '.*\.swp$' - let g:netrw_list_hide= netrw_gitignore#Hide().'.*\.swp$' + let g:netrw_list_hide= netrw_gitignore#Hide() .. '.*\.swp$' default: "" *g:netrw_localcopycmd* ="cp" Linux/Unix/MacOS/Cygwin diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt index f54d0429a6..924fab175e 100644 --- a/runtime/doc/print.txt +++ b/runtime/doc/print.txt @@ -127,21 +127,21 @@ file: > system(['lpr'] + (empty(&printdevice)?[]:['-P', &printdevice]) + [v:fname_in]) - . delete(v:fname_in) + .. delete(v:fname_in) + v:shell_error On MS-Dos and MS-Windows machines the default is to copy the file to the currently specified printdevice: > system(['copy', v:fname_in, empty(&printdevice)?'LPT1':&printdevice]) - . delete(v:fname_in) + .. delete(v:fname_in) If you change this option, using a function is an easy way to avoid having to escape all the spaces. Example: > :set printexpr=PrintFile(v:fname_in) :function PrintFile(fname) - : call system("ghostview " . a:fname) + : call system("ghostview " .. a:fname) : call delete(a:fname) : return v:shell_error :endfunc diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 5b68da8be9..8e91b101cd 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -341,7 +341,7 @@ processing a quickfix or location list command, it will be aborted. cursor position will not be changed. See |:cexpr| for more information. Example: > - :g/mypattern/caddexpr expand("%") . ":" . line(".") . ":" . getline(".") + :g/mypattern/caddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".") < *:lad* *:addd* *:laddexpr* :lad[dexpr] {expr} Same as ":caddexpr", except the location list for the @@ -497,7 +497,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: autocommand event is disabled by adding it to 'eventignore'. This considerably speeds up editing each buffer. - {not in Vi} Also see |:bufdo|, |:tabdo|, |:argdo|, |:windo|, |:ldo|, |:cfdo| and |:lfdo|. @@ -510,7 +509,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: :{cmd} etc. < Otherwise it works the same as `:cdo`. - {not in Vi} *:ldo* :ld[o][!] {cmd} Execute {cmd} in each valid entry in the location list @@ -523,7 +521,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: etc. < Only valid entries in the location list are used. Otherwise it works the same as `:cdo`. - {not in Vi} *:lfdo* :lfdo[!] {cmd} Execute {cmd} in each file in the location list for @@ -535,7 +532,6 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: :{cmd} etc. < Otherwise it works the same as `:ldo`. - {not in Vi} FILTERING A QUICKFIX OR LOCATION LIST: *cfilter-plugin* *:Cfilter* *:Lfilter* @@ -575,6 +571,7 @@ location list. second quickfix window. If [height] is given the existing window will be resized to it. + *quickfix-buffer* The window will contain a special buffer, with 'buftype' equal to "quickfix". Don't change this! The window will have the w:quickfix_title variable set @@ -583,7 +580,11 @@ location list. status line if the value of 'statusline' is adjusted properly. Whenever this buffer is modified by a quickfix command or function, the |b:changedtick| - variable is incremented. + variable is incremented. You can get the number of + this buffer using the getqflist() and getloclist() + functions by passing the 'qfbufnr' item. For a + location list, this buffer is wiped out when the + location list is removed. *:lop* *:lopen* :lop[en] [height] Open a window to show the location list for the @@ -641,6 +642,27 @@ quickfix window. If there already is a window for that file, it is used instead. If the buffer in the used window has changed, and the error is in another file, jumping to the error will fail. You will first have to make sure the window contains a buffer which can be abandoned. + +When you select a file from the quickfix window, the following steps are used +to find a window to edit the file: + +1. If a window displaying the selected file is present in the current tabpage + (starting with the window before the quickfix window), then that window is + used. +2. If the above step fails and if 'switchbuf' contains "usetab" and a window + displaying the selected file is present in any one of the tabpages + (starting with the first tabpage) then that window is used. +3. If the above step fails then a window in the current tabpage displaying a + buffer with 'buftype' not set (starting with the window before the quickfix + window) is used. +4. If the above step fails and if 'switchbuf' contains "uselast", then the + previously accessed window is used. +5. If the above step fails then the window before the quickfix window is used. + If there is no previous window, then the window after the quickfix window + is used. +6. If the above step fails, then a new horizontally split window above the + quickfix window is used. + *CTRL-W_<Enter>* *CTRL-W_<CR>* You can use CTRL-W <Enter> to open a new window and jump to the error there. @@ -650,7 +672,7 @@ FileType event (also see |qf.vim|). Then the BufReadPost event is triggered, using "quickfix" for the buffer name. This can be used to perform some action on the listed errors. Example: > au BufReadPost quickfix setlocal modifiable - \ | silent exe 'g/^/s//\=line(".")." "/' + \ | silent exe 'g/^/s//\=line(".") .. " "/' \ | setlocal nomodifiable This prepends the line number to each line. Note the use of "\=" in the substitute string of the ":s" command, which is used to evaluate an @@ -679,13 +701,15 @@ this window, the displayed location list is used. When you select a file from the location list window, the following steps are used to find a window to edit the file: -1. If a window with the location list displayed in the location list window is - present, then the file is opened in that window. -2. If the above step fails and if the file is already opened in another - window, then that window is used. -3. If the above step fails then an existing window showing a buffer with - 'buftype' not set is used. -4. If the above step fails, then the file is edited in a new window. +1. If a non-quickfix window associated with the location list is present in + the current tabpage, then that window is used. +2. If the above step fails and if the file is already opened in another window + in the current tabpage, then that window is used. +3. If the above step fails and 'switchbuf' contains "usetab" and if the file + is opened in a window in any one of the tabpages, then that window is used. +4. If the above step fails then a window in the current tabpage showing a + buffer with 'buftype' not set is used. +5. If the above step fails, then the file is edited in a new window. In all of the above cases, if the location list for the selected window is not yet set, then it is set to the location list displayed in the location list @@ -749,12 +773,18 @@ using these functions are below: " get the quickfix list window id :echo getqflist({'winid' : 0}).winid + " get the quickfix list window buffer number + :echo getqflist({'qfbufnr' : 0}).qfbufnr + " get the context of the current location list :echo getloclist(0, {'context' : 0}).context " get the location list window id of the third window :echo getloclist(3, {'winid' : 0}).winid + " get the location list window buffer number of the third window + :echo getloclist(3, {'qfbufnr' : 0}).qfbufnr + " get the file window id of a location list window (winnr: 4) :echo getloclist(4, {'filewinid' : 0}).filewinid < @@ -1018,7 +1048,7 @@ commands can be combined to create a NewGrep command: > matching is used to find matching lines. In this case, {pattern} is treated as a literal string instead of a regular expression. See - |fuzzy-match| for more information about fuzzy + |fuzzy-matching| for more information about fuzzy matching strings. |QuickFixCmdPre| and |QuickFixCmdPost| are triggered. diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index af8301f1a0..e36eb2359f 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -356,6 +356,7 @@ In Insert or Command-line mode: |v_y| {visual}y yank the highlighted text into a register |yy| N yy yank N lines into a register |Y| N Y yank N lines into a register + Note: Mapped to "y$" by default. |default-mappings| |p| N p put a register after the cursor position (N times) |P| N P put a register before the cursor position (N times) |]p| N ]p like p, but adjust indent to current line diff --git a/runtime/doc/remote.txt b/runtime/doc/remote.txt new file mode 100644 index 0000000000..0c1e3438de --- /dev/null +++ b/runtime/doc/remote.txt @@ -0,0 +1,131 @@ +*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* + +Nvim's |RPC| functionality allows clients to programmatically control Nvim. Nvim +itself takes command-line arguments that cause it to become a client to another +Nvim running as a server. These arguments match those provided by Vim's +clientserver option. + +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. + Vim allows one init command: +{cmd}. + This must be an Ex command that can be + followed by "|". It's not yet supported by + Nvim. + 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 > + nvim --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-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-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. + *--server* + --server {addr} Connect to the named pipe or socket at the + given address for executing remote commands. + See |--listen| for specifying an address when + starting a server. + +Examples ~ + +Start an Nvim server listening on a named pipe at '~/.cache/nvim/server.pipe': > + nvim --listen ~/.cache/nvim/server.pipe + +Edit "file.txt" in an Nvim server listening at '~/.cache/nvim/server.pipe': > + nvim --server ~/.cache/nvim/server.pipe --remote file.txt + +This doesn't work, all arguments after --remote will be used as file names: > + nvim --remote --server ~/.cache/nvim/server.pipe file.txt + +Tell the remote server to write all files and exit: > + nvim --server ~/.cache/nvim/server.pipe --remote-send '<C-\><C-N>:wqa<CR>' + + +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. +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! + + +============================================================================== +2. Missing functionality *E5600* *clientserver-missing* + +Vim supports additional functionality in clientserver that's not yet +implemented in Nvim. In particular, none of the "wait" variants are supported +yet. The following command line arguments are not yet available: + + argument meaning ~ + + --remote-wait [+{cmd}] {file} ... *--remote-wait* + Not yet supported by Nvim. + As --remote, but wait for files to complete + (unload) in remote Vim. + --remote-wait-silent [+{cmd}] {file} ... *--remote-wait-silent* + Not yet supported by Nvim. + As --remote-wait, but don't complain if there + is no server. + *--remote-tab-wait* + --remote-tab-wait Not yet supported by Nvim. + Like --remote-wait but open each file in a new + tabpage. + *--remote-tab-wait-silent* + --remote-tab-wait-silent Not yet supported by Nvim. + Like --remote-wait-silent but open each file + in a new tabpage. + *--servername* + --servername {name} Not yet supported by Nvim. + Become the server {name}. When used together + with one of the --remote commands: connect to + server {name} instead of the default (see + below). The name used will be uppercase. + + *--serverlist* + --serverlist Not yet supported by Nvim. + Output a list of server names. + + + + +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. Nvim +either listens on a named pipe or a socket and does not yet support this +--servername functionality. + + vim:tw=78:sw=4:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index a022049766..994f97bba0 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -161,6 +161,11 @@ Q Repeat the last recorded register [count] times. result of evaluating the expression is executed as an Ex command. Mappings are not recognized in these commands. + When the |line-continuation| character (\) is present + at the beginning of a line in a linewise register, + then it is combined with the previous line. This is + useful for yanking and executing parts of a Vim + script. *:@:* :[addr]@: Repeat last command-line. First set cursor at line @@ -253,21 +258,22 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. below "plugin", just like with plugins in 'runtimepath'. - If the filetype detection was not enabled yet (this + If the filetype detection was already enabled (this is usually done with a "syntax enable" or "filetype - on" command in your .vimrc file), this will also look + on" command in your |init.vim|, or automatically during + |initialization|), and the package was found in + "pack/*/opt/{name}", this command will also look for "{name}/ftdetect/*.vim" files. When the optional ! is added no plugin files or ftdetect scripts are loaded, only the matching directories are added to 'runtimepath'. This is - useful in your .vimrc. The plugins will then be - loaded during initialization, see |load-plugins| (note + useful in your |init.vim|. The plugins will then be + loaded during |initialization|, see |load-plugins| (note that the loading order will be reversed, because each - directory is inserted before others). - Note that for ftdetect scripts to be loaded - you will need to write `filetype plugin indent on` - AFTER all `packadd!` commands. + directory is inserted before others). In this case, the + ftdetect scripts will be loaded during |initialization|, + before the |load-plugins| step. Also see |pack-add|. diff --git a/runtime/doc/sign.txt b/runtime/doc/sign.txt index 5cfa06c33c..a2a5645baa 100644 --- a/runtime/doc/sign.txt +++ b/runtime/doc/sign.txt @@ -87,7 +87,7 @@ the delete is undone the sign does not move back. Here is an example that places a sign "piet", displayed with the text ">>", in line 23 of the current file: > :sign define piet text=>> texthl=Search - :exe ":sign place 2 line=23 name=piet file=" . expand("%:p") + :exe ":sign place 2 line=23 name=piet file=" .. expand("%:p") And here is the command to delete it again: > :sign unplace 2 diff --git a/runtime/doc/spell.txt b/runtime/doc/spell.txt index 03c00c8495..bc45b0e511 100644 --- a/runtime/doc/spell.txt +++ b/runtime/doc/spell.txt @@ -120,8 +120,8 @@ zuG Undo |zW| and |zG|, remove the word from the internal rare as this is a fairly uncommon command and all intuitive commands for this are already taken. If you want you can add mappings with e.g.: > - nnoremap z? :exe ':spellrare ' . expand('<cWORD>')<CR> - nnoremap z/ :exe ':spellrare! ' . expand('<cWORD>')<CR> + nnoremap z? :exe ':spellrare ' .. expand('<cWORD>')<CR> + nnoremap z/ :exe ':spellrare! ' .. expand('<cWORD>')<CR> < |:spellundo|, |zuw|, or |zuW| can be used to undo this. :spellr[rare]! {word} Add {word} as a rare word to the internal word diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 978142a1e0..1d3fa6c2ca 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -800,7 +800,7 @@ resulting file, when executed with a ":source" command: After restoring the Session, the full filename of your current Session is available in the internal variable |v:this_session|. An example mapping: > - :nmap <F2> :wa<Bar>exe "mksession! " . v:this_session<CR>:so ~/sessions/ + :nmap <F2> :wa<Bar>exe "mksession! " .. v:this_session<CR>:so ~/sessions/ This saves the current Session, and starts off the command to load another. A session includes all tab pages, unless "tabpages" was removed from diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 5446bd3a88..0ff31e81ab 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -188,7 +188,8 @@ A syntax group name doesn't specify any color or attributes itself. The name for a highlight or syntax group must consist of ASCII letters, digits and the underscore. As a regexp: "[a-zA-Z0-9_]*". However, Vim does not give -an error when using other characters. +an error when using other characters. The maxium length of a group name is +about 200 bytes. *E1249* To be able to allow each user to pick their favorite set of colors, there must be preferred names for highlight groups that are common for many languages. @@ -616,7 +617,7 @@ evaluate to get a unique string to append to each ID used in a given document, so that the full IDs will be unique even when combined with other content in a larger HTML document. Example, to append _ and the buffer number to each ID: > - :let g:html_id_expr = '"_".bufnr("%")' + :let g:html_id_expr = '"_" .. bufnr("%")' < To append a string "_mystring" to the end of each ID: > @@ -1500,6 +1501,14 @@ The enhanced mode also takes advantage of additional color features for a dark gvim display. Here, statements are colored LightYellow instead of Yellow, and conditionals are LightBlue for better distinction. +Both Visual Basic and FORM use the extension ".frm". To detect which one +should be used, Vim checks for the string "VB_Name" in the first five lines of +the file. If it is found, filetype will be "vb", otherwise "form". + +If the automatic detection doesn't work for you or you only edit, for +example, FORM files, use this in your startup vimrc: > + :let filetype_frm = "form" + FORTH *forth.vim* *ft-forth-syntax* @@ -3550,8 +3559,8 @@ Do you want to draw with the mouse? Try the following: > :function! GetPixel() : let c = getline(".")[col(".") - 1] : echo c - : exe "noremap <LeftMouse> <LeftMouse>r".c - : exe "noremap <LeftDrag> <LeftMouse>r".c + : exe "noremap <LeftMouse> <LeftMouse>r" .. c + : exe "noremap <LeftDrag> <LeftMouse>r" .. c :endfunction :noremap <RightMouse> <LeftMouse>:call GetPixel()<CR> :set guicursor=n:hor20 " to see the color beneath the cursor @@ -4388,7 +4397,7 @@ Leading context *:syn-lc* *:syn-leading* *:syn-context* Note: This is an obsolete feature, only included for backwards compatibility with previous Vim versions. It's now recommended to use the |/\@<=| construct -in the pattern. +in the pattern. You can also often use |/\zs|. The "lc" offset specifies leading context -- a part of the pattern that must be present, but is not considered part of the match. An offset of "lc=n" will @@ -4875,7 +4884,8 @@ the same syntax file on all UIs. 1. TUI highlight arguments - *bold* *underline* *undercurl* + *bold* *underline* *underlineline* + *undercurl* *underdot* *underdash* *inverse* *italic* *standout* *nocombine* *strikethrough* cterm={attr-list} *attr-list* *highlight-cterm* *E418* @@ -4883,7 +4893,10 @@ cterm={attr-list} *attr-list* *highlight-cterm* *E418* following items (in any order): bold underline + underlineline double underline undercurl curly underline + underdot dotted underline + underdash dashed underline strikethrough reverse inverse same as reverse @@ -4894,8 +4907,9 @@ cterm={attr-list} *attr-list* *highlight-cterm* *E418* Note that "bold" can be used here and by using a bold font. They have the same effect. - "undercurl" falls back to "underline" in a terminal that does not - support it. The color is set using |highlight-guisp|. + "underlineline", "undercurl", "underdot", and "underdash" fall back + to "underline" in a terminal that does not support them. The color is + set using |highlight-guisp|. start={term-list} *highlight-start* *E422* stop={term-list} *term-list* *highlight-stop* @@ -5028,8 +5042,8 @@ guifg={color-name} *highlight-guifg* guibg={color-name} *highlight-guibg* guisp={color-name} *highlight-guisp* These give the foreground (guifg), background (guibg) and special - (guisp) color to use in the GUI. "guisp" is used for undercurl - and underline. + (guisp) color to use in the GUI. "guisp" is used for various + underlines. There are a few special names: NONE no color (transparent) bg use normal background color @@ -5363,9 +5377,9 @@ types.vim: *.[ch] And put these lines in your vimrc: > " load the types.vim highlighting file, if it exists - autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim' + autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') .. '/types.vim' autocmd BufRead,BufNewFile *.[ch] if filereadable(fname) - autocmd BufRead,BufNewFile *.[ch] exe 'so ' . fname + autocmd BufRead,BufNewFile *.[ch] exe 'so ' .. fname autocmd BufRead,BufNewFile *.[ch] endif ============================================================================== diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt index 7f91fda9f4..f06a6bcc34 100644 --- a/runtime/doc/tabpage.txt +++ b/runtime/doc/tabpage.txt @@ -133,7 +133,10 @@ something else. :tabclose + " close the next tab page :tabclose 3 " close the third tab page :tabclose $ " close the last tab page -< + :tabclose # " close the last accessed tab page + +When a tab is closed the next tab page will become the current one. + *:tabo* *:tabonly* :tabo[nly][!] Close all other tab pages. When the 'hidden' option is set, all buffers in closed windows @@ -159,6 +162,8 @@ something else. " one :tabonly 1 " close all tab pages except the first one :tabonly $ " close all tab pages except the last one + :tabonly # " close all tab pages except the last + " accessed one SWITCHING TO ANOTHER TAB PAGE: @@ -181,6 +186,7 @@ gt *i_CTRL-<PageDown>* *i_<C-PageDown>* :+2tabnext " go to the two next tab page :1tabnext " go to the first tab page :$tabnext " go to the last tab page + :tabnext # " go to the last accessed tab page :tabnext $ " as above :tabnext - " go to the previous tab page :tabnext -1 " as above @@ -190,10 +196,6 @@ gt *i_CTRL-<PageDown>* *i_<C-PageDown>* {count}<C-PageDown> {count}gt Go to tab page {count}. The first tab page has number one. -CTRL-<Tab> *CTRL-<Tab>* -CTRL-W g<Tab> *g<Tab>* *CTRL-W_g<Tab>* -g<Tab> Go to previous (last accessed) tab page. - :tabp[revious] *:tabp* *:tabprevious* *gT* *:tabN* :tabN[ext] *:tabNext* *CTRL-<PageUp>* <C-PageUp> *<C-PageUp>* *i_CTRL-<PageUp>* *i_<C-PageUp>* @@ -213,6 +215,9 @@ gT Go to the previous tab page. Wraps around from the first one *:tabl* *:tablast* :tabl[ast] Go to the last tab page. +<C-Tab> *CTRL-<Tab>* *<C-Tab>* +CTRL-W g<Tab> *g<Tab>* *CTRL-W_g<Tab>* +g<Tab> Go to the last accessed tab page. Other commands: *:tabs* @@ -245,6 +250,8 @@ REORDERING TAB PAGES: :tabmove " move the tab page to the last :$tabmove " as above :tabmove $ " as above + :tabmove # " move the tab page after the last accessed + " tab page :tabm[ove] +[N] :tabm[ove] -[N] @@ -366,24 +373,24 @@ pages and define labels for them. Then get the label for each tab page. > for i in range(tabpagenr('$')) " select the highlighting if i + 1 == tabpagenr() - let s .= '%#TabLineSel#' + let s ..= '%#TabLineSel#' else - let s .= '%#TabLine#' + let s ..= '%#TabLine#' endif " set the tab page number (for mouse clicks) - let s .= '%' . (i + 1) . 'T' + let s ..= '%' .. (i + 1) .. 'T' " the label is made by MyTabLabel() - let s .= ' %{MyTabLabel(' . (i + 1) . ')} ' + let s ..= ' %{MyTabLabel(' .. (i + 1) .. ')} ' endfor " after the last tab fill with TabLineFill and reset tab page nr - let s .= '%#TabLineFill#%T' + let s ..= '%#TabLineFill#%T' " right-align the label to close the current tab page if tabpagenr('$') > 1 - let s .= '%=%#TabLine#%999Xclose' + let s ..= '%=%#TabLine#%999Xclose' endif return s @@ -446,14 +453,14 @@ windows in the tab page and a '+' if there is a modified buffer: > " Append the number of windows in the tab page if more than one let wincount = tabpagewinnr(v:lnum, '$') if wincount > 1 - let label .= wincount + let label ..= wincount endif if label != '' - let label .= ' ' + let label ..= ' ' endif " Append the buffer name - return label . bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) + return label .. bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) endfunction set guitablabel=%{GuiTabLabel()} diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index 4d938c4a23..5a0d16d6b8 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -705,7 +705,7 @@ matches the pattern "^# *define" it is not considered to be a comment. If you want to list matches, and then select one to jump to, you could use a mapping to do that for you. Here is an example: > - :map <F4> [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR> + :map <F4> [I:let nr = input("Which one: ")<Bar>exe "normal " .. nr .. "[\t"<CR> < *[i* [i Display the first line that contains the keyword diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 62e13285f5..f9b2271756 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -321,7 +321,7 @@ an #if/#else/#endif block, the selection becomes linewise. For MS-Windows and xterm the time for double clicking can be set with the 'mousetime' option. For the other systems this time is defined outside of Vim. An example, for using a double click to jump to the tag under the cursor: > - :map <2-LeftMouse> :exe "tag ". expand("<cword>")<CR> + :map <2-LeftMouse> :exe "tag " .. expand("<cword>")<CR> Dragging the mouse with a double click (button-down, button-up, button-down and then drag) will result in whole words to be selected. This continues diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt index b77c7d9a6d..d913b53c6b 100644 --- a/runtime/doc/tips.txt +++ b/runtime/doc/tips.txt @@ -84,14 +84,14 @@ What you need: create it with the shell command "mkid file1 file2 ..". Put this in your |init.vim|: > - map _u :call ID_search()<Bar>execute "/\\<" . g:word . "\\>"<CR> - map _n :n<Bar>execute "/\\<" . g:word . "\\>"<CR> + map _u :call ID_search()<Bar>execute "/\\<" .. g:word .. "\\>"<CR> + map _n :n<Bar>execute "/\\<" .. g:word .. "\\>"<CR> function! ID_search() let g:word = expand("<cword>") - let x = system("lid --key=none ". g:word) + let x = system("lid --key=none " .. g:word) let x = substitute(x, "\n", " ", "g") - execute "next " . x + execute "next " .. x endfun To use it, place the cursor on a word, type "_u" and vim will load the file @@ -285,13 +285,13 @@ This mapping will format any bullet list. It requires that there is an empty line above and below each list entry. The expression commands are used to be able to give comments to the parts of the mapping. > - :let m = ":map _f :set ai<CR>" " need 'autoindent' set - :let m = m . "{O<Esc>" " add empty line above item - :let m = m . "}{)^W" " move to text after bullet - :let m = m . "i <CR> <Esc>" " add space for indent - :let m = m . "gq}" " format text after the bullet - :let m = m . "{dd" " remove the empty line - :let m = m . "5lDJ" " put text after bullet + :let m = ":map _f :set ai<CR>" " need 'autoindent' set + :let m ..= "{O<Esc>" " add empty line above item + :let m ..= "}{)^W" " move to text after bullet + :let m ..= "i <CR> <Esc>" " add space for indent + :let m ..= "gq}" " format text after the bullet + :let m ..= "{dd" " remove the empty line + :let m ..= "5lDJ" " put text after bullet :execute m |" define the mapping (<> notation |<>|. Note that this is all typed literally. ^W is "^" "W", not @@ -429,15 +429,15 @@ A slightly more advanced version is used in the |matchparen| plugin. let c = '\[' let c2 = '\]' endif - let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' . + let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .. \ '=~? "string\\|comment"' execute 'if' s_skip '| let s_skip = 0 | endif' let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip) if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$') - exe 'match Search /\(\%' . c_lnum . 'l\%' . c_col . - \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + exe 'match Search /\(\%' .. c_lnum .. 'l\%' .. c_col .. + \ 'c\)\|\(\%' .. m_lnum .. 'l\%' .. m_col .. 'c\)/' let s:paren_hl_on = 1 endif endfunction diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index dbd8ec6fef..a9d9f81849 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -207,14 +207,14 @@ Here is a list of built-in predicates : `eq?` *ts-predicate-eq?* This predicate will check text correspondence between nodes or - strings : > + strings: > ((identifier) @foo (#eq? @foo "foo")) ((node1) @left (node2) @right (#eq? @left @right)) < `match?` *ts-predicate-match?* `vim-match?` *ts-predicate-vim-match?* This will match if the provided vim regex matches the text - corresponding to a node : > + corresponding to a node: > ((identifier) @constant (#match? @constant "^[A-Z_]+$")) < Note: the `^` and `$` anchors will respectively match the start and end of the node's text. @@ -225,17 +225,18 @@ Here is a list of built-in predicates : `contains?` *ts-predicate-contains?* Will check if any of the following arguments appears in the - text corresponding to the node : > + text corresponding to the node: > ((identifier) @foo (#contains? @foo "foo")) ((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 + arguments: > + ((identifier) @foo (#any-of? @foo "foo" "bar")) +< This is the recommended way to check if the node matches one of many keywords for example, as it has been optimized for this. - arguments : > - ((identifier) @foo (#any-of? @foo "foo" "bar")) < *lua-treesitter-not-predicate* Each predicate has a `not-` prefixed predicate that is just the negation of @@ -467,7 +468,7 @@ parse_query({lang}, {query}) *parse_query()* Exposes `info` and `captures` with additional context about {query}. • `captures` contains the list of unique capture names defined - in {query}. - `info.captures` also points to `captures` . + in {query}. -`info.captures` also points to `captures`. • `info.patterns` contains information about predicates. Parameters: ~ @@ -527,8 +528,8 @@ Query:iter_matches({self}, {node}, {source}, {start}, {stop}) a table mapping capture indices to nodes, and metadata from any directives processing the match. If the query has more than one pattern the capture table might be sparse, and e.g. - `pairs()` method should be used over `ipairs` . Here an - example iterating over all captures in every match: + `pairs()` method should be used over `ipairs`. Here an example + iterating over all captures in every match: > for pattern, match, metadata in cquery:iter_matches(tree:root(), bufnr, first, last) do diff --git a/runtime/doc/uganda.txt b/runtime/doc/uganda.txt index 79519da51e..23dfa082a0 100644 --- a/runtime/doc/uganda.txt +++ b/runtime/doc/uganda.txt @@ -129,11 +129,12 @@ Kibaale Children's Centre *kcc* *Kibaale* *charity* Kibaale Children's Centre (KCC) is located in Kibaale, a small town in the south of Uganda, near Tanzania, in East Africa. The area is known as Rakai District. The population is mostly farmers. Although people are poor, there -is enough food. But this district is suffering from AIDS more than any other -part of the world. Some say that it started there. Estimations are that 10 -to 30% of the Ugandans are infected with HIV. Because parents die, there are -many orphans. In this district about 60,000 children have lost one or both -parents, out of a population of 350,000. And this is still continuing. +usually is enough food. But this district is suffering from AIDS more than +any other part of the world. Some say that it started there. Estimations are +that in the past 10 to 30% of the Ugandans are infected with HIV. Because +parents die, there are many orphans. In this district about 60,000 children +have lost one or both parents, out of a population of 350,000. Although AIDS +is now mostly under control, the problems are still continuing. The children need a lot of help. The KCC is working hard to provide the needy with food, medical care and education. Food and medical care to keep them diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index e7be14e732..c5e3b60079 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -283,19 +283,24 @@ numerical highlight ids to the actual attributes. attributes specified by the `rgb_attr` and `cterm_attr` dicts, with the following (all optional) keys. - `foreground`: foreground color. - `background`: background color. - `special`: color to use for underline and undercurl, when present. - `reverse`: reverse video. Foreground and background colors are - switched. - `italic`: italic text. - `bold`: bold text. - `strikethrough`: struckthrough text. - `underline`: underlined text. The line has `special` color. - `undercurl`: undercurled text. The curl has `special` color. - `blend`: Blend level (0-100). Could be used by UIs to support - blending floating windows to the background or to - signal a transparent cursor. + `foreground`: foreground color. + `background`: background color. + `special`: color to use for various underlines, when + present. + `reverse`: reverse video. Foreground and background colors + are switched. + `italic`: italic text. + `bold`: bold text. + `strikethrough`: struckthrough text. + `underline`: underlined text. The line has `special` color. + `underlineline`: double underlined text. The lines have `special` + color. + `undercurl`: undercurled text. The curl has `special` color. + `underdot`: underdotted text. The dots have `special` color. + `underdash`: underdashed text. The dashes have `special` color. + `blend`: Blend level (0-100). Could be used by UIs to + support blending floating windows to the + background or to signal a transparent cursor. For absent color keys the default color should be used. Don't store the default value in the table, rather a sentinel value, so that @@ -444,14 +449,17 @@ is not active. New UIs should implement |ui-linegrid| instead. `foreground`: foreground color. `background`: background color. - `special`: color to use for underline and undercurl, when present. + `special`: color to use for various underlines, when present. `reverse`: reverse video. Foreground and background colors are switched. `italic`: italic text. `bold`: bold text. `strikethrough`: struckthrough text. `underline`: underlined text. The line has `special` color. + `underlineline`: double underlined text. The lines have `special` color. `undercurl`: undercurled text. The curl has `special` color. + `underdot`: underdotted text. The dots have `special` color. + `underdash`: underdashed text. The dashes have `special` color. ["put", text] The (utf-8 encoded) string `text` is put at the cursor position diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt index b11d7581ed..a853aea995 100644 --- a/runtime/doc/undo.txt +++ b/runtime/doc/undo.txt @@ -272,12 +272,12 @@ history file. E.g.: > au BufReadPost * call ReadUndo() au BufWritePost * call WriteUndo() func ReadUndo() - if filereadable(expand('%:h'). '/UNDO/' . expand('%:t')) + if filereadable(expand('%:h') .. '/UNDO/' .. expand('%:t')) rundo %:h/UNDO/%:t endif endfunc func WriteUndo() - let dirname = expand('%:h') . '/UNDO' + let dirname = expand('%:h') .. '/UNDO' if !isdirectory(dirname) call mkdir(dirname) endif diff --git a/runtime/doc/usr_04.txt b/runtime/doc/usr_04.txt index b2dd617542..c7c900274b 100644 --- a/runtime/doc/usr_04.txt +++ b/runtime/doc/usr_04.txt @@ -349,15 +349,17 @@ Notice that "yw" includes the white space after a word. If you don't want this, use "ye". The "yy" command yanks a whole line, just like "dd" deletes a whole line. -Unexpectedly, while "D" deletes from the cursor to the end of the line, "Y" -works like "yy", it yanks the whole line. Watch out for this inconsistency! -Use "y$" to yank to the end of the line. a text line yy a text line a text line line 2 line 2 p line 2 last line last line a text line last line +"Y" was originally equivalent to "yank the entire line", as opposed to "D" +which is "delete to end of the line". "Y" has thus been remapped to mean +"yank to end of the line" to make it consistent with the behavior of "D". +Mappings will be covered in later chapters. + ============================================================================== *04.7* Using the clipboard diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index f93a221e43..b1ef563e43 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -131,7 +131,7 @@ it worked before Vim 5.0. Otherwise the "Q" command starts Ex mode, but you will not need it. > - vnoremap _g y:exe "grep /" . escape(@", '\\/') . "/ *.c *.h"<CR> + vnoremap _g y:exe "grep /" .. escape(@", '\\/') .. "/ *.c *.h"<CR> This mapping yanks the visually selected text and searches for it in C files. This is a complicated mapping. You can see that mappings can be used to do diff --git a/runtime/doc/usr_07.txt b/runtime/doc/usr_07.txt index 649be8d7ce..ebf5c3d7b8 100644 --- a/runtime/doc/usr_07.txt +++ b/runtime/doc/usr_07.txt @@ -336,7 +336,7 @@ there. > Of course you can use many other commands to yank the text. For example, to select whole lines start Visual mode with "V". Or use CTRL-V to select a -rectangular block. Or use "Y" to yank a single line, "yaw" to yank-a-word, +rectangular block. Or use "yy" to yank a single line, "yaw" to yank-a-word, etc. The "p" command puts the text after the cursor. Use "P" to put the text before the cursor. Notice that Vim remembers if you yanked a whole line or a @@ -359,7 +359,7 @@ the text should be placed in the f register. This must come just before the yank command. Now yank three whole lines to the l register (l for line): > - "l3Y + "l3yy The count could be before the "l just as well. To yank a block of text to the b (for block) register: > diff --git a/runtime/doc/usr_10.txt b/runtime/doc/usr_10.txt index 5365f90314..8844671e01 100644 --- a/runtime/doc/usr_10.txt +++ b/runtime/doc/usr_10.txt @@ -132,11 +132,11 @@ This works both with recording and with yank and delete commands. For example, you want to collect a sequence of lines into the a register. Yank the first line with: > - "aY + "ayy Now move to the second line, and type: > - "AY + "Ayy Repeat this command for all lines. The a register now contains all those lines, in the order you yanked them. diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index 38869f8e94..75ee0fdfdf 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -275,7 +275,7 @@ g8 Print the hex values of the bytes used in the Special characters are not escaped, use quotes or |shellescape()|: > :!ls "%" - :exe "!ls " . shellescape(expand("%")) + :exe "!ls " .. shellescape(expand("%")) < Newline character ends {cmd} unless a backslash precedes the newline. What follows is interpreted as @@ -432,7 +432,7 @@ g8 Print the hex values of the bytes used in the used. In this example |:silent| is used to avoid the message about reading the file and |:unsilent| to be able to list the first line of each file. > - :silent argdo unsilent echo expand('%') . ": " . getline(1) + :silent argdo unsilent echo expand('%') .. ": " .. getline(1) < *:verb* *:verbose* @@ -461,10 +461,11 @@ g8 Print the hex values of the bytes used in the *:verbose-cmd* When 'verbose' is non-zero, listing the value of a Vim option or a key map or an abbreviation or a user-defined function or a command or a highlight group -or an autocommand will also display where it was last defined. If it was -defined manually then there will be no "Last set" message. When it was -defined while executing a function, user command or autocommand, the script in -which it was defined is reported. +or an autocommand will also display where it was last defined. If they were +defined in Lua they will only be located if 'verbose' is set. So Start +nvim with -V1 arg to see them. If it was defined manually then there +will be no "Last set" message. When it was defined while executing a function, +user command or autocommand, the script in which it was defined is reported. *K* [count]K Runs the program given by 'keywordprg' to lookup the diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 69b0e0081a..9ca5faf112 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -84,7 +84,7 @@ Nvim creates the following default mappings at |startup|. You can disable any of these in your config by simply removing the mapping, e.g. ":unmap Y". > nnoremap Y y$ - nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L> + nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR> inoremap <C-U> <C-G>u<C-U> inoremap <C-W> <C-G>u<C-W> < @@ -437,7 +437,8 @@ Vimscript compatibility: `this_session` does not alias to |v:this_session| Working directory (Vim implemented some of these later than Nvim): -- |DirChanged| can be triggered when switching to another window. +- |DirChanged| and |DirChangedPre| can be triggered when switching to another + window or tab. - |getcwd()| and |haslocaldir()| may throw errors if the tab page or window cannot be found. *E5000* *E5001* *E5002* - |haslocaldir()| checks for tab-local directory if and only if -1 is passed as @@ -497,6 +498,9 @@ Eval: *js_encode()* *js_decode()* *v:none* (used by Vim to represent JavaScript "undefined"); use |v:null| instead. + *v:sizeofint* + *v:sizeoflong* + *v:sizeofpointer* Events: *SigUSR1* Use |Signal| to detect `SIGUSR1` signal instead. diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index f8a8a557ef..cd5425336f 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -449,7 +449,7 @@ These commands can also be executed with ":wincmd": the |CursorHold| autocommand event). Or when a Normal mode command is inconvenient. The count can also be a window number. Example: > - :exe nr . "wincmd w" + :exe nr .. "wincmd w" < This goes to window "nr". ============================================================================== @@ -911,12 +911,12 @@ CTRL-W g } *CTRL-W_g}* cursor. This is less clever than using |:ptag|, but you don't need a tags file and it will also find matches in system include files. Example: > - :au! CursorHold *.[ch] ++nested exe "silent! psearch " . expand("<cword>") + :au! CursorHold *.[ch] ++nested exe "silent! psearch " .. expand("<cword>") < Warning: This can be slow. Example *CursorHold-example* > - :au! CursorHold *.[ch] ++nested exe "silent! ptag " . expand("<cword>") + :au! CursorHold *.[ch] ++nested exe "silent! ptag " .. expand("<cword>") This will cause a ":ptag" to be executed for the keyword under the cursor, when the cursor hasn't moved for the time set with 'updatetime'. "++nested" @@ -939,14 +939,14 @@ is no word under the cursor, and a few other things: > : : " Delete any existing highlight before showing another tag : silent! wincmd P " jump to preview window - : if &previewwindow " if we really get there... + : if &previewwindow " if we really get there... : match none " delete existing highlight : wincmd p " back to old window : endif : : " Try displaying a matching tag for the word under the cursor : try - : exe "ptag " . w + : exe "ptag " .. w : catch : return : endtry @@ -958,10 +958,10 @@ is no word under the cursor, and a few other things: > : endif : call search("$", "b") " to end of previous line : let w = substitute(w, '\\', '\\\\', "") - : call search('\<\V' . w . '\>') " position cursor on match + : call search('\<\V' .. w .. '\>') " position cursor on match : " Add a match highlight to the word at this position : hi previewWord term=bold ctermbg=green guibg=green - : exe 'match previewWord "\%' . line(".") . 'l\%' . col(".") . 'c\k*"' + : exe 'match previewWord "\%' .. line(".") .. 'l\%' .. col(".") .. 'c\k*"' : wincmd p " back to old window : endif : endif diff --git a/runtime/filetype.lua b/runtime/filetype.lua index fcfc5701f0..8224b79534 100644 --- a/runtime/filetype.lua +++ b/runtime/filetype.lua @@ -7,19 +7,36 @@ if vim.g.do_filetype_lua ~= 1 then return end -vim.cmd [[ -augroup filetypedetect -au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('<afile>')) +vim.api.nvim_create_augroup("filetypedetect", {clear = false}) + +vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + group = "filetypedetect", + callback = function() + vim.filetype.match(vim.fn.expand("<afile>")) + end, +}) -" These *must* be sourced after the autocommand above is created +-- These *must* be sourced after the autocommand above is created +vim.cmd [[ runtime! ftdetect/*.vim runtime! ftdetect/*.lua +]] -" Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim -let g:did_load_ftdetect = 1 +-- Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim +vim.g.did_load_ftdetect = 1 -augroup END -]] +-- If filetype.vim is disabled, set up the autocmd to use scripts.vim +if vim.g.did_load_filetypes then + vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + group = "filetypedetect", + command = "if !did_filetype() && expand('<amatch>') !~ g:ft_ignore_pat | runtime! scripts.vim | endif", + }) + + vim.api.nvim_create_autocmd("StdinReadPost", { + group = "filetypedetect", + command = "if !did_filetype() | runtime! scripts.vim | endif", + }) +end if not vim.g.ft_ignore_pat then vim.g.ft_ignore_pat = "\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$" diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 35f4b25120..9df89674e3 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -44,7 +44,7 @@ endif " file name matches ft_ignore_pat. " When using this, the entry should probably be further down below with the " other StarSetf() calls. -func! s:StarSetf(ft) +func s:StarSetf(ft) if expand("<amatch>") !~ g:ft_ignore_pat exe 'setf ' . a:ft endif @@ -225,6 +225,9 @@ au BufNewFile,BufRead *.bib setf bib " BibTeX Bibliography Style au BufNewFile,BufRead *.bst setf bst +" Bicep +au BufNewFile,BufRead *.bicep setf bicep + " BIND configuration " sudoedit uses namedXXXX.conf au BufNewFile,BufRead named*.conf,rndc*.conf,rndc*.key setf named @@ -477,6 +480,7 @@ au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq au BufNewFile,BufRead *.desc setf desc " the D language or dtrace +au BufNewFile,BufRead */dtrace/*.d setf dtrace au BufNewFile,BufRead *.d call dist#ft#DtraceCheck() " Desktop files @@ -660,7 +664,7 @@ au BufNewFile,BufRead *.fs call dist#ft#FTfs() au BufNewFile,BufRead *.fsi,*.fsx setf fsharp " GDB command files -au BufNewFile,BufRead .gdbinit,gdbinit setf gdb +au BufNewFile,BufRead .gdbinit,gdbinit,.gdbearlyinit,gdbearlyinit,*.gdb setf gdb " GDMO au BufNewFile,BufRead *.mo,*.gdmo setf gdmo @@ -723,6 +727,10 @@ au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash au BufNewFile,BufRead gitolite.conf setf gitolite au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc setf perl +" Glimmer-flavored TypeScript and JavaScript +au BufNewFile,BufRead *.gts setf typescript.glimmer +au BufNewFile,BufRead *.gjs setf javascript.glimmer + " Gnuplot scripts au BufNewFile,BufRead *.gpi,.gnuplot setf gnuplot @@ -1788,6 +1796,9 @@ au BufNewFile,BufRead *.mib,*.my setf mib au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog au BufNewFile,BufRead *.rules call dist#ft#FTRules() +" Solidity +au BufRead,BufNewFile *.sol setf solidity + " SPARQL queries au BufNewFile,BufRead *.rq,*.sparql setf sparql @@ -2517,7 +2528,7 @@ endif " Function called for testing all functions defined here. These are " script-local, thus need to be executed here. " Returns a string with error messages (hopefully empty). -func! TestFiletypeFuncs(testlist) +func TestFiletypeFuncs(testlist) let output = '' for f in a:testlist try diff --git a/runtime/ftplugin/ant.vim b/runtime/ftplugin/ant.vim index 5905858896..aee07ca4b9 100644 --- a/runtime/ftplugin/ant.vim +++ b/runtime/ftplugin/ant.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: ant -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/aspvbs.vim b/runtime/ftplugin/aspvbs.vim index 660dab4685..70a130d287 100644 --- a/runtime/ftplugin/aspvbs.vim +++ b/runtime/ftplugin/aspvbs.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: aspvbs -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/config.vim b/runtime/ftplugin/config.vim index 7fde42ebf5..73136cbc66 100644 --- a/runtime/ftplugin/config.vim +++ b/runtime/ftplugin/config.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: config -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/csc.vim b/runtime/ftplugin/csc.vim index 3a09c3bf8b..7b4126a503 100644 --- a/runtime/ftplugin/csc.vim +++ b/runtime/ftplugin/csc.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: csc -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 diff --git a/runtime/ftplugin/csh.vim b/runtime/ftplugin/csh.vim index 929823219c..ca5da5a8b9 100644 --- a/runtime/ftplugin/csh.vim +++ b/runtime/ftplugin/csh.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: csh " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" Previous Maintainer: Dan Sharp " Contributor: Johannes Zellner <johannes@zellner.org> " Last Change: 2021 Oct 15 diff --git a/runtime/ftplugin/dtd.vim b/runtime/ftplugin/dtd.vim index 6c08f6691d..a046118c70 100644 --- a/runtime/ftplugin/dtd.vim +++ b/runtime/ftplugin/dtd.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: dtd -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 diff --git a/runtime/ftplugin/html.vim b/runtime/ftplugin/html.vim index 7579080ea5..3179aa2e88 100644 --- a/runtime/ftplugin/html.vim +++ b/runtime/ftplugin/html.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: html -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 diff --git a/runtime/ftplugin/java.vim b/runtime/ftplugin/java.vim index 292cb6b166..74c8e8d1c1 100644 --- a/runtime/ftplugin/java.vim +++ b/runtime/ftplugin/java.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: Java -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Change: 2012 Mar 11 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 diff --git a/runtime/ftplugin/jsp.vim b/runtime/ftplugin/jsp.vim index fbba863b32..18136ccc24 100644 --- a/runtime/ftplugin/jsp.vim +++ b/runtime/ftplugin/jsp.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: jsp -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/pascal.vim b/runtime/ftplugin/pascal.vim index 2de92563ae..aba1e54f27 100644 --- a/runtime/ftplugin/pascal.vim +++ b/runtime/ftplugin/pascal.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: Pascal " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" Previous Maintainer: Dan Sharp " Last Change: 2021 Apr 23 if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/php.vim b/runtime/ftplugin/php.vim index a2f8b4d8d3..3ff0828ffe 100644 --- a/runtime/ftplugin/php.vim +++ b/runtime/ftplugin/php.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: php -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/sgml.vim b/runtime/ftplugin/sgml.vim index bf63efbf1f..ef52125c68 100644 --- a/runtime/ftplugin/sgml.vim +++ b/runtime/ftplugin/sgml.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: sgml -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/sh.vim b/runtime/ftplugin/sh.vim index 593fcec927..93a46f63e2 100644 --- a/runtime/ftplugin/sh.vim +++ b/runtime/ftplugin/sh.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: sh -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 diff --git a/runtime/ftplugin/svg.vim b/runtime/ftplugin/svg.vim index 8fff6ea32c..6f16b1a0f4 100644 --- a/runtime/ftplugin/svg.vim +++ b/runtime/ftplugin/svg.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: svg -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/tcsh.vim b/runtime/ftplugin/tcsh.vim index 33f1aabf68..85d3873b33 100644 --- a/runtime/ftplugin/tcsh.vim +++ b/runtime/ftplugin/tcsh.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: tcsh " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" Previous Maintainer: Dan Sharp " Last Change: 2021 Oct 15 if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/xhtml.vim b/runtime/ftplugin/xhtml.vim index 21ed3e1100..d2a1c0b566 100644 --- a/runtime/ftplugin/xhtml.vim +++ b/runtime/ftplugin/xhtml.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: xhtml -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/xml.vim b/runtime/ftplugin/xml.vim index 1d43521155..9aa188cecc 100644 --- a/runtime/ftplugin/xml.vim +++ b/runtime/ftplugin/xml.vim @@ -3,7 +3,7 @@ " Maintainer: Christian Brabandt <cb@256bit.org> " Last Changed: Dec 07th, 2018 " Repository: https://github.com/chrisbra/vim-xml-ftplugin -" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" Previous Maintainer: Dan Sharp " URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/xsd.vim b/runtime/ftplugin/xsd.vim index 6a4a193656..7d3efbb390 100644 --- a/runtime/ftplugin/xsd.vim +++ b/runtime/ftplugin/xsd.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: xsd -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/ftplugin/xslt.vim b/runtime/ftplugin/xslt.vim index 1a5ee62865..9d2def107b 100644 --- a/runtime/ftplugin/xslt.vim +++ b/runtime/ftplugin/xslt.vim @@ -1,8 +1,10 @@ " Vim filetype plugin file " Language: xslt -" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> +" +" This runtime file is looking for a new maintainer. +" +" Former maintainer: Dan Sharp " Last Changed: 20 Jan 2009 -" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin if exists("b:did_ftplugin") | finish | endif diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 7c03ff2873..cd2d4982d8 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Vim script " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Nov 27 +" Last Change: 2022 Mar 01 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -10,7 +10,7 @@ endif let b:did_indent = 1 setlocal indentexpr=GetVimIndent() -setlocal indentkeys+==end,=},=else,=cat,=finall,=END,0\\,0=\"\\\ +setlocal indentkeys+==endif,=enddef,=endfu,=endfor,=endwh,=endtry,=},=else,=cat,=finall,=END,0\\,0=\"\\\ setlocal indentkeys-=0# setlocal indentkeys-=: @@ -103,10 +103,11 @@ function GetVimIndentIntern() " A line starting with :au does not increment/decrement indent. " A { may start a block or a dict. Assume that when a } follows it's a " terminated dict. + " ":function" starts a block but "function(" doesn't. if prev_text !~ '^\s*au\%[tocmd]' && prev_text !~ '^\s*{.*}' - let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|fu\%[nction]\|def\|el\%[seif]\)\>\)') + let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|def\|el\%[seif]\)\>\|fu\%[nction][! ]\)') if i >= 0 - let ind += shiftwidth() + let ind += shiftwidth() if strpart(prev_text, i, 1) == '|' && has('syntax_items') \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\|PatSep\)$' let ind -= shiftwidth() @@ -170,10 +171,15 @@ function GetVimIndentIntern() let ind = ind + shiftwidth() endif - " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry, - " :endfun, :else and :augroup END. - if cur_text =~ '^\s*\(ene\@!\|cat\|finall\|el\|aug\%[roup]\s\+[eE][nN][dD]\)' + " Subtract a 'shiftwidth' on a :endif, :endwhile, :endfor, :catch, :finally, + " :endtry, :endfun, :enddef, :else and :augroup END. + " Although ":en" would be enough only match short command names as in + " 'indentkeys'. + if cur_text =~ '^\s*\(endif\|endwh\|endfor\|endtry\|endfu\|enddef\|cat\|finall\|else\|aug\%[roup]\s\+[eE][nN][dD]\)' let ind = ind - shiftwidth() + if ind < 0 + let ind = 0 + endif endif return ind diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua new file mode 100644 index 0000000000..d4db4850bd --- /dev/null +++ b/runtime/lua/vim/_editor.lua @@ -0,0 +1,740 @@ +-- Nvim-Lua stdlib: the `vim` module (:help lua-stdlib) +-- +-- Lua code lives in one of three places: +-- 1. runtime/lua/vim/ (the runtime): For "nice to have" features, e.g. the +-- `inspect` and `lpeg` modules. +-- 2. runtime/lua/vim/shared.lua: pure lua functions which always +-- are available. Used in the test runner, as well as worker threads +-- and processes launched from Nvim. +-- 3. runtime/lua/vim/_editor.lua: Code which directly interacts with +-- the Nvim editor state. Only available in the main thread. +-- +-- Guideline: "If in doubt, put it in the runtime". +-- +-- Most functions should live directly in `vim.`, not in submodules. +-- The only "forbidden" names are those claimed by legacy `if_lua`: +-- $ vim +-- :lua for k,v in pairs(vim) do print(k) end +-- buffer +-- open +-- window +-- lastline +-- firstline +-- type +-- line +-- eval +-- dict +-- beep +-- list +-- command +-- +-- Reference (#6580): +-- - https://github.com/luafun/luafun +-- - https://github.com/rxi/lume +-- - http://leafo.net/lapis/reference/utilities.html +-- - https://github.com/torch/paths +-- - https://github.com/bakpakin/Fennel (pretty print, repl) +-- - https://github.com/howl-editor/howl/tree/master/lib/howl/util + +local vim = assert(vim) + +-- These are for loading runtime modules lazily since they aren't available in +-- the nvim binary as specified in executor.c +for k,v in pairs { + treesitter=true; + filetype = true; + F=true; + lsp=true; + highlight=true; + diagnostic=true; + keymap=true; + ui=true; +} do vim._submodules[k] = v end + +vim.log = { + levels = { + TRACE = 0; + DEBUG = 1; + INFO = 2; + WARN = 3; + ERROR = 4; + } +} + +-- Internal-only until comments in #8107 are addressed. +-- Returns: +-- {errcode}, {output} +function vim._system(cmd) + local out = vim.fn.system(cmd) + local err = vim.v.shell_error + return err, out +end + +-- Gets process info from the `ps` command. +-- Used by nvim_get_proc() as a fallback. +function vim._os_proc_info(pid) + if pid == nil or pid <= 0 or type(pid) ~= 'number' then + error('invalid pid') + end + local cmd = { 'ps', '-p', pid, '-o', 'comm=', } + local err, name = vim._system(cmd) + if 1 == err and vim.trim(name) == '' then + return {} -- Process not found. + elseif 0 ~= err then + error('command failed: '..vim.fn.string(cmd)) + end + local _, ppid = vim._system({ 'ps', '-p', pid, '-o', 'ppid=', }) + -- Remove trailing whitespace. + name = vim.trim(name):gsub('^.*/', '') + ppid = tonumber(ppid) or -1 + return { + name = name, + pid = pid, + ppid = ppid, + } +end + +-- Gets process children from the `pgrep` command. +-- Used by nvim_get_proc_children() as a fallback. +function vim._os_proc_children(ppid) + if ppid == nil or ppid <= 0 or type(ppid) ~= 'number' then + error('invalid ppid') + end + local cmd = { 'pgrep', '-P', ppid, } + local err, rv = vim._system(cmd) + if 1 == err and vim.trim(rv) == '' then + return {} -- Process not found. + elseif 0 ~= err then + error('command failed: '..vim.fn.string(cmd)) + end + local children = {} + for s in rv:gmatch('%S+') do + local i = tonumber(s) + if i ~= nil then + table.insert(children, i) + end + end + return children +end + +-- TODO(ZyX-I): Create compatibility layer. + +--- Return a human-readable representation of the given object. +--- +---@see https://github.com/kikito/inspect.lua +---@see https://github.com/mpeterv/vinspect +local function inspect(object, options) -- luacheck: no unused + error(object, options) -- Stub for gen_vimdoc.py +end + +do + local tdots, tick, got_line1, undo_started, trailing_nl = 0, 0, false, false, false + + --- Paste handler, invoked by |nvim_paste()| when a conforming UI + --- (such as the |TUI|) pastes text into the editor. + --- + --- Example: To remove ANSI color codes when pasting: + --- <pre> + --- vim.paste = (function(overridden) + --- return function(lines, phase) + --- for i,line in ipairs(lines) do + --- -- Scrub ANSI color codes from paste input. + --- lines[i] = line:gsub('\27%[[0-9;mK]+', '') + --- end + --- overridden(lines, phase) + --- end + --- end)(vim.paste) + --- </pre> + --- + ---@see |paste| + --- + ---@param lines |readfile()|-style list of lines to paste. |channel-lines| + ---@param phase -1: "non-streaming" paste: the call contains all lines. + --- If paste is "streamed", `phase` indicates the stream state: + --- - 1: starts the paste (exactly once) + --- - 2: continues the paste (zero or more times) + --- - 3: ends the paste (exactly once) + ---@returns false if client should cancel the paste. + function vim.paste(lines, phase) + local now = vim.loop.now() + local is_first_chunk = phase < 2 + local is_last_chunk = phase == -1 or phase == 3 + if is_first_chunk then -- Reset flags. + tdots, tick, got_line1, undo_started, trailing_nl = now, 0, false, false, false + end + if #lines == 0 then + lines = {''} + end + if #lines == 1 and lines[1] == '' and not is_last_chunk then + -- An empty chunk can cause some edge cases in streamed pasting, + -- so don't do anything unless it is the last chunk. + return true + end + -- Note: mode doesn't always start with "c" in cmdline mode, so use getcmdtype() instead. + if vim.fn.getcmdtype() ~= '' then -- cmdline-mode: paste only 1 line. + if not got_line1 then + got_line1 = (#lines > 1) + vim.api.nvim_set_option('paste', true) -- For nvim_input(). + -- Escape "<" and control characters + local line1 = lines[1]:gsub('<', '<lt>'):gsub('(%c)', '\022%1') + vim.api.nvim_input(line1) + vim.api.nvim_set_option('paste', false) + end + return true + end + local mode = vim.api.nvim_get_mode().mode + if undo_started then + vim.api.nvim_command('undojoin') + end + if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer + vim.api.nvim_put(lines, 'c', false, true) + elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode + -- TODO: implement Replace mode streamed pasting + -- TODO: support Virtual Replace mode + local nchars = 0 + for _, line in ipairs(lines) do + nchars = nchars + line:len() + end + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1] + local firstline = lines[1] + firstline = bufline:sub(1, col)..firstline + lines[1] = firstline + lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len()) + vim.api.nvim_buf_set_lines(0, row-1, row, false, lines) + elseif mode:find('^[nvV\22sS\19]') then -- Normal or Visual or Select mode + if mode:find('^n') then -- Normal mode + -- When there was a trailing new line in the previous chunk, + -- the cursor is on the first character of the next line, + -- so paste before the cursor instead of after it. + vim.api.nvim_put(lines, 'c', not trailing_nl, false) + else -- Visual or Select mode + vim.api.nvim_command([[exe "silent normal! \<Del>"]]) + local del_start = vim.fn.getpos("'[") + local cursor_pos = vim.fn.getpos('.') + if mode:find('^[VS]') then -- linewise + if cursor_pos[2] < del_start[2] then -- replacing lines at eof + -- create a new line + vim.api.nvim_put({''}, 'l', true, true) + end + vim.api.nvim_put(lines, 'c', false, false) + else + -- paste after cursor when replacing text at eol, otherwise paste before cursor + vim.api.nvim_put(lines, 'c', cursor_pos[3] < del_start[3], false) + end + end + -- put cursor at the end of the text instead of one character after it + vim.fn.setpos('.', vim.fn.getpos("']")) + trailing_nl = lines[#lines] == '' + else -- Don't know what to do in other modes + return false + end + undo_started = true + if phase ~= -1 and (now - tdots >= 100) then + local dots = ('.'):rep(tick % 4) + tdots = now + tick = tick + 1 + -- Use :echo because Lua print('') is a no-op, and we want to clear the + -- message when there are zero dots. + vim.api.nvim_command(('echo "%s"'):format(dots)) + end + if is_last_chunk then + vim.api.nvim_command('redraw'..(tick > 1 and '|echo ""' or '')) + end + return true -- Paste will not continue if not returning `true`. + end +end + +--- Defers callback `cb` until the Nvim API is safe to call. +--- +---@see |lua-loop-callbacks| +---@see |vim.schedule()| +---@see |vim.in_fast_event()| +function vim.schedule_wrap(cb) + return (function (...) + local args = vim.F.pack_len(...) + vim.schedule(function() cb(vim.F.unpack_len(args)) end) + end) +end + +-- vim.fn.{func}(...) +vim.fn = setmetatable({}, { + __index = function(t, key) + local _fn + if vim.api[key] ~= nil then + _fn = function() + error(string.format("Tried to call API function with vim.fn: use vim.api.%s instead", key)) + end + else + _fn = function(...) + return vim.call(key, ...) + end + end + t[key] = _fn + return _fn + end +}) + +vim.funcref = function(viml_func_name) + return vim.fn[viml_func_name] +end + +-- An easier alias for commands. +vim.cmd = function(command) + return vim.api.nvim_exec(command, false) +end + +-- These are the vim.env/v/g/o/bo/wo variable magic accessors. +do + local validate = vim.validate + + --@private + local function make_dict_accessor(scope, handle) + validate { + scope = {scope, 's'}; + } + local mt = {} + function mt:__newindex(k, v) + return vim._setvar(scope, handle or 0, k, v) + end + function mt:__index(k) + if handle == nil and type(k) == 'number' then + return make_dict_accessor(scope, k) + end + return vim._getvar(scope, handle or 0, k) + end + return setmetatable({}, mt) + end + + vim.g = make_dict_accessor('g', false) + vim.v = make_dict_accessor('v', false) + vim.b = make_dict_accessor('b') + vim.w = make_dict_accessor('w') + vim.t = make_dict_accessor('t') +end + +--- Get a table of lines with start, end columns for a region marked by two points +--- +---@param bufnr number of buffer +---@param pos1 (line, column) tuple marking beginning of region +---@param pos2 (line, column) tuple marking end of region +---@param regtype type of selection (:help setreg) +---@param inclusive boolean indicating whether the selection is end-inclusive +---@return region lua table of the form {linenr = {startcol,endcol}} +function vim.region(bufnr, pos1, pos2, regtype, inclusive) + if not vim.api.nvim_buf_is_loaded(bufnr) then + vim.fn.bufload(bufnr) + end + + -- check that region falls within current buffer + local buf_line_count = vim.api.nvim_buf_line_count(bufnr) + pos1[1] = math.min(pos1[1], buf_line_count - 1) + pos2[1] = math.min(pos2[1], buf_line_count - 1) + + -- in case of block selection, columns need to be adjusted for non-ASCII characters + -- TODO: handle double-width characters + local bufline + if regtype:byte() == 22 then + bufline = vim.api.nvim_buf_get_lines(bufnr, pos1[1], pos1[1] + 1, true)[1] + pos1[2] = vim.str_utfindex(bufline, pos1[2]) + end + + local region = {} + for l = pos1[1], pos2[1] do + local c1, c2 + if regtype:byte() == 22 then -- block selection: take width from regtype + c1 = pos1[2] + c2 = c1 + regtype:sub(2) + -- and adjust for non-ASCII characters + bufline = vim.api.nvim_buf_get_lines(bufnr, l, l + 1, true)[1] + if c1 < #bufline then + c1 = vim.str_byteindex(bufline, c1) + end + if c2 < #bufline then + c2 = vim.str_byteindex(bufline, c2) + end + else + c1 = (l == pos1[1]) and (pos1[2]) or 0 + c2 = (l == pos2[1]) and (pos2[2] + (inclusive and 1 or 0)) or -1 + end + table.insert(region, l, {c1, c2}) + end + return region +end + +--- Defers calling `fn` until `timeout` ms passes. +--- +--- Use to do a one-shot timer that calls `fn` +--- Note: The {fn} is |schedule_wrap|ped automatically, so API functions are +--- safe to call. +---@param fn Callback to call once `timeout` expires +---@param timeout Number of milliseconds to wait before calling `fn` +---@return timer luv timer object +function vim.defer_fn(fn, timeout) + vim.validate { fn = { fn, 'c', true}; } + local timer = vim.loop.new_timer() + timer:start(timeout, 0, vim.schedule_wrap(function() + timer:stop() + timer:close() + + fn() + end)) + + return timer +end + + +--- Display a notification to the user. +--- +--- This function can be overridden by plugins to display notifications using a +--- custom provider (such as the system notification provider). By default, +--- writes to |:messages|. +--- +---@param msg string Content of the notification to show to the user. +---@param level number|nil One of the values from |vim.log.levels|. +---@param opts table|nil Optional parameters. Unused by default. +function vim.notify(msg, level, opts) -- luacheck: no unused args + if level == vim.log.levels.ERROR then + vim.api.nvim_err_writeln(msg) + elseif level == vim.log.levels.WARN then + vim.api.nvim_echo({{msg, 'WarningMsg'}}, true, {}) + else + vim.api.nvim_echo({{msg}}, true, {}) + end +end + +do + local notified = {} + + --- Display a notification only one time. + --- + --- Like |vim.notify()|, but subsequent calls with the same message will not + --- display a notification. + --- + ---@param msg string Content of the notification to show to the user. + ---@param level number|nil One of the values from |vim.log.levels|. + ---@param opts table|nil Optional parameters. Unused by default. + function vim.notify_once(msg, level, opts) -- luacheck: no unused args + if not notified[msg] then + vim.notify(msg, level, opts) + notified[msg] = true + end + end +end + +---@private +function vim.register_keystroke_callback() + error('vim.register_keystroke_callback is deprecated, instead use: vim.on_key') +end + +local on_key_cbs = {} + +--- Adds Lua function {fn} with namespace id {ns_id} as a listener to every, +--- yes every, input key. +--- +--- The Nvim command-line option |-w| is related but does not support callbacks +--- and cannot be toggled dynamically. +--- +---@param fn function: Callback function. It should take one string argument. +--- On each key press, Nvim passes the key char to fn(). |i_CTRL-V| +--- If {fn} is nil, it removes the callback for the associated {ns_id} +---@param ns_id number? Namespace ID. If nil or 0, generates and returns a new +--- |nvim_create_namespace()| id. +--- +---@return number Namespace id associated with {fn}. Or count of all callbacks +---if on_key() is called without arguments. +--- +---@note {fn} will be removed if an error occurs while calling. +---@note {fn} will not be cleared by |nvim_buf_clear_namespace()| +---@note {fn} will receive the keys after mappings have been evaluated +function vim.on_key(fn, ns_id) + if fn == nil and ns_id == nil then + return #on_key_cbs + end + + vim.validate { + fn = { fn, 'c', true}, + ns_id = { ns_id, 'n', true } + } + + if ns_id == nil or ns_id == 0 then + ns_id = vim.api.nvim_create_namespace('') + end + + on_key_cbs[ns_id] = fn + return ns_id +end + +--- Executes the on_key callbacks. +---@private +function vim._on_key(char) + local failed_ns_ids = {} + local failed_messages = {} + for k, v in pairs(on_key_cbs) do + local ok, err_msg = pcall(v, char) + if not ok then + vim.on_key(nil, k) + table.insert(failed_ns_ids, k) + table.insert(failed_messages, err_msg) + end + end + + if failed_ns_ids[1] then + error(string.format( + "Error executing 'on_key' with ns_ids '%s'\n Messages: %s", + table.concat(failed_ns_ids, ", "), + table.concat(failed_messages, "\n"))) + end +end + +--- Generate a list of possible completions for the string. +--- String starts with ^ and then has the pattern. +--- +--- 1. Can we get it to just return things in the global namespace with that name prefix +--- 2. Can we get it to return things from global namespace even with `print(` in front. +function vim._expand_pat(pat, env) + env = env or _G + + pat = string.sub(pat, 2, #pat) + + if pat == '' then + local result = vim.tbl_keys(env) + table.sort(result) + return result, 0 + end + + -- TODO: We can handle spaces in [] ONLY. + -- We should probably do that at some point, just for cooler completion. + -- TODO: We can suggest the variable names to go in [] + -- This would be difficult as well. + -- Probably just need to do a smarter match than just `:match` + + -- Get the last part of the pattern + local last_part = pat:match("[%w.:_%[%]'\"]+$") + if not last_part then return {}, 0 end + + local parts, search_index = vim._expand_pat_get_parts(last_part) + + local match_part = string.sub(last_part, search_index, #last_part) + local prefix_match_pat = string.sub(pat, 1, #pat - #match_part) or '' + + local final_env = env + + for _, part in ipairs(parts) do + if type(final_env) ~= 'table' then + return {}, 0 + end + local key + + -- Normally, we just have a string + -- Just attempt to get the string directly from the environment + if type(part) == "string" then + key = part + else + -- However, sometimes you want to use a variable, and complete on it + -- With this, you have the power. + + -- MY_VAR = "api" + -- vim[MY_VAR] + -- -> _G[MY_VAR] -> "api" + local result_key = part[1] + if not result_key then + return {}, 0 + end + + local result = rawget(env, result_key) + + if result == nil then + return {}, 0 + end + + key = result + end + local field = rawget(final_env, key) + if field == nil then + local mt = getmetatable(final_env) + if mt and type(mt.__index) == "table" then + field = rawget(mt.__index, key) + elseif final_env == vim and vim._submodules[key] then + field = vim[key] + end + end + final_env = field + + if not final_env then + return {}, 0 + end + end + + local keys = {} + ---@private + local function insert_keys(obj) + for k,_ in pairs(obj) do + if type(k) == "string" and string.sub(k,1,string.len(match_part)) == match_part then + table.insert(keys,k) + end + end + end + + if type(final_env) == "table" then + insert_keys(final_env) + end + local mt = getmetatable(final_env) + if mt and type(mt.__index) == "table" then + insert_keys(mt.__index) + end + if final_env == vim then + insert_keys(vim._submodules) + end + + table.sort(keys) + + return keys, #prefix_match_pat +end + +vim._expand_pat_get_parts = function(lua_string) + local parts = {} + + local accumulator, search_index = '', 1 + local in_brackets, bracket_end = false, -1 + local string_char = nil + for idx = 1, #lua_string do + local s = lua_string:sub(idx, idx) + + if not in_brackets and (s == "." or s == ":") then + table.insert(parts, accumulator) + accumulator = '' + + search_index = idx + 1 + elseif s == "[" then + in_brackets = true + + table.insert(parts, accumulator) + accumulator = '' + + search_index = idx + 1 + elseif in_brackets then + if idx == bracket_end then + in_brackets = false + search_index = idx + 1 + + if string_char == "VAR" then + table.insert(parts, { accumulator }) + accumulator = '' + + string_char = nil + end + elseif not string_char then + bracket_end = string.find(lua_string, ']', idx, true) + + if s == '"' or s == "'" then + string_char = s + elseif s ~= ' ' then + string_char = "VAR" + accumulator = s + end + elseif string_char then + if string_char ~= s then + accumulator = accumulator .. s + else + table.insert(parts, accumulator) + accumulator = '' + + string_char = nil + end + end + else + accumulator = accumulator .. s + end + end + + parts = vim.tbl_filter(function(val) return #val > 0 end, parts) + + return parts, search_index +end + +---Prints given arguments in human-readable format. +---Example: +---<pre> +--- -- Print highlight group Normal and store it's contents in a variable. +--- local hl_normal = vim.pretty_print(vim.api.nvim_get_hl_by_name("Normal", true)) +---</pre> +---@see |vim.inspect()| +---@return given arguments. +function vim.pretty_print(...) + local objects = {} + for i = 1, select('#', ...) do + local v = select(i, ...) + table.insert(objects, vim.inspect(v)) + end + + print(table.concat(objects, ' ')) + return ... +end + +function vim._cs_remote(rcid, server_addr, connect_error, args) + local function connection_failure_errmsg(consequence) + local explanation + if server_addr == '' then + explanation = "No server specified with --server" + else + explanation = "Failed to connect to '" .. server_addr .. "'" + if connect_error ~= "" then + explanation = explanation .. ": " .. connect_error + end + end + return "E247: " .. explanation .. ". " .. consequence + end + + local f_silent = false + local f_tab = false + + local subcmd = string.sub(args[1],10) + if subcmd == 'tab' then + f_tab = true + elseif subcmd == 'silent' then + f_silent = true + elseif subcmd == 'wait' or subcmd == 'wait-silent' or subcmd == 'tab-wait' or subcmd == 'tab-wait-silent' then + return { errmsg = 'E5600: Wait commands not yet implemented in nvim' } + elseif subcmd == 'tab-silent' then + f_tab = true + f_silent = true + elseif subcmd == 'send' then + if rcid == 0 then + return { errmsg = connection_failure_errmsg('Send failed.') } + end + vim.fn.rpcrequest(rcid, 'nvim_input', args[2]) + return { should_exit = true, tabbed = false } + elseif subcmd == 'expr' then + if rcid == 0 then + return { errmsg = connection_failure_errmsg('Send expression failed.') } + end + print(vim.fn.rpcrequest(rcid, 'nvim_eval', args[2])) + return { should_exit = true, tabbed = false } + elseif subcmd ~= '' then + return { errmsg='Unknown option argument: ' .. args[1] } + end + + if rcid == 0 then + if not f_silent then + vim.notify(connection_failure_errmsg("Editing locally"), vim.log.levels.WARN) + end + else + local command = {} + if f_tab then table.insert(command, 'tab') end + table.insert(command, 'drop') + for i = 2, #args do + table.insert(command, vim.fn.fnameescape(args[i])) + end + vim.fn.rpcrequest(rcid, 'nvim_command', table.concat(command, ' ')) + end + + return { + should_exit = rcid ~= 0, + tabbed = f_tab, + } +end + +require('vim._meta') + +return vim diff --git a/runtime/lua/vim/_init_packages.lua b/runtime/lua/vim/_init_packages.lua new file mode 100644 index 0000000000..7d27741f1b --- /dev/null +++ b/runtime/lua/vim/_init_packages.lua @@ -0,0 +1,83 @@ +-- prevents luacheck from making lints for setting things on vim +local vim = assert(vim) + +local pathtrails = {} +vim._so_trails = {} +for s in (package.cpath..';'):gmatch('[^;]*;') do + s = s:sub(1, -2) -- Strip trailing semicolon + -- Find out path patterns. pathtrail should contain something like + -- /?.so, \?.dll. This allows not to bother determining what correct + -- suffixes are. + local pathtrail = s:match('[/\\][^/\\]*%?.*$') + if pathtrail and not pathtrails[pathtrail] then + pathtrails[pathtrail] = true + table.insert(vim._so_trails, pathtrail) + end +end + +function vim._load_package(name) + local basename = name:gsub('%.', '/') + local paths = {"lua/"..basename..".lua", "lua/"..basename.."/init.lua"} + local found = vim.api.nvim__get_runtime(paths, false, {is_lua=true}) + if #found > 0 then + local f, err = loadfile(found[1]) + return f or error(err) + end + + local so_paths = {} + for _,trail in ipairs(vim._so_trails) do + local path = "lua"..trail:gsub('?', basename) -- so_trails contains a leading slash + table.insert(so_paths, path) + end + + found = vim.api.nvim__get_runtime(so_paths, false, {is_lua=true}) + if #found > 0 then + -- Making function name in Lua 5.1 (see src/loadlib.c:mkfuncname) is + -- a) strip prefix up to and including the first dash, if any + -- b) replace all dots by underscores + -- c) prepend "luaopen_" + -- So "foo-bar.baz" should result in "luaopen_bar_baz" + local dash = name:find("-", 1, true) + local modname = dash and name:sub(dash + 1) or name + local f, err = package.loadlib(found[1], "luaopen_"..modname:gsub("%.", "_")) + return f or error(err) + end + return nil +end + +-- Insert vim._load_package after the preloader at position 2 +table.insert(package.loaders, 2, vim._load_package) + +-- builtin functions which always should be available +require'vim.shared' + +vim._submodules = {inspect=true} + +-- These are for loading runtime modules in the vim namespace lazily. +setmetatable(vim, { + __index = function(t, key) + if vim._submodules[key] then + t[key] = require('vim.'..key) + return t[key] + elseif vim.startswith(key, 'uri_') then + local val = require('vim.uri')[key] + if val ~= nil then + -- Expose all `vim.uri` functions on the `vim` module. + t[key] = val + return t[key] + end + end + end +}) + +--- <Docs described in |vim.empty_dict()| > +---@private +--- TODO: should be in vim.shared when vim.shared always uses nvim-lua +function vim.empty_dict() + return setmetatable({}, vim._empty_dict_mt) +end + +-- only on main thread: functions for interacting with editor state +if not vim.is_thread() then + require'vim._editor' +end diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua index b4537c2882..fcb1e61764 100644 --- a/runtime/lua/vim/diagnostic.lua +++ b/runtime/lua/vim/diagnostic.lua @@ -447,7 +447,7 @@ local function set_list(loclist, opts) vim.fn.setqflist({}, ' ', { title = title, items = items }) end if open then - vim.api.nvim_command(loclist and "lopen" or "copen") + vim.api.nvim_command(loclist and "lopen" or "botright copen") end end @@ -920,7 +920,8 @@ M.handlers.underline = { underline_ns, higroup, { diagnostic.lnum, diagnostic.col }, - { diagnostic.end_lnum, diagnostic.end_col } + { diagnostic.end_lnum, diagnostic.end_col }, + { priority = vim.highlight.priorities.diagnostics } ) end save_extmarks(underline_ns, bufnr) diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index 2fe4aa3d32..b356f5e3dc 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -65,6 +65,7 @@ local extension = { bdf = "bdf", beancount = "beancount", bib = "bib", + bicep = "bicep", bl = "blank", bsdl = "bsdl", bst = "bst", @@ -224,6 +225,7 @@ local extension = { fsi = "fsharp", fsx = "fsharp", fusion = "fusion", + gdb = "gdb", gdmo = "gdmo", mo = "gdmo", tres = "gdresource", @@ -246,6 +248,8 @@ local extension = { gradle = "groovy", groovy = "groovy", gsp = "gsp", + gjs = "javascript.glimmer", + gts = "typescript.glimmer", hack = "hack", hackpartial = "hack", haml = "haml", @@ -597,6 +601,7 @@ local extension = { sl = "slang", ice = "slice", score = "slrnsc", + sol = "solidity", tpl = "smarty", ihlp = "smcl", smcl = "smcl", @@ -915,6 +920,8 @@ local filename = { mtab = "fstab", [".gdbinit"] = "gdb", gdbinit = "gdb", + [".gdbearlyinit"] = "gdb", + gdbearlyinit = "gdb", ["lltxxxxx.txt"] = "gedcom", ["TAG_EDITMSG"] = "gitcommit", ["MERGE_MSG"] = "gitcommit", @@ -1174,6 +1181,7 @@ local pattern = { [".*/etc/yum%.conf"] = "dosini", [".*lvs"] = "dracula", [".*lpe"] = "dracula", + [".*/dtrace/.*%.d"] = "dtrace", [".*esmtprc"] = "esmtprc", [".*Eterm/.*%.cfg"] = "eterm", [".*%.git/modules/.*/config"] = "gitconfig", diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index 12faa0a6e1..4105ef0675 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -1,9 +1,16 @@ local api = vim.api -local highlight = {} +local M = {} + +M.priorities = { + syntax = 50, + treesitter = 100, + diagnostics = 150, + user = 200, +} ---@private -function highlight.create(higroup, hi_info, default) +function M.create(higroup, hi_info, default) local options = {} -- TODO: Add validation for k, v in pairs(hi_info) do @@ -13,28 +20,33 @@ function highlight.create(higroup, hi_info, default) end ---@private -function highlight.link(higroup, link_to, force) +function M.link(higroup, link_to, force) vim.cmd(string.format([[highlight%s link %s %s]], force and "!" or " default", higroup, link_to)) end - --- Highlight range between two positions --- ---@param bufnr number of buffer to apply highlighting to ---@param ns namespace to add highlight to ---@param higroup highlight group to use for highlighting ----@param rtype type of range (:help setreg, default charwise) ----@param inclusive boolean indicating whether the range is end-inclusive (default false) ----@param priority number indicating priority of highlight (default 50) -function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive, priority) - rtype = rtype or 'v' - inclusive = inclusive or false - priority = priority or 50 +---@param start first position (tuple {line,col}) +---@param finish second position (tuple {line,col}) +---@param opts table with options: +-- - regtype type of range (:help setreg, default charwise) +-- - inclusive boolean indicating whether the range is end-inclusive (default false) +-- - priority number indicating priority of highlight (default priorities.user) +function M.range(bufnr, ns, higroup, start, finish, opts) + opts = opts or {} + local regtype = opts.regtype or "v" + local inclusive = opts.inclusive or false + local priority = opts.priority or M.priorities.user -- sanity check - if start[2] < 0 or finish[1] < start[1] then return end + if start[2] < 0 or finish[1] < start[1] then + return + end - local region = vim.region(bufnr, start, finish, rtype, inclusive) + local region = vim.region(bufnr, start, finish, regtype, inclusive) for linenr, cols in pairs(region) do local end_row if cols[2] == -1 then @@ -46,13 +58,12 @@ function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive, pr end_row = end_row, end_col = cols[2], priority = priority, - strict = false + strict = false, }) end - end -local yank_ns = api.nvim_create_namespace('hlyank') +local yank_ns = api.nvim_create_namespace("hlyank") --- Highlight the yanked region --- --- use from init.vim via @@ -62,26 +73,40 @@ local yank_ns = api.nvim_create_namespace('hlyank') --- customize conditions (here: do not highlight a visual selection) via --- au TextYankPost * lua vim.highlight.on_yank {on_visual=false} --- --- @param opts dictionary with options controlling the highlight: +-- @param opts table with options controlling the highlight: -- - higroup highlight group for yanked region (default "IncSearch") -- - timeout time in ms before highlight is cleared (default 150) -- - on_macro highlight when executing macro (default false) -- - on_visual highlight when yanking visual selection (default true) -- - event event structure (default vim.v.event) -function highlight.on_yank(opts) - vim.validate { - opts = { opts, - function(t) if t == nil then return true else return type(t) == 'table' end end, - 'a table or nil to configure options (see `:h highlight.on_yank`)', - }} +function M.on_yank(opts) + vim.validate({ + opts = { + opts, + function(t) + if t == nil then + return true + else + return type(t) == "table" + end + end, + "a table or nil to configure options (see `:h highlight.on_yank`)", + }, + }) opts = opts or {} local event = opts.event or vim.v.event local on_macro = opts.on_macro or false local on_visual = (opts.on_visual ~= false) - if (not on_macro) and vim.fn.reg_executing() ~= '' then return end - if event.operator ~= 'y' or event.regtype == '' then return end - if (not on_visual) and event.visual then return end + if not on_macro and vim.fn.reg_executing() ~= "" then + return + end + if event.operator ~= "y" or event.regtype == "" then + return + end + if not on_visual and event.visual then + return + end local higroup = opts.higroup or "IncSearch" local timeout = opts.timeout or 150 @@ -92,19 +117,23 @@ function highlight.on_yank(opts) local pos1 = vim.fn.getpos("'[") local pos2 = vim.fn.getpos("']") - pos1 = {pos1[2] - 1, pos1[3] - 1 + pos1[4]} - pos2 = {pos2[2] - 1, pos2[3] - 1 + pos2[4]} - - highlight.range(bufnr, yank_ns, higroup, pos1, pos2, event.regtype, event.inclusive, 200) + pos1 = { pos1[2] - 1, pos1[3] - 1 + pos1[4] } + pos2 = { pos2[2] - 1, pos2[3] - 1 + pos2[4] } - vim.defer_fn( - function() - if api.nvim_buf_is_valid(bufnr) then - api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) - end - end, - timeout + M.range( + bufnr, + yank_ns, + higroup, + pos1, + pos2, + { regtype = event.regtype, inclusive = event.inclusive, priority = M.priorities.user } ) + + vim.defer_fn(function() + if api.nvim_buf_is_valid(bufnr) then + api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) + end + end, timeout) end -return highlight +return M diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua index d53b790746..1be40b0081 100644 --- a/runtime/lua/vim/keymap.lua +++ b/runtime/lua/vim/keymap.lua @@ -25,8 +25,8 @@ local keymap = {} --- vim.keymap.set('n', 'asdf', require('jkl').my_fun) --- </pre> --- ---- the require('jkl') gets evaluated during this call in order to access the function. If you want to ---- avoid this cost at startup you can wrap it in a function, for example: +--- the ``require('jkl')`` gets evaluated during this call in order to access the function. +--- If you want to avoid this cost at startup you can wrap it in a function, for example: --- <pre> --- vim.keymap.set('n', 'asdf', function() return require('jkl').my_fun() end) --- </pre> @@ -42,7 +42,7 @@ local keymap = {} --- |nvim_replace_termcodes()| is applied to the result of Lua expr maps. --- - remap: (boolean) Make the mapping recursive. This is the --- inverse of the "noremap" option from |nvim_set_keymap()|. ---- Default `true` if `lhs` is a string starting with `<plug>` (case-insensitive), `false` otherwise. +--- Default `false`. ---@see |nvim_set_keymap()| function keymap.set(mode, lhs, rhs, opts) vim.validate { @@ -66,8 +66,8 @@ function keymap.set(mode, lhs, rhs, opts) opts.replace_keycodes = nil if opts.remap == nil then - -- remap by default on <plug> mappings and don't otherwise. - opts.noremap = is_rhs_luaref or rhs:lower():match("^<plug>") == nil + -- default remap value is false + opts.noremap = true else -- remaps behavior is opposite of noremap option. opts.noremap = not opts.remap diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 8d11b4621c..105e7c4621 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -1689,7 +1689,7 @@ end --- --- Currently only supports a single client. This can be set via --- `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach` ---- via `vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`. +--- via ``vim.api.nvim_buf_set_option(bufnr, 'formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')``. --- ---@param opts table options for customizing the formatting expression which takes the --- following optional keys: diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 68942ae11a..614d83f565 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -104,8 +104,10 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id) severity = severity_lsp_to_vim(diagnostic.severity), message = diagnostic.message, source = diagnostic.source, + code = diagnostic.code, user_data = { lsp = { + -- usage of user_data.lsp.code is deprecated in favor of the top-level code field code = diagnostic.code, codeDescription = diagnostic.codeDescription, tags = diagnostic.tags, @@ -120,7 +122,8 @@ end ---@private local function diagnostic_vim_to_lsp(diagnostics) return vim.tbl_map(function(diagnostic) - return vim.tbl_extend("error", { + return vim.tbl_extend("keep", { + -- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp range = { start = { line = diagnostic.lnum, @@ -134,6 +137,7 @@ local function diagnostic_vim_to_lsp(diagnostics) severity = severity_vim_to_lsp(diagnostic.severity), message = diagnostic.message, source = diagnostic.source, + code = diagnostic.code, }, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {}) end, diagnostics) end diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a997b887d9..f5aefd4402 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -336,7 +336,7 @@ local function location_handler(_, result, ctx, _) title = 'LSP locations', items = util.locations_to_items(result, client.offset_encoding) }) - api.nvim_command("copen") + api.nvim_command("botright copen") end else util.jump_to_location(result, client.offset_encoding) @@ -430,7 +430,7 @@ local make_call_hierarchy_handler = function(direction) end end vim.fn.setqflist({}, ' ', {title = 'LSP call hierarchy', items = items}) - api.nvim_command("copen") + api.nvim_command("botright copen") end end diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua index 0f4e5b572b..9955fff3e2 100644 --- a/runtime/lua/vim/lsp/sync.lua +++ b/runtime/lua/vim/lsp/sync.lua @@ -131,13 +131,30 @@ end ---@param offset_encoding string utf-8|utf-16|utf-32|nil (fallback to utf-8) ---@returns table<int, int> line_idx, byte_idx, and char_idx of first change position local function compute_start_range(prev_lines, curr_lines, firstline, lastline, new_lastline, offset_encoding) + local char_idx + local byte_idx -- If firstline == lastline, no existing text is changed. All edit operations -- occur on a new line pointed to by lastline. This occurs during insertion of -- new lines(O), the new newline is inserted at the line indicated by -- new_lastline. + if firstline == lastline then + local line_idx + local line = prev_lines[firstline - 1] + if line then + line_idx = firstline - 1 + byte_idx = #line + 1 + char_idx = compute_line_length(line, offset_encoding) + 1 + else + line_idx = firstline + byte_idx = 1 + char_idx = 1 + end + return { line_idx = line_idx, byte_idx = byte_idx, char_idx = char_idx } + end + -- If firstline == new_lastline, the first change occurred on a line that was deleted. -- In this case, the first byte change is also at the first byte of firstline - if firstline == new_lastline or firstline == lastline then + if firstline == new_lastline then return { line_idx = firstline, byte_idx = 1, char_idx = 1 } end @@ -158,8 +175,6 @@ local function compute_start_range(prev_lines, curr_lines, firstline, lastline, end -- Convert byte to codepoint if applicable - local char_idx - local byte_idx if start_byte_idx == 1 or (#prev_line == 0 and start_byte_idx == 1)then byte_idx = start_byte_idx char_idx = 1 diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index d22c00ae76..59ab3d7e1f 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -480,7 +480,7 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding) -- Remove final line if needed local fix_eol = has_eol_text_edit - fix_eol = fix_eol and api.nvim_buf_get_option(bufnr, 'fixeol') + fix_eol = fix_eol and (api.nvim_buf_get_option(bufnr, 'eol') or (api.nvim_buf_get_option(bufnr, 'fixeol') and not api.nvim_buf_get_option('binary'))) fix_eol = fix_eol and get_line(bufnr, max - 1) == '' if fix_eol then vim.api.nvim_buf_set_lines(bufnr, -2, -1, false, {}) @@ -1551,9 +1551,7 @@ do --[[ References ]] document_highlight_kind[kind], { start_line, start_idx }, { end_line, end_idx }, - nil, - false, - 40) + { priority = vim.highlight.priorities.user }) end end end diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index e170befa4c..3eb332279a 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -1,8 +1,10 @@ -- Functions shared by Nvim and its test-suite. -- --- The singular purpose of this module is to share code with the Nvim --- test-suite. If, in the future, Nvim itself is used to run the test-suite --- instead of "vanilla Lua", these functions could move to src/nvim/lua/vim.lua +-- These are "pure" lua functions not depending of the state of the editor. +-- Thus they should always be available whenever nvim-related lua code is run, +-- regardless if it is code in the editor itself, or in worker threads/processes, +-- or the test suite. (Eventually the test suite will be run in a worker process, +-- so this wouldn't be a separate case to consider) local vim = vim or {} @@ -329,7 +331,7 @@ end --- Add the reverse lookup values to an existing table. --- For example: ---- `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` +--- ``tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }`` -- --Do note that it *modifies* the input. ---@param o table The table to add the reverse to. diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 22b528838c..b6f61cfb2e 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -22,7 +22,21 @@ local _link_default_highlight_once = function(from, to) return from end -TSHighlighter.hl_map = { +-- If @definition.special does not exist use @definition instead +local subcapture_fallback = { + __index = function(self, capture) + local rtn + local shortened = capture + while not rtn and shortened do + shortened = shortened:match('(.*)%.') + rtn = shortened and rawget(self, shortened) + end + rawset(self, capture, rtn or "__notfound") + return rtn + end +} + +TSHighlighter.hl_map = setmetatable({ ["error"] = "Error", -- Miscs @@ -66,7 +80,7 @@ TSHighlighter.hl_map = { ["type.builtin"] = "Type", ["structure"] = "Structure", ["include"] = "Include", -} +}, subcapture_fallback) ---@private local function is_highlight_name(capture_name) diff --git a/runtime/menu.vim b/runtime/menu.vim index 701dd33cdd..956b941971 100644 --- a/runtime/menu.vim +++ b/runtime/menu.vim @@ -569,9 +569,9 @@ func! s:XxdConv() %!mc vim:xxd else call s:XxdFind() - exe '%!' . g:xxdprogram + exe ':%!' . g:xxdprogram endif - if getline(1) =~ "^0000000:" " only if it worked + if getline(1) =~ "^00000000:" " only if it worked set ft=xxd endif let &mod = mod @@ -583,7 +583,7 @@ func! s:XxdBack() %!mc vim:xxd -r else call s:XxdFind() - exe '%!' . g:xxdprogram . ' -r' + exe ':%!' . g:xxdprogram . ' -r' endif set ft= doautocmd filetypedetect BufReadPost diff --git a/runtime/spell/cleanadd.vim b/runtime/spell/cleanadd.vim new file mode 100644 index 0000000000..6dc0692186 --- /dev/null +++ b/runtime/spell/cleanadd.vim @@ -0,0 +1,32 @@ +" Vim script to clean the ll.xxxxx.add files of commented out entries +" Author: Antonio Colombo, Bram Moolenaar +" Last Update: 2008 Jun 3 + +" Time in seconds after last time an ll.xxxxx.add file was updated +" Default is one second. +" If you invoke this script often set it to something bigger, e.g. 60 * 60 +" (one hour) +if !exists("g:spell_clean_limit") + let g:spell_clean_limit = 1 +endif + +" Loop over all the runtime/spell/*.add files. +" Delete all comment lines, except the ones starting with ##. +for s:fname in split(globpath(&rtp, "spell/*.add"), "\n") + if filewritable(s:fname) && localtime() - getftime(s:fname) > g:spell_clean_limit + if exists('*fnameescape') + let s:f = fnameescape(s:fname) + else + let s:f = escape(s:fname, ' \|<') + endif + silent exe "tab split " . s:f + echo "Processing" s:f + silent! g/^#[^#]/d + silent update + close + unlet s:f + endif +endfor +unlet s:fname + +echo "Done" diff --git a/runtime/syntax/structurizr.vim b/runtime/syntax/structurizr.vim index 73629b1495..ab9e4ee609 100644 --- a/runtime/syntax/structurizr.vim +++ b/runtime/syntax/structurizr.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Structurizr DSL " Maintainer: Bastian Venthur <venthur@debian.org> -" Last Change: 2021-08-16 +" Last Change: 2022-02-15 " Remark: For a language reference, see " https://github.com/structurizr/dsl @@ -30,6 +30,7 @@ syn keyword skeyword deployment syn keyword skeyword deploymentenvironment syn keyword skeyword deploymentgroup syn keyword skeyword deploymentnode +syn keyword skeyword description syn keyword skeyword dynamic syn keyword skeyword element syn keyword skeyword enterprise @@ -37,7 +38,6 @@ syn keyword skeyword exclude syn keyword skeyword filtered syn keyword skeyword group syn keyword skeyword healthcheck -syn keyword skeyword impliedrelationships syn keyword skeyword include syn keyword skeyword infrastructurenode syn keyword skeyword model @@ -51,6 +51,7 @@ syn keyword skeyword styles syn keyword skeyword systemcontext syn keyword skeyword systemlandscape syn keyword skeyword tags +syn keyword skeyword technology syn keyword skeyword terminology syn keyword skeyword theme syn keyword skeyword title @@ -63,7 +64,11 @@ syn match skeyword "\!adrs\s\+" syn match skeyword "\!constant\s\+" syn match skeyword "\!docs\s\+" syn match skeyword "\!identifiers\s\+" +syn match skeyword "\!impliedrelationships\s\+" syn match skeyword "\!include\s\+" +syn match skeyword "\!plugin\s\+" +syn match skeyword "\!ref\s\+" +syn match skeyword "\!script\s\+" syn region sstring oneline start='"' end='"' diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim index 41993b65b0..0bc233fc2a 100644 --- a/runtime/syntax/vim.vim +++ b/runtime/syntax/vim.vim @@ -46,14 +46,14 @@ syn match vimTermOption contained "t_%i" syn match vimTermOption contained "t_k;" " unsupported settings: these are supported by vi but don't do anything in vim {{{2 -syn keyword vimErrSetting contained hardtabs ht w1200 w300 w9600 +syn keyword vimErrSetting contained hardtabs ht w1200 w300 w9600 "}}}2 syn case ignore " Highlight commonly used Groupnames {{{2 -syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo +syn keyword vimGroup contained Comment Constant String Character Number Boolean Float Identifier Function Statement Conditional Repeat Label Operator Keyword Exception PreProc Include Define Macro PreCondit Type StorageClass Structure Typedef Special SpecialChar Tag Delimiter SpecialComment Debug Underlined Ignore Error Todo " Default highlighting groups {{{2 -syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu +syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineFold CursorLineNr CursorLineSign DiffAdd DiffChange DiffDelete DiffText Directory EndOfBuffer ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question QuickFixLine Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu syn match vimHLGroup contained "Conceal" syn keyword vimOnlyHLGroup contained LineNrAbove LineNrBelow StatusLineTerm Terminal VisualNOS syn keyword nvimHLGroup contained Substitute TermCursor TermCursorNC @@ -88,10 +88,10 @@ if exists("g:vimsyn_folding") && g:vimsyn_folding =~# '[afhlmpPrt]' else com! -nargs=* VimFoldm <args> endif - if g:vimsyn_folding =~# 'p' - com! -nargs=* VimFoldp <args> fold - else - com! -nargs=* VimFoldp <args> + if g:vimsyn_folding =~# 'p' + com! -nargs=* VimFoldp <args> fold + else + com! -nargs=* VimFoldp <args> endif if g:vimsyn_folding =~# 'P' com! -nargs=* VimFoldP <args> fold @@ -148,8 +148,8 @@ syn match vimNumber '-\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\=' skipwhite nextgro syn match vimNumber '\<0[xX]\x\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\%(^\|\A\)\zs#\x\{6}' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment syn match vimNumber '\<0[zZ][a-zA-Z0-9.]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment -syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[0-7]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment +syn match vimNumber '0[bB][01]\+' skipwhite nextgroup=vimGlobal,vimSubst,vimCommand,vimComment,vim9Comment " All vimCommands are contained by vimIsCommand. {{{2 syn match vimCmdSep "[:|]\+" skipwhite nextgroup=vimAddress,vimAutoCmd,vimEcho,vimIsCommand,vimExtCmd,vimFilter,vimLet,vimMap,vimMark,vimSet,vimSyntax,vimUserCmd @@ -574,7 +574,7 @@ syn match vimHiBang contained "!" skipwhite nextgroup=@vimHighlightCluster syn match vimHiGroup contained "\i\+" syn case ignore -syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline undercurl +syn keyword vimHiAttrib contained none bold inverse italic nocombine reverse standout strikethrough underline underlineline undercurl underdot underdash syn keyword vimFgBgAttrib contained none bg background fg foreground syn case match syn match vimHiAttribList contained "\i\+" contains=vimHiAttrib |