diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/dist/ft.vim | 19 | ||||
-rw-r--r-- | runtime/doc/api.txt | 100 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 8 | ||||
-rw-r--r-- | runtime/doc/filetype.txt | 1 | ||||
-rw-r--r-- | runtime/doc/index.txt | 6 | ||||
-rw-r--r-- | runtime/doc/insert.txt | 8 | ||||
-rw-r--r-- | runtime/doc/intro.txt | 7 | ||||
-rw-r--r-- | runtime/doc/lua.txt | 14 | ||||
-rw-r--r-- | runtime/doc/nvim_terminal_emulator.txt | 5 | ||||
-rw-r--r-- | runtime/doc/options.txt | 7 | ||||
-rw-r--r-- | runtime/doc/provider.txt | 1 | ||||
-rw-r--r-- | runtime/doc/repeat.txt | 8 | ||||
-rw-r--r-- | runtime/doc/treesitter.txt | 2 | ||||
-rw-r--r-- | runtime/doc/usr_05.txt | 6 | ||||
-rw-r--r-- | runtime/filetype.vim | 5 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/shared.lua | 11 |
17 files changed, 153 insertions, 57 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index ac80659113..48a9657cf5 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -264,6 +264,13 @@ func dist#ft#ProtoCheck(default) endfunc func dist#ft#FTm() + if exists("g:filetype_m") + exe "setf " . g:filetype_m + return + endif + + let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|for\|function\|if\|methods\|parfor\|properties\|switch\|while\)\>' + let n = 1 let saw_comment = 0 " Whether we've seen a multiline comment leader. while n < 100 @@ -278,6 +285,13 @@ func dist#ft#FTm() setf objc return endif + if line =~ '^\s*\%(#\|%!\|[#%]{\=\s*$\)' || + \ line =~ '^\s*unwind_protect\>' || + \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators + setf octave + return + endif + " TODO: could be Matlab or Octave if line =~ '^\s*%' setf matlab return @@ -298,11 +312,8 @@ func dist#ft#FTm() " or Murphi based on the comment leader. Assume the former as it is more " common. setf objc - elseif exists("g:filetype_m") - " Use user specified default filetype for .m - exe "setf " . g:filetype_m else - " Default is matlab + " Default is Matlab setf matlab endif endfunc diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index dae7986fdb..df345e4981 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -134,6 +134,14 @@ lines, 0-based columns): |nvim_win_get_cursor()| |nvim_win_set_cursor()| +Exception: the following API functions use |extmarks| indexing (0-based +indices, end-inclusive): + + |nvim_buf_del_extmark()| + |nvim_buf_get_extmark_by_id()| + |nvim_buf_get_extmarks()| + |nvim_buf_set_extmark()| + *api-fast* Most API functions are "deferred": they are queued on the main loop and processed sequentially with normal input. So if the editor is waiting for @@ -436,36 +444,76 @@ Example: create a float with scratch buffer: > > ============================================================================== -Extended marks *api-extended-marks* +Extended marks *api-extended-marks* *extmarks* Extended marks (extmarks) represent buffer annotations that track text changes -in the buffer. They could be used to represent cursors, folds, misspelled -words, and anything else that needs to track a logical location in the buffer -over time. +in the buffer. They can represent cursors, folds, misspelled words, anything +that needs to track a logical location in the buffer over time. |api-indexing| + +Extmark position works like "bar" cursor: it exists between characters. Thus +the maximum extmark index on a line is 1 more than the character index: > + + f o o b a r line contents + 0 1 2 3 4 5 character positions (0-based) + 0 1 2 3 4 5 6 extmark positions (0-based) + +Extmarks have "forward gravity": if you place the cursor directly on an +extmark position and enter some text, the extmark migrates forward. > + + f o o|b a r line (| = cursor) + 3 extmark + + f o o z|b a r line (| = cursor) + 4 extmark (after typing "z") + +If an extmark is on the last index of a line and you inputsa newline at that +point, the extmark will accordingly migrate to the next line: > + + f o o z b a r| line (| = cursor) + 7 extmark + + f o o z b a r first line + extmarks (none present) + | second line (| = cursor) + 0 extmark (after typing <CR>) + Example: -We will set an extmark at the first row and third column. |api-indexing| is -zero-indexed, so we use row=0 and column=2. Passing id=0 creates a new mark -and returns the id: > +Let's set an extmark at the first row (row=0) and third column (column=2). +|api-indexing| Passing id=0 creates a new mark and returns the id: > + 01 2345678 + 0 ex|ample.. +< ^ extmark position +> let g:mark_ns = nvim_create_namespace('myplugin') - let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 0, 2, {}) - -We can get a mark by its id: > + let g:mark_id = nvim_buf_set_extmark(0, g:mark_ns, 0, 2, {}) +< +We can get the mark by its id: > - echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id) + echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {}) => [0, 2] -We can get all marks in a buffer for our namespace (or by a range): > +We can get all marks in a buffer by |namespace| (or by a range): > echo nvim_buf_get_extmarks(0, g:mark_ns, 0, -1, {}) => [[1, 0, 2]] -Deleting all text surrounding an extmark does not remove the extmark. To -remove an extmark use |nvim_buf_del_extmark()|. +Deleting all surrounding text does NOT remove an extmark! To remove extmarks +use |nvim_buf_del_extmark()|. Deleting "x" in our example: > + + 0 12345678 + 0 e|ample.. +< ^ extmark position +> + echo nvim_buf_get_extmark_by_id(0, g:mark_ns, g:mark_id, {}) + => [0, 1] +< + Note: Extmark "gravity" decides how it will shift after a text edit. + See |nvim_buf_set_extmark()| -Namespaces allow your plugin to manage only its own extmarks, ignoring those +Namespaces allow any plugin to manage only its own extmarks, ignoring those created by another plugin. Extmark positions changed by an edit will be restored on undo/redo. Creating @@ -779,10 +827,9 @@ nvim_feedkeys({keys}, {mode}, {escape_csi}) *nvim_feedkeys()* On execution error: does not fail, but updates v:errmsg. - If you need to input sequences like <C-o> use - |nvim_replace_termcodes| to replace the termcodes and then - pass the resulting string to nvim_feedkeys. You'll also want - to enable escape_csi. + To input sequences like <C-o> use |nvim_replace_termcodes()| + (typically with escape_csi=true) to replace the keycodes. Then + pass the result to nvim_feedkeys(). Example: > :let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true) @@ -2072,7 +2119,7 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()* *nvim_buf_get_extmark_by_id()* nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts}) - Returns position for a given extmark id + Gets the position (0-indexed) of an extmark {id}. Parameters: ~ {buffer} Buffer handle, or 0 for current buffer @@ -2082,7 +2129,8 @@ nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts}) • details: Whether to include the details dict Return: ~ - (row, col) tuple or empty list () if extmark id was absent + 0-indexed (row, col) tuple or empty list () if extmark id + was absent *nvim_buf_get_extmarks()* nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts}) @@ -2122,10 +2170,12 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts}) Parameters: ~ {buffer} Buffer handle, or 0 for current buffer {ns_id} Namespace id from |nvim_create_namespace()| - {start} Start of range, given as (row, col) or valid - extmark id (whose position defines the bound) - {end} End of range, given as (row, col) or valid - extmark id (whose position defines the bound) + {start} Start of range, given as 0-indexed (row, col) or + valid extmark id (whose position defines the + bound) + {end} End of range (inclusive), given as 0-indexed + (row, col) or valid extmark id (whose position + defines the bound) {opts} Optional parameters. Keys: • limit: Maximum number of marks to return • details Whether to include the details dict diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 48c08acf78..2db8995eab 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4718,9 +4718,9 @@ getcurpos() Get the position of the cursor. This is like getpos('.'), but |winrestview()| for restoring more state. getcwd([{winnr}[, {tabnr}]]) *getcwd()* - With no arguments the result is a String, which is the name of - the current effective working directory. With {winnr} or - {tabnr} the working directory of that scope is returned. + With no arguments, returns the name of the effective + |current-directory|. With {winnr} or {tabnr} the working + directory of that scope is returned. Tabs and windows are identified by their respective numbers, 0 means current tab or window. Missing argument implies 0. Thus the following are equivalent: > @@ -9110,7 +9110,7 @@ system({cmd} [, {input}]) *system()* *E677* *E5677* Note: system() cannot write to or read from backgrounded ("&") shell commands, e.g.: > - :echo system("cat - &", "foo")) + :echo system("cat - &", "foo") < which is equivalent to: > $ echo foo | bash -c 'cat - &' < The pipes are disconnected (unless overridden by shell diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 894d1627ab..4d0fdd71cc 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -135,6 +135,7 @@ can be used to overrule the filetype used for certain extensions: *.inc g:filetype_inc *.w g:filetype_w |ft-cweb-syntax| *.i g:filetype_i |ft-progress-syntax| + *.m g:filetype_m |ft-mathematica-syntax| *.p g:filetype_p |ft-pascal-syntax| *.pp g:filetype_pp |ft-pascal-syntax| *.sh g:bash_is_sh |ft-sh-syntax| diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 9a279ad880..baa7bc1992 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -155,6 +155,7 @@ commands in CTRL-X submode *i_CTRL-X_index* |i_CTRL-X_CTRL-Y| CTRL-X CTRL-Y scroll down |i_CTRL-X_CTRL-U| CTRL-X CTRL-U complete with 'completefunc' |i_CTRL-X_CTRL-V| CTRL-X CTRL-V complete like in : command line +|i_CTRL-X_CTRL-Z| CTRL-X CTRL-Z stop completion, keeping the text as-is |i_CTRL-X_CTRL-]| CTRL-X CTRL-] complete tags |i_CTRL-X_s| CTRL-X s spelling suggestions @@ -1096,8 +1097,9 @@ tag command action in Command-line editing mode ~ ============================================================================== 5. Terminal mode *terminal-mode-index* -In a |terminal| buffer all keys except |CTRL-\_CTRL-N| are forwarded to the -terminal job. Use CTRL-\_CTRL-N to go to Normal mode. +In a |terminal| buffer all keys except CTRL-\ are forwarded to the terminal +job. If CTRL-\ is pressed, the next key is forwarded unless it is CTRL-N. +Use |CTRL-\_CTRL-N| to go to Normal mode. You found it, Arthur! *holy-grail* diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 4500e2ba9b..8f6de3e36f 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -622,6 +622,8 @@ Completion can be done for: 12. Spelling suggestions |i_CTRL-X_s| 13. keywords in 'complete' |i_CTRL-N| |i_CTRL-P| +Additionally, |i_CTRL-X_CTRL-Z| stops completion without changing the text. + All these, except CTRL-N and CTRL-P, are done in CTRL-X mode. This is a sub-mode of Insert and Replace modes. You enter CTRL-X mode by typing CTRL-X and one of the CTRL-X commands. You exit CTRL-X mode by typing a key that is @@ -1022,6 +1024,12 @@ CTRL-P Find previous match for words that start with the other contexts unless a double CTRL-X is used. +Stop completion *compl-stop* + + *i_CTRL-X_CTRL-Z* +CTRL-X CTRL-Z Stop completion without changing the text. + + FUNCTIONS FOR FINDING COMPLETIONS *complete-functions* This applies to 'completefunc' and 'omnifunc'. diff --git a/runtime/doc/intro.txt b/runtime/doc/intro.txt index f739e2e88b..2baf3a247f 100644 --- a/runtime/doc/intro.txt +++ b/runtime/doc/intro.txt @@ -454,9 +454,10 @@ Ex mode Like Command-line mode, but after entering a command command line. |Ex-mode| *Terminal-mode* -Terminal mode In Terminal mode all input (except |c_CTRL-\_CTRL-N|) - is sent to the process running in the current - |terminal| buffer. +Terminal mode In Terminal mode all input (except CTRL-\) is sent to + the process running in the current |terminal| buffer. + If CTRL-\ is pressed, the next key is sent unless it + is CTRL-N (|CTRL-\_CTRL-N|). If the 'showmode' option is on "-- TERMINAL --" is shown at the bottom of the window. diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 3fd3875557..5731569947 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -907,7 +907,7 @@ vim.fn.{func}({...}) *vim.fn* To call autoload functions, use the syntax: > vim.fn['some#function']({...}) < - Unlike vim.api.|nvim_call_function| this converts directly between Vim + Unlike vim.api.|nvim_call_function()| this converts directly between Vim objects and Lua objects. If the Vim function returns a float, it will be represented directly as a Lua number. Empty lists and dictionaries both are represented by an empty table. @@ -1268,7 +1268,17 @@ schedule_wrap({cb}) *vim.schedule_wrap()* deep_equal({a}, {b}) *vim.deep_equal()* - TODO: Documentation + Deep compare values for equality + + Tables are compared recursively unless they both provide the `eq` methamethod. + All other types are compared using the equality `==` operator. + + Parameters: ~ + {a} first value + {b} second value + + Return: ~ + `true` if values are equals, else `false` . deepcopy({orig}) *vim.deepcopy()* Returns a deep copy of the given object. Non-table objects are diff --git a/runtime/doc/nvim_terminal_emulator.txt b/runtime/doc/nvim_terminal_emulator.txt index 0bf58f85fc..f61d2905be 100644 --- a/runtime/doc/nvim_terminal_emulator.txt +++ b/runtime/doc/nvim_terminal_emulator.txt @@ -47,8 +47,9 @@ Input *terminal-input* To send input, enter |Terminal-mode| using any command that would enter "insert mode" in a normal buffer, such as |i| or |:startinsert|. In this mode all keys -except <C-\><C-N> are sent to the underlying program. Use <C-\><C-N> to return -to normal-mode. |CTRL-\_CTRL-N| +except <C-\> are sent to the underlying program. If <C-\> is pressed, the +next key is sent unless it is <C-N>. Use <C-\><C-N> to return to normal-mode. +|CTRL-\_CTRL-N| Terminal-mode forces these local options: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 90ba3b86d9..e2248e5d9a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5476,7 +5476,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'showbreak'* *'sbr'* *E595* 'showbreak' 'sbr' string (default "") - global + global or local to window |global-local| String to put at the start of lines that have been wrapped. Useful values are "> " or "+++ ": > :set showbreak=>\ @@ -5490,7 +5490,10 @@ A jump table for the options with a short description can be found at |Q_op|. Note that tabs after the showbreak will be displayed differently. If you want the 'showbreak' to appear in between line numbers, add the "n" flag to 'cpoptions'. - + A window-local value overrules a global value. If the global value is + set and you want no value in the current window use NONE: > + :setlocal showbreak=NONE +< *'showcmd'* *'sc'* *'noshowcmd'* *'nosc'* 'showcmd' 'sc' boolean (Vim default: on, Vi default: off) global diff --git a/runtime/doc/provider.txt b/runtime/doc/provider.txt index be895f9e4e..b785010699 100644 --- a/runtime/doc/provider.txt +++ b/runtime/doc/provider.txt @@ -207,6 +207,7 @@ registers. Nvim looks for these clipboard tools, in order of priority: - lemonade (for SSH) https://github.com/pocke/lemonade - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ - win32yank (Windows) + - termux (via termux-clipboard-set, termux-clipboard-set) - tmux (if $TMUX is set) *g:clipboard* diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index ed770434d5..61428aefb0 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -201,10 +201,12 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. When [!] is included, all found files are sourced. Else only the first found file is sourced. - When [where] is omitted only 'runtimepath' is used. + When [where] is omitted, first 'runtimepath' is + searched, then directories under "start" in 'packpath' + are searched. Other values: - START search under "start" in 'packpath' - OPT search under "opt" in 'packpath' + START search only under "start" in 'packpath' + OPT search only under "opt" in 'packpath' PACK search under "start" and "opt" in 'packpath' ALL first use 'runtimepath', then search diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 86316b8ac5..ac10aeec88 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -296,7 +296,7 @@ for those who want to experiment with this feature and contribute to its development. Highlights are defined in the same query format as in the tree-sitter highlight -crate, which some limitations and additions. Set a highlight query for a +crate, with some limitations and additions. Set a highlight query for a buffer with this code: > local query = [[ diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index d0206ba82d..2edef0ca23 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -175,10 +175,8 @@ This switches on three very clever mechanisms: *restore-cursor* *last-position-jump* > - autocmd BufReadPost * - \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' - \ | exe "normal! g`\"" - \ | endif + autocmd BufRead * autocmd FileType <buffer> ++once + \ if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif Another autocommand. This time it is used after reading any file. The complicated stuff after it checks if the '" mark is defined, and jumps to it diff --git a/runtime/filetype.vim b/runtime/filetype.vim index d85f5f1be0..7358f8f2b3 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1025,7 +1025,7 @@ au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown " Mason au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason -" Mathematica, Matlab, Murphi or Objective C +" Mathematica, Matlab, Murphi, Objective C or Octave au BufNewFile,BufRead *.m call dist#ft#FTm() " Mathematica notebook @@ -1171,6 +1171,9 @@ au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit,*.mlt,*.mlp,*.mlip,*.mli " Occam au BufNewFile,BufRead *.occ setf occam +" Octave +au BufNewFile,BufRead octave.conf,.octaverc,octaverc setf octave + " Omnimark au BufNewFile,BufRead *.xom,*.xin setf omnimark diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 41a62da522..ccd325b1ac 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -449,7 +449,7 @@ end --- endif --- return sl --- endfunction ---- let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus() +--- autocmd BufWinEnter * let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus() --- </pre> --- ---@param bufnr number The buffer number diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 032b2b2cb5..18c1e21049 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -267,18 +267,23 @@ function vim.tbl_deep_extend(behavior, ...) end --- Deep compare values for equality +--- +--- Tables are compared recursively unless they both provide the `eq` methamethod. +--- All other types are compared using the equality `==` operator. +---@param a first value +---@param b second value +---@returns `true` if values are equals, else `false`. function vim.deep_equal(a, b) if a == b then return true end if type(a) ~= type(b) then return false end if type(a) == 'table' then - -- TODO improve this algorithm's performance. for k, v in pairs(a) do if not vim.deep_equal(v, b[k]) then return false end end - for k, v in pairs(b) do - if not vim.deep_equal(v, a[k]) then + for k, _ in pairs(b) do + if a[k] == nil then return false end end |