diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/api.txt | 25 | ||||
-rw-r--r-- | runtime/doc/autocmd.txt | 3 | ||||
-rw-r--r-- | runtime/doc/channel.txt | 2 | ||||
-rw-r--r-- | runtime/doc/develop.txt | 2 | ||||
-rw-r--r-- | runtime/doc/lsp-extension.txt | 2 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 4 | ||||
-rw-r--r-- | runtime/doc/lua.txt | 2 | ||||
-rw-r--r-- | runtime/doc/term.txt | 2 | ||||
-rw-r--r-- | runtime/doc/treesitter.txt | 2 | ||||
-rw-r--r-- | runtime/filetype.lua | 6 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 81 | ||||
-rw-r--r-- | runtime/lua/vim/lsp.lua | 8 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 12 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/sync.lua | 2 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/languagetree.lua | 2 |
16 files changed, 107 insertions, 50 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index e73634c632..0daca0de53 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -45,7 +45,7 @@ start with a TCP/IP socket instead, use |--listen| with a TCP-style address: > More endpoints can be started with |serverstart()|. Note that localhost TCP sockets are generally less secure than named pipes, -and can lead to vunerabilities like remote code execution. +and can lead to vulnerabilities like remote code execution. Connecting to the socket is the easiest way a programmer can test the API, which can be done through any msgpack-rpc client library or full-featured @@ -198,7 +198,7 @@ any of these approaches: 2. Start Nvim with |--api-info|. Useful for statically-compiled clients. Example (requires Python "pyyaml" and "msgpack-python" modules): > - nvim --api-info | python -c 'import msgpack, sys, yaml; print yaml.dump(msgpack.unpackb(sys.stdin.read()))' + nvim --api-info | python -c 'import msgpack, sys, yaml; yaml.dump(msgpack.unpackb(sys.stdin.buffer.read()), sys.stdout)' < 3. Use the |api_info()| Vimscript function. > :lua print(vim.inspect(vim.fn.api_info())) @@ -468,7 +468,7 @@ extmark position and enter some text, the extmark migrates forward. > 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 +If an extmark is on the last index of a line and you inputs a newline at that point, the extmark will accordingly migrate to the next line: > f o o z b a r| line (| = cursor) @@ -667,14 +667,17 @@ nvim_add_user_command({name}, {command}, {*opts}) {opts} Optional command attributes. See |command-attributes| for more details. To use boolean attributes (such as |:command-bang| or - |:command-bar|) set the value to "true". When - using a Lua function for {command} you can also - provide a "desc" key that will be displayed - when listing commands. In addition to the - string options listed in |:command-complete|, - the "complete" key also accepts a Lua function - which works like the "customlist" completion - mode |:command-complete-customlist|. + |:command-bar|) set the value to "true". In + addition to the string options listed in + |:command-complete|, the "complete" key also + accepts a Lua function which works like the + "customlist" completion mode + |:command-completion-customlist|. Additional + parameters: + • desc: (string) Used for listing the command + when a Lua function is used for {command}. + • force: (boolean, default true) Override any + previous definition. nvim_call_atomic({calls}) *nvim_call_atomic()* Calls many API methods atomically. diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 3df8d5ced4..46d9a3b57a 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -840,6 +840,9 @@ RecordingLeave When a macro stops recording. register. |reg_recorded()| is only updated after this event. + Sets these |v:event| keys: + regcontents + regname *SessionLoadPost* SessionLoadPost After loading the session file created using the |:mksession| command. diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt index 5f376a600e..e14427494d 100644 --- a/runtime/doc/channel.txt +++ b/runtime/doc/channel.txt @@ -44,7 +44,7 @@ functions like |chansend()| consume channel ids. 2. Reading and writing raw bytes *channel-bytes* Channels opened by Vimscript functions operate with raw bytes by default. For -a job channel using RPC, bytes can still be read over its stderr. Similarily, +a job channel using RPC, bytes can still be read over its stderr. Similarly, only bytes can be written to Nvim's own stderr. *channel-callback* diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt index 7127c74134..178b0dc62b 100644 --- a/runtime/doc/develop.txt +++ b/runtime/doc/develop.txt @@ -105,7 +105,7 @@ in eval.c: - eval_call_provider(name, method, arguments, discard): calls provider#{name}#Call with the method and arguments. If discard is true, any - value returned by the provider will be discarded and and empty value be + value returned by the provider will be discarded and empty value will be returned. - eval_has_provider(name): Checks the `g:loaded_{name}_provider` variable which must be set to 2 by the provider script to indicate that it is diff --git a/runtime/doc/lsp-extension.txt b/runtime/doc/lsp-extension.txt index d13303ada6..6e9ad940c7 100644 --- a/runtime/doc/lsp-extension.txt +++ b/runtime/doc/lsp-extension.txt @@ -60,7 +60,7 @@ The example will: return nil end local dir = bufname - -- Just in case our algo is buggy, don't infinite loop. + -- Just in case our algorithm is buggy, don't infinite loop. for _ = 1, 100 do local did_change dir, did_change = dirname(dir) diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 614dd82443..bb42a87034 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -887,10 +887,10 @@ start_client({config}) *vim.lsp.start_client()* default true): Allow using incremental sync for buffer edits • debounce_text_changes (number, - default nil): Debounce didChange + default 150): Debounce didChange notifications to the server by the given number in milliseconds. No - debounce occurs if nil + debounce occurs if set to 0. • exit_timeout (number, default 500): Milliseconds to wait for server to exit cleanly after sending the diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index c6bca087c8..e3b66c94ba 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -274,7 +274,7 @@ arguments separated by " " (space) instead of "\t" (tab). lua << EOF local linenr = vim.api.nvim_win_get_cursor(0)[1] local curline = vim.api.nvim_buf_get_lines( - 0, linenr, linenr + 1, false)[1] + 0, linenr - 1, linenr, false)[1] print(string.format("Current line [%d] has %d bytes", linenr, #curline)) EOF diff --git a/runtime/doc/term.txt b/runtime/doc/term.txt index 935d958729..62e13285f5 100644 --- a/runtime/doc/term.txt +++ b/runtime/doc/term.txt @@ -133,7 +133,7 @@ capabilities as if they had been in the terminfo definition. If terminfo does not (yet) have this flag, Nvim will fall back to $TERM and other environment variables. It will add constructed "setrgbf" and "setrgbb" -capabilities in the case of the the "rxvt", "linux", "st", "tmux", and "iterm" +capabilities in the case of the "rxvt", "linux", "st", "tmux", and "iterm" terminal types, or when Konsole, genuine Xterm, a libvte terminal emulator version 0.36 or later, or a terminal emulator that sets the COLORTERM environment variable to "truecolor" is detected. diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 5f238fb2ff..7de6a0f890 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -210,7 +210,7 @@ Here is a list of built-in predicates : < `match?` *ts-predicate-match?* `vim-match?` *ts-predicate-vim-match?* - This will match if the provived vim regex matches the text + This will match if the provided vim regex matches the text corresponding to a node : > ((identifier) @constant (#match? @constant "^[A-Z_]+$")) < Note: the `^` and `$` anchors will respectively match the diff --git a/runtime/filetype.lua b/runtime/filetype.lua index 3177705b65..fcfc5701f0 100644 --- a/runtime/filetype.lua +++ b/runtime/filetype.lua @@ -9,7 +9,7 @@ end vim.cmd [[ augroup filetypedetect -au BufRead,BufNewFile * call v:lua.vim.filetype.match(str2nr(expand('<abuf>'))) +au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('<afile>')) " These *must* be sourced after the autocommand above is created runtime! ftdetect/*.vim @@ -20,3 +20,7 @@ let g:did_load_ftdetect = 1 augroup END ]] + +if not vim.g.ft_ignore_pat then + vim.g.ft_ignore_pat = "\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$" +end diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f7048f3709..54b20f7391 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -19,7 +19,13 @@ local function starsetf(ft) }} end +---@private +local function getline(bufnr, lnum) + return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1] +end + -- Filetypes based on file extension +-- luacheck: push no unused args local extension = { -- BEGIN EXTENSION ["8th"] = "8th", @@ -635,6 +641,13 @@ local extension = { tssop = "tssop", tutor = "tutor", twig = "twig", + ts = function(path, bufnr) + if getline(bufnr, 1):find("<%?xml") then + return "xml" + else + return "typescript" + end + end, tsx = "typescriptreact", uc = "uc", uit = "uil", @@ -774,6 +787,12 @@ local extension = { xml = function() vim.fn["dist#ft#FTxml"]() end, y = function() vim.fn["dist#ft#FTy"]() end, zsql = function() vim.fn["dist#ft#SQL"]() end, + txt = function(path, bufnr) + --helpfiles match *.txt, but should have a modeline as last line + if not getline(bufnr, -1):match("vim:.*ft=help") then + return "text" + end + end, -- END EXTENSION } @@ -1075,7 +1094,7 @@ local pattern = { [".*/etc/a2ps%.cfg"] = "a2ps", [".*/usr/share/alsa/alsa%.conf"] = "alsaconf", [".*/etc/asound%.conf"] = "alsaconf", - [".*/etc/apache2/sites-.*/.*%.com"] = "apache", + [".*/etc/apache2/sites%-.*/.*%.com"] = "apache", [".*/etc/httpd/.*%.conf"] = "apache", [".*/%.aptitude/config"] = "aptconf", ["[mM]akefile%.am"] = "automake", @@ -1096,7 +1115,7 @@ local pattern = { ["dictd.*%.conf"] = "dictdconf", [".*/etc/DIR_COLORS"] = "dircolors", [".*/etc/dnsmasq%.conf"] = "dnsmasq", - ["php%.ini-.*"] = "dosini", + ["php%.ini%-.*"] = "dosini", [".*/etc/pacman%.conf"] = "dosini", [".*/etc/yum%.conf"] = "dosini", [".*lvs"] = "dracula", @@ -1122,7 +1141,7 @@ local pattern = { [".*/boot/grub/grub%.conf"] = "grub", [".*/boot/grub/menu%.lst"] = "grub", [".*/etc/grub%.conf"] = "grub", - ["hg-editor-.*%.txt"] = "hgcommit", + ["hg%-editor%-.*%.txt"] = "hgcommit", [".*/etc/host%.conf"] = "hostconf", [".*/etc/hosts%.deny"] = "hostsaccess", [".*/etc/hosts%.allow"] = "hostsaccess", @@ -1190,7 +1209,7 @@ local pattern = { [".*/etc/serial%.conf"] = "setserial", [".*/etc/udev/cdsymlinks%.conf"] = "sh", [".*%._sst%.meta"] = "sisu", - [".*%.-sst%.meta"] = "sisu", + [".*%.%-sst%.meta"] = "sisu", [".*%.sst%.meta"] = "sisu", [".*/etc/slp%.conf"] = "slpconf", [".*/etc/slp%.reg"] = "slpreg", @@ -1199,7 +1218,7 @@ local pattern = { [".*/%.ssh/config"] = "sshconfig", [".*/etc/ssh/sshd_config%.d/.*%.conf"] = "sshdconfig", [".*/etc/sudoers"] = "sudoers", - ["svn-commit.*%.tmp"] = "svn", + ["svn%-commit.*%.tmp"] = "svn", [".*%.swift%.gyb"] = "swiftgyb", [".*/etc/sysctl%.conf"] = "sysctl", [".*/etc/sysctl%.d/.*%.conf"] = "sysctl", @@ -1253,20 +1272,20 @@ local pattern = { [".*/%.gitconfig%.d/.*"] = starsetf('gitconfig'), [".*/%.neomutt/neomuttrc.*"] = starsetf('neomuttrc'), [".*/Xresources/.*"] = starsetf('xdefaults'), - [".*/app-defaults/.*"] = starsetf('xdefaults'), + [".*/app%-defaults/.*"] = starsetf('xdefaults'), [".*/bind/db%..*"] = starsetf('bindzone'), [".*/debian/patches/.*"] = function() vim.fn["dist#ft#Dep3patch"]() end, [".*/etc/Muttrc%.d/.*"] = starsetf('muttrc'), [".*/etc/apache2/.*%.conf.*"] = starsetf('apache'), [".*/etc/apache2/conf%..*/.*"] = starsetf('apache'), - [".*/etc/apache2/mods-.*/.*"] = starsetf('apache'), - [".*/etc/apache2/sites-.*/.*"] = starsetf('apache'), + [".*/etc/apache2/mods%-.*/.*"] = starsetf('apache'), + [".*/etc/apache2/sites%-.*/.*"] = starsetf('apache'), [".*/etc/cron%.d/.*"] = starsetf('crontab'), [".*/etc/dnsmasq%.d/.*"] = starsetf('dnsmasq'), [".*/etc/httpd/conf%..*/.*"] = starsetf('apache'), [".*/etc/httpd/conf%.d/.*%.conf.*"] = starsetf('apache'), - [".*/etc/httpd/mods-.*/.*"] = starsetf('apache'), - [".*/etc/httpd/sites-.*/.*"] = starsetf('apache'), + [".*/etc/httpd/mods%-.*/.*"] = starsetf('apache'), + [".*/etc/httpd/sites%-.*/.*"] = starsetf('apache'), [".*/etc/logcheck/.*%.d.*/.*"] = starsetf('logcheck'), [".*/etc/modprobe%..*"] = starsetf('modconf'), [".*/etc/pam%.d/.*"] = starsetf('pamconf'), @@ -1276,7 +1295,7 @@ local pattern = { [".*/etc/sudoers%.d/.*"] = starsetf('sudoers'), [".*/etc/xinetd%.d/.*"] = starsetf('xinetd'), [".*/etc/yum%.repos%.d/.*"] = starsetf('dosini'), - [".*/gitolite-admin/conf/.*"] = starsetf('gitolite'), + [".*/gitolite%-admin/conf/.*"] = starsetf('gitolite'), [".*/named/db%..*"] = starsetf('bindzone'), [".*/tmp/lltmp.*"] = starsetf('gedcom'), [".*asterisk.*/.*voicemail%.conf.*"] = starsetf('asteriskvm'), @@ -1297,7 +1316,7 @@ local pattern = { ["access%.conf.*"] = starsetf('apache'), ["apache%.conf.*"] = starsetf('apache'), ["apache2%.conf.*"] = starsetf('apache'), - ["bash-fc[-%.]"] = function() vim.fn["dist#ft#SetFileTypeSH"]("bash") end, + ["bash%-fc[-%.]"] = function() vim.fn["dist#ft#SetFileTypeSH"]("bash") end, ["cabal%.project%..*"] = starsetf('cabalproject'), ["crontab%..*"] = starsetf('crontab'), ["drac%..*"] = starsetf('dracula'), @@ -1306,14 +1325,16 @@ local pattern = { ["lilo%.conf.*"] = starsetf('lilo'), ["neomuttrc.*"] = starsetf('neomuttrc'), ["proftpd%.conf.*"] = starsetf('apachestyle'), - ["reportbug-.*"] = starsetf('mail'), + ["reportbug%-.*"] = starsetf('mail'), ["sgml%.catalog.*"] = starsetf('catalog'), ["srm%.conf.*"] = starsetf('apache'), ["tmac%..*"] = starsetf('nroff'), ["zlog.*"] = starsetf('zsh'), ["zsh.*"] = starsetf('zsh'), + ["ae%d+%.txt"] = 'mail', -- END PATTERN } +-- luacheck: pop ---@private local function sort_by_priority(t) @@ -1336,6 +1357,11 @@ end local pattern_sorted = sort_by_priority(pattern) +---@private +local function normalize_path(path) + return (path:gsub("\\", "/")) +end + --- Add new filetype mappings. --- --- Filetype mappings can be added either by extension or by filename (either @@ -1398,11 +1424,11 @@ function M.add(filetypes) end for k, v in pairs(filetypes.filename or {}) do - filename[k] = v + filename[normalize_path(k)] = v end for k, v in pairs(filetypes.pattern or {}) do - pattern[k] = v + pattern[normalize_path(k)] = v end if filetypes.pattern then @@ -1428,15 +1454,22 @@ local function dispatch(ft, path, bufnr, ...) end ---@private -function M.match(bufnr) - local path = api.nvim_buf_get_name(bufnr) +function M.match(name, bufnr) + -- When fired from the main filetypedetect autocommand the {bufnr} argument is omitted, so we use + -- the current buffer. The {bufnr} argument is provided to allow extensibility in case callers + -- wish to perform filetype detection on buffers other than the current one. + bufnr = bufnr or api.nvim_get_current_buf() + + name = normalize_path(name) + -- First check for the simple case where the full path exists as a key + local path = vim.fn.resolve(vim.fn.fnamemodify(name, ":p")) if dispatch(filename[path], path, bufnr) then return end -- Next check against just the file name - local tail = vim.fn.fnamemodify(path, ":t") + local tail = vim.fn.fnamemodify(name, ":t") if dispatch(filename[tail], path, bufnr) then return end @@ -1447,7 +1480,15 @@ function M.match(bufnr) local ft = v[k][1] -- If the pattern contains a / match against the full path, otherwise just the tail local pat = "^" .. k .. "$" - local matches = k:find("/") and path:match(pat) or tail:match(pat) + local matches + if k:find("/") then + -- Similar to |autocmd-pattern|, if the pattern contains a '/' then check for a match against + -- both the short file name (as typed) and the full file name (after expanding to full path + -- and resolving symlinks) + matches = name:match(pat) or path:match(pat) + else + matches = tail:match(pat) + end if matches then if dispatch(ft, path, bufnr, matches) then return @@ -1456,7 +1497,7 @@ function M.match(bufnr) end -- Finally, check file extension - local ext = vim.fn.fnamemodify(path, ":e") + local ext = vim.fn.fnamemodify(name, ":e") if dispatch(extension[ext], path, bufnr) then return end diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index cfbabb12a6..7df0064b6b 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -256,7 +256,7 @@ local function validate_client_config(config) (not config.flags or not config.flags.debounce_text_changes or type(config.flags.debounce_text_changes) == 'number'), - "flags.debounce_text_changes must be nil or a number with the debounce time in milliseconds" + "flags.debounce_text_changes must be a number with the debounce time in milliseconds" ) local cmd, cmd_args = lsp._cmd_parts(config.cmd) @@ -383,8 +383,8 @@ do return end local state = state_by_client[client.id] - local debounce = client.config.flags.debounce_text_changes - if not debounce then + local debounce = client.config.flags.debounce_text_changes or 150 + if debounce == 0 then local changes = state.use_incremental_sync and incremental_changes(client) or full_changes() client.notify("textDocument/didChange", { textDocument = { @@ -897,7 +897,7 @@ function lsp.start_client(config) client.initialized = true uninitialized_clients[client_id] = nil client.workspace_folders = workspace_folders - -- TODO(mjlbach): Backwards compatbility, to be removed in 0.7 + -- TODO(mjlbach): Backwards compatibility, to be removed in 0.7 client.workspaceFolders = client.workspace_folders client.server_capabilities = assert(result.capabilities, "initialize result doesn't contain capabilities") -- These are the cleaned up capabilities we use for dynamically deciding diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 8e3ed9b002..543fdb0237 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -453,7 +453,7 @@ end --- 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`, eg: +--- by events such as `CursorHold`, e.g.: --- --- <pre> --- autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a1d3b2aa94..a48302cc4b 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -439,14 +439,20 @@ for k, fn in pairs(M) do }) if err then - local client = vim.lsp.get_client_by_id(ctx.client_id) - local client_name = client and client.name or string.format("client_id=%d", ctx.client_id) -- LSP spec: -- interface ResponseError: -- code: integer; -- message: string; -- data?: string | number | boolean | array | object | null; - return err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) + + -- Per LSP, don't show ContentModified error to the user. + if err.code ~= protocol.ErrorCodes.ContentModified then + local client = vim.lsp.get_client_by_id(ctx.client_id) + local client_name = client and client.name or string.format("client_id=%d", ctx.client_id) + + err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) + end + return end return fn(err, result, ctx, config) diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua index d01f45ad8f..0f4e5b572b 100644 --- a/runtime/lua/vim/lsp/sync.lua +++ b/runtime/lua/vim/lsp/sync.lua @@ -298,7 +298,7 @@ end ---@private -- rangelength depends on the offset encoding --- bytes for utf-8 (clangd with extenion) +-- bytes for utf-8 (clangd with extension) -- codepoints for utf-16 -- codeunits for utf-32 -- Line endings count here as 2 chars for \r\n (dos), 1 char for \n (unix), and 1 char for \r (mac) diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua index 594765761d..85fd5cd8e0 100644 --- a/runtime/lua/vim/treesitter/languagetree.lua +++ b/runtime/lua/vim/treesitter/languagetree.lua @@ -77,7 +77,7 @@ end --- Determines whether this tree is valid. --- If the tree is invalid, `parse()` must be called ---- to get the an updated tree. +--- to get the updated tree. function LanguageTree:is_valid() return self._valid end |