diff options
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/autoload/health/nvim.vim | 60 | ||||
| -rw-r--r-- | runtime/autoload/provider.vim | 5 | ||||
| -rw-r--r-- | runtime/autoload/provider/pythonx.vim | 2 | ||||
| -rw-r--r-- | runtime/doc/api.txt | 113 | ||||
| -rw-r--r-- | runtime/doc/eval.txt | 15 | ||||
| -rw-r--r-- | runtime/doc/lsp.txt | 323 | ||||
| -rw-r--r-- | runtime/doc/lua.txt | 175 | ||||
| -rw-r--r-- | runtime/doc/options.txt | 22 | ||||
| -rw-r--r-- | runtime/doc/starting.txt | 1 | ||||
| -rw-r--r-- | runtime/doc/syntax.txt | 20 | ||||
| -rw-r--r-- | runtime/filetype.vim | 28 | ||||
| -rw-r--r-- | runtime/indent/tex.vim | 22 | ||||
| -rw-r--r-- | runtime/lua/vim/highlight.lua | 37 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp.lua | 15 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/buf.lua | 66 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/callbacks.lua | 27 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/protocol.lua | 7 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 6 | ||||
| -rw-r--r-- | runtime/lua/vim/lsp/util.lua | 167 | ||||
| -rw-r--r-- | runtime/lua/vim/shared.lua | 22 | ||||
| -rw-r--r-- | runtime/lua/vim/treesitter.lua | 38 | ||||
| -rw-r--r-- | runtime/lua/vim/tshighlighter.lua | 112 | ||||
| -rw-r--r-- | runtime/pack/dist/opt/termdebug/plugin/termdebug.vim | 30 | ||||
| -rw-r--r-- | runtime/scripts.vim | 6 | ||||
| -rw-r--r-- | runtime/syntax/tex.vim | 37 |
25 files changed, 995 insertions, 361 deletions
diff --git a/runtime/autoload/health/nvim.vim b/runtime/autoload/health/nvim.vim index c25f5ee64f..f18801ea69 100644 --- a/runtime/autoload/health/nvim.vim +++ b/runtime/autoload/health/nvim.vim @@ -129,6 +129,25 @@ function! s:check_performance() abort endif endfunction +function! s:get_tmux_option(option) abort + let cmd = 'tmux show-option -qvg '.a:option " try global scope + let out = system(cmd) + let val = substitute(out, '\v(\s|\r|\n)', '', 'g') + if v:shell_error + call health#report_error('command failed: '.cmd."\n".out) + return 'error' + elseif empty(val) + let cmd = 'tmux show-option -qvgs '.a:option " try session scope + let out = system(cmd) + let val = substitute(out, '\v(\s|\r|\n)', '', 'g') + if v:shell_error + call health#report_error('command failed: '.cmd."\n".out) + return 'error' + endif + endif + return val +endfunction + function! s:check_tmux() abort if empty($TMUX) || !executable('tmux') return @@ -136,20 +155,31 @@ function! s:check_tmux() abort call health#report_start('tmux') " check escape-time - let suggestions = ["Set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10", + let suggestions = ["set escape-time in ~/.tmux.conf:\nset-option -sg escape-time 10", \ s:suggest_faq] - let cmd = 'tmux show-option -qvgs escape-time' - let out = system(cmd) - let tmux_esc_time = substitute(out, '\v(\s|\r|\n)', '', 'g') - if v:shell_error - call health#report_error('command failed: '.cmd."\n".out) - elseif empty(tmux_esc_time) - call health#report_error('escape-time is not set', suggestions) - elseif tmux_esc_time > 300 - call health#report_error( - \ 'escape-time ('.tmux_esc_time.') is higher than 300ms', suggestions) - else - call health#report_ok('escape-time: '.tmux_esc_time.'ms') + let tmux_esc_time = s:get_tmux_option('escape-time') + if tmux_esc_time !=# 'error' + if empty(tmux_esc_time) + call health#report_error('`escape-time` is not set', suggestions) + elseif tmux_esc_time > 300 + call health#report_error( + \ '`escape-time` ('.tmux_esc_time.') is higher than 300ms', suggestions) + else + call health#report_ok('escape-time: '.tmux_esc_time) + endif + endif + + " check focus-events + let suggestions = ["(tmux 1.9+ only) Set `focus-events` in ~/.tmux.conf:\nset-option -g focus-events on"] + let tmux_focus_events = s:get_tmux_option('focus-events') + call health#report_info('Checking stuff') + if tmux_focus_events !=# 'error' + if empty(tmux_focus_events) || tmux_focus_events !=# 'on' + call health#report_warn( + \ "`focus-events` is not enabled. |'autoread'| may not work.", suggestions) + else + call health#report_ok('focus-events: '.tmux_focus_events) + endif endif " check default-terminal and $TERM @@ -203,9 +233,9 @@ function! s:check_terminal() abort call health#report_error('command failed: '.cmd."\n".out) else call health#report_info('key_backspace (kbs) terminfo entry: ' - \ .(empty(kbs_entry) ? '? (not found)' : kbs_entry)) + \ .(empty(kbs_entry) ? '? (not found)' : kbs_entry)) call health#report_info('key_dc (kdch1) terminfo entry: ' - \ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry)) + \ .(empty(kbs_entry) ? '? (not found)' : kdch1_entry)) endif for env_var in ['XTERM_VERSION', 'VTE_VERSION', 'TERM_PROGRAM', 'COLORTERM', 'SSH_TTY'] if exists('$'.env_var) diff --git a/runtime/autoload/provider.vim b/runtime/autoload/provider.vim index dc24e801d0..803c1a0b1c 100644 --- a/runtime/autoload/provider.vim +++ b/runtime/autoload/provider.vim @@ -3,8 +3,11 @@ " Start the provider and perform a 'poll' request " " Returns a valid channel on success -function! provider#Poll(argv, orig_name, log_env) abort +function! provider#Poll(argv, orig_name, log_env, ...) abort let job = {'rpc': v:true, 'stderr_buffered': v:true} + if a:0 + let job = extend(job, a:1) + endif try let channel_id = jobstart(a:argv, job) if channel_id > 0 && rpcrequest(channel_id, 'poll') ==# 'ok' diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index ffb9bf3021..e89d519790 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -19,7 +19,7 @@ function! provider#pythonx#Require(host) abort call add(args, plugin.path) endfor - return provider#Poll(args, a:host.orig_name, '$NVIM_PYTHON_LOG_FILE') + return provider#Poll(args, a:host.orig_name, '$NVIM_PYTHON_LOG_FILE', {'overlapped': v:true}) endfunction function! s:get_python_executable_from_host_var(major_version) abort diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index a2e0c56f85..ea3a8242ae 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -475,6 +475,9 @@ created for extmark changes. ============================================================================== Global Functions *api-global* +nvim__get_lib_dir() *nvim__get_lib_dir()* + TODO: Documentation + nvim__id({obj}) *nvim__id()* Returns object given as argument. @@ -526,7 +529,8 @@ nvim__id_float({flt}) *nvim__id_float()* nvim__inspect_cell({grid}, {row}, {col}) *nvim__inspect_cell()* TODO: Documentation -nvim__put_attr({id}, {c0}, {c1}) *nvim__put_attr()* + *nvim__put_attr()* +nvim__put_attr({id}, {start_row}, {start_col}, {end_row}, {end_col}) Set attrs in nvim__buf_set_lua_hl callbacks TODO(bfredl): This is rather pedestrian. The final interface @@ -612,7 +616,8 @@ nvim_create_buf({listed}, {scratch}) *nvim_create_buf()* Parameters: ~ {listed} Sets 'buflisted' {scratch} Creates a "throwaway" |scratch-buffer| for - temporary work (always 'nomodified') + temporary work (always 'nomodified'). Also sets + 'nomodeline' on the buffer. Return: ~ Buffer handle, or 0 on error @@ -729,6 +734,15 @@ 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. + + Example: > + :let key = nvim_replace_termcodes("<C-o>", v:true, v:false, v:true) + :call nvim_feedkeys(key, 'n', v:true) +< + Parameters: ~ {keys} to be typed {mode} behavior flags, see |feedkeys()| @@ -929,6 +943,23 @@ nvim_get_proc_children({pid}) *nvim_get_proc_children()* Return: ~ Array of child process ids, empty if process not found. +nvim_get_runtime_file({name}, {all}) *nvim_get_runtime_file()* + Find files in runtime directories + + 'name' can contain wildcards. For example + nvim_get_runtime_file("colors/*.vim", true) will return all + color scheme files. + + It is not an error to not find any files. An empty array is + returned then. + + Parameters: ~ + {name} pattern of files to search for + {all} whether to return all matches or only the first + + Return: ~ + list of absolute paths to the found files + nvim_get_var({name}) *nvim_get_var()* Gets a global (g:) variable. @@ -1517,6 +1548,9 @@ nvim_unsubscribe({event}) *nvim_unsubscribe()* ============================================================================== Buffer Functions *api-buffer* + +For more information on buffers, see |buffers|. + Unloaded Buffers:~ Buffers may be unloaded by the |:bunload| command or the @@ -1530,6 +1564,12 @@ affected. You can use |nvim_buf_is_loaded()| or |nvim_buf_line_count()| to check whether a buffer is loaded. + *nvim__buf_add_decoration()* +nvim__buf_add_decoration({buffer}, {ns_id}, {hl_group}, {start_row}, + {start_col}, {end_row}, {end_col}, + {virt_text}) + TODO: Documentation + *nvim__buf_redraw_range()* nvim__buf_redraw_range({buffer}, {first}, {last}) TODO: Documentation @@ -1550,7 +1590,7 @@ nvim__buf_stats({buffer}) *nvim__buf_stats()* TODO: Documentation *nvim_buf_add_highlight()* -nvim_buf_add_highlight({buffer}, {ns_id}, {hl_group}, {line}, +nvim_buf_add_highlight({buffer}, {src_id}, {hl_group}, {line}, {col_start}, {col_end}) Adds a highlight to buffer. @@ -1612,6 +1652,7 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* {opts} Optional parameters. • on_lines: Lua callback invoked on change. Return`true`to detach. Args: + • the string "lines" • buffer handle • b:changedtick • first line that changed (zero-indexed) @@ -1626,11 +1667,13 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* • on_changedtick: Lua callback invoked on changedtick increment without text change. Args: + • the string "changedtick" • buffer handle • b:changedtick • on_detach: Lua callback invoked on detach. Args: + • the string "detach" • buffer handle • utf_sizes: include UTF-32 and UTF-16 size @@ -1744,8 +1787,8 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts}) as (0,0) and (-1,-1) respectively, thus the following are equivalent: > - nvim_buf_get_extmarks(0, my_ns, 0, -1, {}) - nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {}) + nvim_buf_get_extmarks(0, my_ns, 0, -1, {}) + nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {}) < If `end` is less than `start` , traversal works backwards. @@ -1754,18 +1797,18 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts}) Example: > - local a = vim.api - local pos = a.nvim_win_get_cursor(0) - local ns = a.nvim_create_namespace('my-plugin') - -- Create new extmark at line 1, column 1. - local m1 = a.nvim_buf_set_extmark(0, ns, 0, 0, 0, {}) - -- Create new extmark at line 3, column 1. - local m2 = a.nvim_buf_set_extmark(0, ns, 0, 2, 0, {}) - -- Get extmarks only from line 3. - local ms = a.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {}) - -- Get all marks in this buffer + namespace. - local all = a.nvim_buf_get_extmarks(0, ns, 0, -1, {}) - print(vim.inspect(ms)) + local a = vim.api + local pos = a.nvim_win_get_cursor(0) + local ns = a.nvim_create_namespace('my-plugin') + -- Create new extmark at line 1, column 1. + local m1 = a.nvim_buf_set_extmark(0, ns, 0, 0, 0, {}) + -- Create new extmark at line 3, column 1. + local m2 = a.nvim_buf_set_extmark(0, ns, 0, 2, 0, {}) + -- Get extmarks only from line 3. + local ms = a.nvim_buf_get_extmarks(0, ns, {2,0}, {2,0}, {}) + -- Get all marks in this buffer + namespace. + local all = a.nvim_buf_get_extmarks(0, ns, 0, -1, {}) + print(vim.inspect(ms)) < Parameters: ~ @@ -1876,7 +1919,7 @@ nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()* Variable value *nvim_buf_get_virtual_text()* -nvim_buf_get_virtual_text({buffer}, {lnum}) +nvim_buf_get_virtual_text({buffer}, {line}) Get the virtual text (annotation) for a buffer line. The virtual text is returned as list of lists, whereas the @@ -2010,7 +2053,8 @@ nvim_buf_set_var({buffer}, {name}, {value}) *nvim_buf_set_var()* {value} Variable value *nvim_buf_set_virtual_text()* -nvim_buf_set_virtual_text({buffer}, {ns_id}, {line}, {chunks}, {opts}) +nvim_buf_set_virtual_text({buffer}, {src_id}, {line}, {chunks}, + {opts}) Set the virtual text (annotation) for a buffer line. By default (and currently the only option) the text will be @@ -2334,28 +2378,31 @@ nvim_ui_detach() *nvim_ui_detach()* Removes the client from the list of UIs. |nvim_list_uis()| -nvim_ui_pum_set_height({height}) *nvim_ui_pum_set_height()* - Tells Nvim the number of elements displaying in the popumenu, - to decide <PageUp> and <PageDown> movement. - - Parameters: ~ - {height} Popupmenu height, must be greater than zero. - *nvim_ui_pum_set_bounds()* nvim_ui_pum_set_bounds({width}, {height}, {row}, {col}) + Tells Nvim the geometry of the popumenu, to align floating + windows with an external popup menu. - Tells Nvim the geometry of the popumenu, to align floating - windows with an external popup menu. Note that this method - is not to be confused with |nvim_ui_pum_set_height()|, which - sets the number of visible items in the popup menu, while - this function sets the bounding box of the popup menu, - including visual decorations such as boarders and sliders. + Note that this method is not to be confused with + |nvim_ui_pum_set_height()|, which sets the number of visible + items in the popup menu, while this function sets the bounding + box of the popup menu, including visual decorations such as + boarders and sliders. Floats need not use the same font size, + nor be anchored to exact grid corners, so one can set + floating-point numbers to the popup menu geometry. Parameters: ~ {width} Popupmenu width. {height} Popupmenu height. {row} Popupmenu row. - {height} Popupmenu height. + {col} Popupmenu height. + +nvim_ui_pum_set_height({height}) *nvim_ui_pum_set_height()* + Tells Nvim the number of elements displaying in the popumenu, + to decide <PageUp> and <PageDown> movement. + + Parameters: ~ + {height} Popupmenu height, must be greater than zero. nvim_ui_set_option({name}, {value}) *nvim_ui_set_option()* TODO: Documentation diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 99bc526659..f9a5d36205 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2019,11 +2019,12 @@ argidx() Number current index in the argument list arglistid([{winnr} [, {tabnr}]]) Number argument list id argv({nr} [, {winid}]) String {nr} entry of the argument list argv([-1, {winid}]) List the argument list +asin({expr}) Float arc sine of {expr} assert_beeps({cmd}) Number assert {cmd} causes a beep assert_equal({exp}, {act} [, {msg}]) Number assert {exp} is equal to {act} -assert_equalfile({fname-one}, {fname-two}) - Number assert file contents is equal +assert_equalfile({fname-one}, {fname-two} [, {msg}]) + Number assert file contents are equal assert_exception({error} [, {msg}]) Number assert {error} is in v:exception assert_fails({cmd} [, {error}]) Number assert {cmd} fails @@ -2039,7 +2040,6 @@ assert_notmatch({pat}, {text} [, {msg}]) Number assert {pat} not matches {text} assert_report({msg}) Number report a test failure assert_true({actual} [, {msg}]) Number assert {actual} is true -asin({expr}) Float arc sine of {expr} atan({expr}) Float arc tangent of {expr} atan2({expr}, {expr}) Float arc tangent of {expr1} / {expr2} browse({save}, {title}, {initdir}, {default}) @@ -2630,7 +2630,7 @@ assert_equal({expected}, {actual}, [, {msg}]) test.vim line 12: Expected 'foo' but got 'bar' ~ *assert_equalfile()* -assert_equalfile({fname-one}, {fname-two}) +assert_equalfile({fname-one}, {fname-two} [, {msg}]) When the files {fname-one} and {fname-two} do not contain exactly the same text an error message is added to |v:errors|. Also see |assert-return|. @@ -5506,6 +5506,11 @@ jobstart({cmd}[, {opts}]) *jobstart()* stdout data. |on_stderr|: (function) Callback invoked when the job emits stderr data. + overlapped: (boolean) Set FILE_FLAG_OVERLAPPED for the + standard input/output passed to the child process. + Normally you do not need to set this. + (Only available on MS-Windows, On other + platforms, this option is silently ignored.) pty: (boolean) Connect the job to a new pseudo terminal, and its streams to the master file descriptor. Then `on_stderr` is ignored, @@ -9362,7 +9367,7 @@ wordcount() *wordcount()* (only in Visual mode) visual_chars Number of chars visually selected (only in Visual mode) - visual_words Number of chars visually selected + visual_words Number of words visually selected (only in Visual mode) diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 9deaf26983..9f878ad8c7 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -58,6 +58,11 @@ Nvim provides the |vim.lsp.omnifunc| 'omnifunc' handler which allows " Use LSP omni-completion in Python files. autocmd Filetype python setlocal omnifunc=v:lua.vim.lsp.omnifunc +If a function has a `*_sync` variant, it's primarily intended for being run +automatically on file save. E.g. code formatting: > + + " Auto-format *.rs files prior to saving them + autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) ================================================================================ FAQ *lsp-faq* @@ -164,21 +169,36 @@ name: > LSP HIGHLIGHT *lsp-highlight* *hl-LspDiagnosticsError* -LspDiagnosticsError used for "Error" diagnostic virtual text +LspDiagnosticsError used for "Error" diagnostic virtual text *hl-LspDiagnosticsErrorSign* -LspDiagnosticsErrorSign used for "Error" diagnostic signs in sign column +LspDiagnosticsErrorSign used for "Error" diagnostic signs in sign + column + *hl-LspDiagnosticsErrorFloating* +LspDiagnosticsErrorFloating used for "Error" diagnostic messages in the + diagnostics float *hl-LspDiagnosticsWarning* -LspDiagnosticsWarning used for "Warning" diagnostic virtual text +LspDiagnosticsWarning used for "Warning" diagnostic virtual text *hl-LspDiagnosticsWarningSign* -LspDiagnosticsWarningSign used for "Warning" diagnostic signs in sign column +LspDiagnosticsWarningSign used for "Warning" diagnostic signs in sign + column + *hl-LspDiagnosticsWarningFloating* +LspDiagnosticsWarningFloating used for "Warning" diagnostic messages in the + diagnostics float *hl-LspDiagnosticsInformation* -LspDiagnosticInformation used for "Information" diagnostic virtual text +LspDiagnosticsInformation used for "Information" diagnostic virtual text *hl-LspDiagnosticsInformationSign* -LspDiagnosticInformationSign used for "Information" signs in sign column +LspDiagnosticsInformationSign used for "Information" signs in sign column + *hl-LspDiagnosticsInformationFloating* +LspDiagnosticsInformationFloating used for "Information" diagnostic messages in + the diagnostics float *hl-LspDiagnosticsHint* -LspDiagnosticHint used for "Hint" diagnostic virtual text +LspDiagnosticsHint used for "Hint" diagnostic virtual text *hl-LspDiagnosticsHintSign* -LspDiagnosticHintSign used for "Hint" diagnostic signs in sign column +LspDiagnosticsHintSign used for "Hint" diagnostic signs in sign + column + *hl-LspDiagnosticsHintFloating* +LspDiagnosticsHintFloating used for "Hint" diagnostic messages in the + diagnostics float *hl-LspReferenceText* LspReferenceText used for highlighting "text" references *hl-LspReferenceRead* @@ -344,13 +364,12 @@ buf_is_attached({bufnr}, {client_id}) *vim.lsp.buf_is_attached()* {client_id} (number) the client id buf_notify({bufnr}, {method}, {params}) *vim.lsp.buf_notify()* - Sends a notification to all servers attached to the buffer. + Send a notification to a server Parameters: ~ - {bufnr} (optional, number) Buffer handle, or 0 for - current - {method} (string) LSP method name - {params} (string) Parameters to send to the server + {bufnr} [number] (optional): The number of the buffer + {method} [string]: Name of the request method + {params} [string]: Arguments to send to the server Return: ~ true if any client returns true; false otherwise @@ -452,6 +471,10 @@ client() *vim.lsp.client* client_is_stopped({client_id}) *vim.lsp.client_is_stopped()* TODO: Documentation + *vim.lsp.define_default_sign()* +define_default_sign({name}, {properties}) + TODO: Documentation + err_message({...}) *vim.lsp.err_message()* TODO: Documentation @@ -527,7 +550,7 @@ once({fn}) *vim.lsp.once()* optional_validator({fn}) *vim.lsp.optional_validator()* TODO: Documentation -request({method}, {params}, {callback}) *vim.lsp.request()* +request({method}, {params}, {callback}, {bufnr}) *vim.lsp.request()* TODO: Documentation resolve_bufnr({bufnr}) *vim.lsp.resolve_bufnr()* @@ -563,7 +586,7 @@ start_client({config}) *vim.lsp.start_client()* {root_dir} (required, string) Directory where the LSP server will base its rootUri on initialization. - {cmd} (required, list treated like + {cmd} (required, string or list treated like |jobstart()|) Base command that initiates the LSP client. {cmd_cwd} (string, default=|getcwd()|) Directory @@ -667,7 +690,7 @@ stop_client({client_id}, {force}) *vim.lsp.stop_client()* object. To stop all clients: > - vim.lsp.stop_client(lsp.get_active_clients()) + vim.lsp.stop_client(lsp.get_active_clients()) < By default asks the server to shutdown, unless stop was @@ -689,9 +712,6 @@ unsupported_method({method}) *vim.lsp.unsupported_method()* validate_client_config({config}) *vim.lsp.validate_client_config()* TODO: Documentation -validate_command({input}) *vim.lsp.validate_command()* - TODO: Documentation - validate_encoding({encoding}) *vim.lsp.validate_encoding()* TODO: Documentation @@ -731,6 +751,9 @@ transform_schema_to_table() ============================================================================== Lua module: vim.lsp.buf *lsp-buf* +clear_references() *vim.lsp.buf.clear_references()* + TODO: Documentation + code_action({context}) *vim.lsp.buf.code_action()* TODO: Documentation @@ -744,14 +767,32 @@ definition() *vim.lsp.buf.definition()* TODO: Documentation document_highlight() *vim.lsp.buf.document_highlight()* - TODO: Documentation + Send request to server to resolve document highlights for the + current text document position. This request can be associated + to key mapping or to events such as `CursorHold` , eg: +> + vim.api.nvim_command [[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]] + vim.api.nvim_command [[autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()]] + vim.api.nvim_command [[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]] +< document_symbol() *vim.lsp.buf.document_symbol()* TODO: Documentation +execute_command({command}) *vim.lsp.buf.execute_command()* + TODO: Documentation + formatting({options}) *vim.lsp.buf.formatting()* TODO: Documentation + *vim.lsp.buf.formatting_sync()* +formatting_sync({options}, {timeout_ms}) + Perform |vim.lsp.buf.formatting()| synchronously. + + Useful for running on save, to make sure buffer is formatted + prior to being saved. {timeout_ms} is passed on to + |vim.lsp.buf_request_sync()|. + hover() *vim.lsp.buf.hover()* TODO: Documentation @@ -778,8 +819,8 @@ request({method}, {params}, {callback}) *vim.lsp.buf.request()* TODO: Documentation server_ready() *vim.lsp.buf.server_ready()* - Sends a notification through all clients associated with current - buffer and returns `true` if server responds. + Return: ~ + `true` if server responds. signature_help() *vim.lsp.buf.signature_help()* TODO: Documentation @@ -789,10 +830,22 @@ type_definition() *vim.lsp.buf.type_definition()* workspace_symbol({query}) *vim.lsp.buf.workspace_symbol()* Lists all symbols in the current workspace in the quickfix - window. The list is filtered against the optional argument - {query}; if the argument is omitted from the call, the user - is prompted to enter a string on the command line. An empty - string means no filtering is done. + window. + + The list is filtered against the optional argument {query}; if + the argument is omitted from the call, the user is prompted to + enter a string on the command line. An empty string means no + filtering is done. + +incoming_calls() *vim.lsp.buf.incoming_calls()* + Lists all the call sites of the symbol under the cursor in the + |quickfix| window. If the symbol can resolve to multiple + items, the user can pick one in the |inputlist|. + +outgoing_calls() *vim.lsp.buf.outgoing_calls()* + Lists all the items that are called by the symbol under the + cursor in the |quickfix| window. If the symbol can resolve to + multiple items, the user can pick one in the |inputlist|. ============================================================================== @@ -805,14 +858,6 @@ err_message({...}) *vim.lsp.callbacks.err_message()* location_callback({_}, {method}, {result}) TODO: Documentation - *vim.lsp.callbacks.log_message()* -log_message({_}, {_}, {result}, {client_id}) - TODO: Documentation - - *vim.lsp.callbacks.signature_help_to_preview_contents()* -signature_help_to_preview_contents({input}) - TODO: Documentation - ============================================================================== Lua module: vim.lsp.log *lsp-log* @@ -844,8 +889,17 @@ create_and_start_client({cmd}, {cmd_args}, {handlers}, encode_and_send({payload}) *vim.lsp.rpc.encode_and_send()* TODO: Documentation -force_env_list({final_env}) *vim.lsp.rpc.force_env_list()* - TODO: Documentation +env_merge({env}) *vim.lsp.rpc.env_merge()* + Merges current process env with the given env and returns the + result as a list of "k=v" strings. +> + + Example: +< + + > in: { PRODUCTION="false", PATH="/usr/bin/", PORT=123, HOST="0.0.0.0", } + out: { "PRODUCTION=false", "PATH=/usr/bin/", "PORT=123", "HOST=0.0.0.0", } +< *vim.lsp.rpc.format_message_with_content_length()* format_message_with_content_length({encoded_message}) @@ -919,6 +973,10 @@ try_call({errkind}, {fn}, {...}) *vim.lsp.rpc.try_call()* ============================================================================== Lua module: vim.lsp.util *lsp-util* + *vim.lsp.util.apply_syntax_to_region()* +apply_syntax_to_region({ft}, {start}, {finish}) + TODO: Documentation + *vim.lsp.util.apply_text_document_edit()* apply_text_document_edit({text_document_edit}) TODO: Documentation @@ -931,59 +989,61 @@ apply_text_edits({text_edits}, {bufnr}) apply_workspace_edit({workspace_edit}) TODO: Documentation - *vim.lsp.util.diagnostics_by_buf* -diagnostics_by_buf - A table containing diagnostics grouped by buf. - - {<bufnr>: {diagnostics}} - - {diagnostics} is an array of diagnostics. - - By default this is populated by the - `textDocument/publishDiagnostics` callback via - |vim.lsp.util.buf_diagnostics_save_positions|. - - It contains entries for active buffers. Once a buffer is - detached the entries for it are discarded. - buf_clear_diagnostics({bufnr}) *vim.lsp.util.buf_clear_diagnostics()* TODO: Documentation - - *vim.lsp.util.buf_diagnostics_count()* -buf_diagnostics_count({kind}) - Returns the number of diagnostics of given kind for current buffer. - Useful for showing diagnostics counts in statusline. eg: +buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()* + TODO: Documentation + +buf_diagnostics_count({kind}) *vim.lsp.util.buf_diagnostics_count()* + Returns the number of diagnostics of given kind for current + buffer. + + Useful for showing diagnostic counts in statusline. eg: > + function! LspStatus() abort let sl = '' - if luaeval('vim.lsp.buf.server_ready()') + if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))') let sl.='%#MyStatuslineLSP#E:' - let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.util.buf_diagnostics_count(\"Error\")")}' + let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.util.buf_diagnostics_count([[Error]])")}' let sl.='%#MyStatuslineLSP# W:' - let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.util.buf_diagnostics_count(\"Warning\")")}' + let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.util.buf_diagnostics_count([[Warning]])")}' else let sl.='%#MyStatuslineLSPErrors#off' endif return sl endfunction - let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus() + let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus() < Parameters: ~ - {kind} Diagnostic severity kind: Error, Warning, Information or Hint. + {kind} Diagnostic severity kind: See + |vim.lsp.protocol.DiagnosticSeverity| -buf_clear_references({bufnr}) *vim.lsp.util.buf_clear_references()* - TODO: Documentation + Return: ~ + Count of diagnostics - *vim.lsp.util.buf_diagnostics_save()* + *vim.lsp.util.buf_diagnostics_save_positions()* buf_diagnostics_save_positions({bufnr}, {diagnostics}) - Stores the diagnostics into |vim.lsp.util.diagnostics_by_buf| + Saves the diagnostics (Diagnostic[]) into diagnostics_by_buf Parameters: ~ - {bufr} bufnr for which the diagnostics are for. - {diagnostics} Diagnostics[] received from the - langauge server. + {bufnr} bufnr for which the diagnostics are for. + {diagnostics} Diagnostics[] received from the language + server. + + *vim.lsp.util.buf_diagnostics_signs()* +buf_diagnostics_signs({bufnr}, {diagnostics}) + Place signs for each diagnostic in the sign column. + + Sign characters can be customized with the following commands: +> + sign define LspDiagnosticsErrorSign text=E texthl=LspDiagnosticsError linehl= numhl= + sign define LspDiagnosticsWarningSign text=W texthl=LspDiagnosticsWarning linehl= numhl= + sign define LspDiagnosticsInformationSign text=I texthl=LspDiagnosticsInformation linehl= numhl= + sign define LspDiagnosticsHintSign text=H texthl=LspDiagnosticsHint linehl= numhl= +< *vim.lsp.util.buf_diagnostics_underline()* buf_diagnostics_underline({bufnr}, {diagnostics}) @@ -993,17 +1053,9 @@ buf_diagnostics_underline({bufnr}, {diagnostics}) buf_diagnostics_virtual_text({bufnr}, {diagnostics}) TODO: Documentation - *vim.lsp.util.buf_diagnostics_signs()* -buf_diagnostics_signs({bufnr}, {diagnostics}) - Place signs for each diagnostic in the sign column. - Sign characters can be customized with the following commands: -> -sign define LspDiagnosticsErrorSign text=E texthl=LspDiagnosticsError linehl= numhl= -sign define LspDiagnosticsWarningSign text=W texthl=LspDiagnosticsWarning linehl= numhl= -sign define LspDiagnosticsInformationSign text=I texthl=LspDiagnosticsInformation linehl= numhl= -sign define LspDiagnosticsHintSign text=H texthl=LspDiagnosticsHint linehl= numhl= -< - + *vim.lsp.util.buf_highlight_references()* +buf_highlight_references({bufnr}, {references}) + TODO: Documentation character_offset({buf}, {row}, {col}) *vim.lsp.util.character_offset()* TODO: Documentation @@ -1016,13 +1068,33 @@ close_preview_autocmd({events}, {winnr}) convert_input_to_markdown_lines({input}, {contents}) TODO: Documentation + *vim.lsp.util.convert_signature_help_to_markdown_lines()* +convert_signature_help_to_markdown_lines({signature_help}) + TODO: Documentation + + *vim.lsp.util.diagnostics_group_by_line()* +diagnostics_group_by_line({diagnostics}) + TODO: Documentation + *vim.lsp.util.extract_completion_items()* extract_completion_items({result}) TODO: Documentation *vim.lsp.util.fancy_floating_markdown()* fancy_floating_markdown({contents}, {opts}) - TODO: Documentation + Convert markdown into syntax highlighted regions by stripping + the code blocks and converting them into highlighted code. + This will by default insert a blank line separator after those + code block regions to improve readability. The result is shown + in a floating preview TODO: refactor to separate + stripping/converting and make use of open_floating_preview + + Parameters: ~ + {contents} table of lines to show in window + {opts} dictionary with optional fields + + Return: ~ + width,height size of float find_window_by_var({name}, {value}) *vim.lsp.util.find_window_by_var()* TODO: Documentation @@ -1034,10 +1106,33 @@ focusable_float({unique_name}, {fn}) *vim.lsp.util.focusable_float()* focusable_preview({unique_name}, {fn}) TODO: Documentation +get_completion_word({item}) *vim.lsp.util.get_completion_word()* + TODO: Documentation + *vim.lsp.util.get_current_line_to_cursor()* get_current_line_to_cursor() TODO: Documentation +get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* + Get visual width of tabstop. + + Parameters: ~ + {bufnr} (optional, number): Buffer handle, defaults to + current + + Return: ~ + (number) tabstop visual width + + See also: ~ + |softtabstop| + + *vim.lsp.util.get_line_byte_from_position()* +get_line_byte_from_position({bufnr}, {position}) + TODO: Documentation + +get_line_diagnostics() *vim.lsp.util.get_line_diagnostics()* + TODO: Documentation + *vim.lsp.util.get_severity_highlight_name()* get_severity_highlight_name({severity}) TODO: Documentation @@ -1045,9 +1140,6 @@ get_severity_highlight_name({severity}) jump_to_location({location}) *vim.lsp.util.jump_to_location()* TODO: Documentation -preview_location({location}) *vim.lsp.util.preview_location()* - TODO: Documentation - locations_to_items({locations}) *vim.lsp.util.locations_to_items()* TODO: Documentation @@ -1055,9 +1147,22 @@ locations_to_items({locations}) *vim.lsp.util.locations_to_items()* make_floating_popup_options({width}, {height}, {opts}) TODO: Documentation + *vim.lsp.util.make_formatting_params()* +make_formatting_params({options}) + TODO: Documentation + +make_position_param() *vim.lsp.util.make_position_param()* + TODO: Documentation + make_position_params() *vim.lsp.util.make_position_params()* TODO: Documentation +make_range_params() *vim.lsp.util.make_range_params()* + TODO: Documentation + +make_text_document_params() *vim.lsp.util.make_text_document_params()* + TODO: Documentation + npcall({fn}, {...}) *vim.lsp.util.npcall()* TODO: Documentation @@ -1066,15 +1171,49 @@ ok_or_nil({status}, {...}) *vim.lsp.util.ok_or_nil()* *vim.lsp.util.open_floating_preview()* open_floating_preview({contents}, {filetype}, {opts}) + Show contents in a floating window + + Parameters: ~ + {contents} table of lines to show in window + {filetype} string of filetype to set for opened buffer + {opts} dictionary with optional fields + + Return: ~ + bufnr,winnr buffer and window number of floating window or + nil + +parse_snippet({input}) *vim.lsp.util.parse_snippet()* + TODO: Documentation + +parse_snippet_rec({input}, {inner}) *vim.lsp.util.parse_snippet_rec()* + TODO: Documentation + +preview_location({location}) *vim.lsp.util.preview_location()* + Preview a location in a floating windows + + behavior depends on type of location: + • for Location, range is shown (e.g., function definition) + • for LocationLink, targetRange is shown (e.g., body of + function definition) + + Parameters: ~ + {location} a single Location or LocationLink + + Return: ~ + bufnr,winnr buffer and window number of floating window or + nil + + *vim.lsp.util.remove_unmatch_completion_items()* +remove_unmatch_completion_items({items}, {prefix}) TODO: Documentation set_lines({lines}, {A}, {B}, {new_lines}) *vim.lsp.util.set_lines()* TODO: Documentation -set_loclist({locations}) *vim.lsp.util.set_loclist()* +set_loclist({items}) *vim.lsp.util.set_loclist()* TODO: Documentation -set_qflist({locations}) *vim.lsp.util.set_qflist()* +set_qflist({items}) *vim.lsp.util.set_qflist()* TODO: Documentation show_line_diagnostics() *vim.lsp.util.show_line_diagnostics()* @@ -1083,11 +1222,20 @@ show_line_diagnostics() *vim.lsp.util.show_line_diagnostics()* sort_by_key({fn}) *vim.lsp.util.sort_by_key()* TODO: Documentation +sort_completion_items({items}) *vim.lsp.util.sort_completion_items()* + TODO: Documentation + split_lines({value}) *vim.lsp.util.split_lines()* TODO: Documentation +symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()* + Convert symbols to quickfix list items + + Parameters: ~ + {symbols} DocumentSymbol[] or SymbolInformation[] + *vim.lsp.util.text_document_completion_list_to_complete_items()* -text_document_completion_list_to_complete_items({result}) +text_document_completion_list_to_complete_items({result}, {prefix}) TODO: Documentation trim_empty_lines({lines}) *vim.lsp.util.trim_empty_lines()* @@ -1097,7 +1245,4 @@ trim_empty_lines({lines}) *vim.lsp.util.trim_empty_lines()* try_trim_markdown_code_blocks({lines}) TODO: Documentation -validate_lsp_position({pos}) *vim.lsp.util.validate_lsp_position()* - TODO: Documentation - vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 5a49d36503..60c7a60d25 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -95,6 +95,66 @@ Note: plugins using shell which will not work with paths containing semicolons it is better to not have them in 'runtimepath' at all. +============================================================================== +Lua Syntax Information *lua-syntax-help* + +While Lua has a simple syntax, there are a few things to understand, +particularly when looking at the documentation above. + + *lua-syntax-call-function* + +Lua functions can be called in multiple ways. Consider the function: > + + local example_func = function(a, b) + print("A is: ", a) + print("B is: ", b) + end + + +The first way to call a function is: > + + example_func(1, 2) + -- ==== Result ==== + -- A is: 1 + -- B is: 2 +< + This way of calling a function is familiar to most scripting languages. + In Lua, it's important to understand that any function arguments that are + not supplied are automatically set to `nil`. For example: > + + example_func(1) + -- ==== Result ==== + -- A is: 1 + -- B is: nil +< + + Additionally, if any extra parameters are passed, they are discarded + completely. + +In Lua, it is also possible (when only one argument is passed) to call the +function without any parentheses. This is most often used to approximate +"keyword"-style arguments with a single dictionary. For example: > + + local func_with_opts = function(opts) + local will_do_foo = opts.foo + local filename = opts.filename + + ... + end + + func_with_opts { foo = true, filename = "hello.world" } +< + + In this style, each "parameter" is passed via keyword. It is still valid + to call the function in this style: > + + func_with_opts({ foo = true, filename = "hello.world" }) +< + + But often in the documentation, you will see the former rather than the + latter style, due to its brevity (this is vim after all!). + + ------------------------------------------------------------------------------ LUA PLUGIN EXAMPLE *lua-require-example* @@ -415,6 +475,8 @@ To avoid the error use |vim.schedule_wrap()| to defer the callback: > vim.api.nvim_command('echomsg "test"') end)) +(For one-shot timers, see |vim.defer_fn()|, which automatically adds the wrapping.) + Example: repeating timer 1. Save this code to a file. 2. Execute it with ":luafile %". > @@ -512,6 +574,9 @@ retained for the lifetime of a buffer but this is subject to change. A plugin should keep a reference to the parser object as long as it wants incremental updates. +Parser methods *lua-treesitter-parser* + +tsparser:parse() *tsparser:parse()* Whenever you need to access the current syntax tree, parse the buffer: > tstree = parser:parse() @@ -528,6 +593,16 @@ shouldn't be done directly in the change callback anyway as they will be very frequent. Rather a plugin that does any kind of analysis on a tree should use a timer to throttle too frequent updates. +tsparser:set_included_ranges(ranges) *tsparser:set_included_ranges()* + Changes the ranges the parser should consider. This is used for + language injection. `ranges` should be of the form (all zero-based): > + { + {start_node, end_node}, + ... + } +< + NOTE: `start_node` and `end_node` are both inclusive. + Tree methods *lua-treesitter-tree* tstree:root() *tstree:root()* @@ -698,25 +773,26 @@ VIM.HIGHLIGHT *lua-highlight* Nvim includes a function for highlighting a selection on yank (see for example https://github.com/machakann/vim-highlightedyank). To enable it, add > - au TextYankPost * silent! lua require'vim.highlight'.on_yank() + au TextYankPost * silent! lua vim.highlight.on_yank() < to your `init.vim`. You can customize the highlight group and the duration of the highlight via > - au TextYankPost * silent! lua require'vim.highlight'.on_yank("IncSearch", 500) + au TextYankPost * silent! lua vim.highlight.on_yank {higroup="IncSearch", timeout=150} < If you want to exclude visual selections from highlighting on yank, use > -au TextYankPost * silent! lua return (not vim.v.event.visual) and require'vim.highlight'.on_yank() + au TextYankPost * silent! lua vim.highlight.on_yank {on_visual=false} < -vim.highlight.on_yank([{higroup}, {timeout}, {event}]) - *vim.highlight.on_yank()* - Highlights the yanked text. Optional arguments are the highlight group - to use ({higroup}, default `"IncSearch"`), the duration of highlighting - in milliseconds ({timeout}, default `500`), and the event structure - that is fired ({event}, default `vim.v.event`). - +vim.highlight.on_yank({opts}) *vim.highlight.on_yank()* + Highlights the yanked text. The fields of the optional dict {opts} + control 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`) vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclusive}) *vim.highlight.range()* @@ -726,7 +802,6 @@ vim.highlight.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {rtype}, {inclu or blockwise, see |setreg|; default to characterwise) and whether the range is inclusive (default false). - ------------------------------------------------------------------------------ VIM.REGEX *lua-regex* @@ -846,6 +921,9 @@ vim.defer_fn({fn}, {timeout}) *vim.defer_fn* 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. + Parameters: ~ {fn} Callback to call once {timeout} expires {timeout} Time in ms to wait before calling {fn} @@ -1018,6 +1096,9 @@ inspect({object}, {options}) *vim.inspect()* https://github.com/kikito/inspect.lua https://github.com/mpeterv/vinspect +make_meta_accessor({get}, {set}, {del}) *vim.make_meta_accessor()* + TODO: Documentation + paste({lines}, {phase}) *vim.paste()* Paste handler, invoked by |nvim_paste()| when a conforming UI (such as the |TUI|) pastes text into the editor. @@ -1133,7 +1214,7 @@ list_extend({dst}, {src}, {start}, {finish}) *vim.list_extend()* |vim.tbl_extend()| pesc({s}) *vim.pesc()* - Escapes magic chars in a Lua pattern string. + Escapes magic chars in a Lua pattern. Parameters: ~ {s} String to escape @@ -1177,8 +1258,7 @@ startswith({s}, {prefix}) *vim.startswith()* tbl_add_reverse_lookup({o}) *vim.tbl_add_reverse_lookup()* Add the reverse lookup values to an existing table. For - example: `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = - 1 }` + example: tbl_add_reverse_lookup { A = 1 } == { [1] = 'A , A = 1 }` Parameters: ~ {o} table The table to add the reverse to. @@ -1193,6 +1273,37 @@ tbl_contains({t}, {value}) *vim.tbl_contains()* Return: ~ true if `t` contains `value` +tbl_count({t}) *vim.tbl_count()* + Counts the number of non-nil values in table `t` . +> + + vim.tbl_count({ a=1, b=2 }) => 2 + vim.tbl_count({ 1, 2 }) => 2 +< + + Parameters: ~ + {t} Table + + Return: ~ + Number that is the number of the value in table + + See also: ~ + https://github.com/Tieske/Penlight/blob/master/lua/pl/tablex.lua + +tbl_deep_extend({behavior}, {...}) *vim.tbl_deep_extend()* + Merges recursively two or more map-like tables. + + Parameters: ~ + {behavior} Decides what to do if a key is found in more + than one map: + • "error": raise an error + • "keep": use value from the leftmost map + • "force": use value from the rightmost map + {...} Two or more map-like tables. + + See also: ~ + |tbl_extend()| + tbl_extend({behavior}, {...}) *vim.tbl_extend()* Merges two or more map-like tables. @@ -1207,6 +1318,13 @@ tbl_extend({behavior}, {...}) *vim.tbl_extend()* See also: ~ |extend()| +tbl_filter({func}, {t}) *vim.tbl_filter()* + Filter a table using a predicate function + + Parameters: ~ + {func} function or callable table + {t} table + tbl_flatten({t}) *vim.tbl_flatten()* Creates a copy of a list-like table such that any nested tables are "unrolled" and appended to the result. @@ -1225,11 +1343,19 @@ tbl_isempty({t}) *vim.tbl_isempty()* Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua@paramt Table to check tbl_islist({t}) *vim.tbl_islist()* - Table + Determine whether a Lua table can be treated as an array. + + An empty table `{}` will default to being treated as an array. + Use `vim.emtpy_dict()` to create a table treated as an empty + dict. Empty tables returned by `rpcrequest()` and `vim.fn` + functions can be checked using this function whether they + represent empty API arrays and vimL lists. + + Parameters: ~ + {t} Table Return: ~ - true: A non-empty array, false: A non-empty table, nil: An - empty table + `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 @@ -1244,6 +1370,13 @@ tbl_keys({t}) *vim.tbl_keys()* See also: ~ Fromhttps://github.com/premake/premake-core/blob/master/src/base/table.lua +tbl_map({func}, {t}) *vim.tbl_map()* + Apply a function to all values of a table. + + Parameters: ~ + {func} function or callable table + {t} table + tbl_values({t}) *vim.tbl_values()* Return a list of all values used in a table. However, the order of the return table of values is not guaranteed. @@ -1288,12 +1421,12 @@ validate({opt}) *vim.validate()* => NOP (success) < > - vim.validate{arg1={1, 'table'}} - => error('arg1: expected table, got number') + vim.validate{arg1={1, 'table'}} + => error('arg1: expected table, got number') < > - vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}} - => error('arg1: expected even number, got 3') + vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}} + => error('arg1: expected even number, got 3') < Parameters: ~ diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 8d4f76d3dd..e1beea0fed 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3947,6 +3947,8 @@ A jump table for the options with a short description can be found at |Q_op|. When on allow some options that are an expression to be set in the modeline. Check the option for whether it is affected by 'modelineexpr'. Also see |modeline|. + This option cannot be set from a |modeline| or in the |sandbox|, for + security reasons. *'modelines'* *'mls'* 'modelines' 'mls' number (default 5) @@ -5807,7 +5809,9 @@ A jump table for the options with a short description can be found at |Q_op|. When the option starts with "%!" then it is used as an expression, evaluated and the result is used as the option value. Example: > :set statusline=%!MyStatusLine() -< The result can contain %{} items that will be evaluated too. +< The *g:statusline_winid* variable will be set to the |window-ID| of the + window that the status line belongs to. + The result can contain %{} items that will be evaluated too. Note that the "%!" expression is evaluated in the context of the current window and buffer, while %{} items are evaluated in the context of the window that the statusline belongs to. @@ -5936,13 +5940,15 @@ A jump table for the options with a short description can be found at |Q_op|. become empty. This will make a group like the following disappear completely from the statusline when none of the flags are set. > :set statusline=...%(\ [%M%R%H]%)... -< *g:actual_curbuf* - Beware that an expression is evaluated each and every time the status - line is displayed. The current buffer and current window will be set - temporarily to that of the window (and buffer) whose statusline is - currently being drawn. The expression will evaluate in this context. - The variable "g:actual_curbuf" is set to the `bufnr()` number of the - real current buffer. +< Beware that an expression is evaluated each and every time the status + line is displayed. + *g:actual_curbuf* *g:actual_curwin* + The current buffer and current window will be set temporarily to that + of the window (and buffer) whose statusline is currently being drawn. + The expression will evaluate in this context. The variable + "g:actual_curbuf" is set to the `bufnr()` number of the real current + buffer and "g:actual_curwin" to the |window-ID| of the real current + window. These values are strings. The 'statusline' option will be evaluated in the |sandbox| if set from a modeline, see |sandbox-option|. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index af7d233619..0ded6a9060 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -90,6 +90,7 @@ argument. --clean Equivalent to "-u NONE -i NONE": - Skips initializations from files and environment variables. - No 'shada' file is read or written. + - Excludes user directories from 'runtimepath' *--noplugin* --noplugin Skip loading plugins. Resets the 'loadplugins' option. diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 57337aeac2..7da886dabd 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -3522,6 +3522,24 @@ DEFINING CASE *:syn-case* *E390* :sy[ntax] case Show either "syntax case match" or "syntax case ignore" (translated). + +DEFINING FOLDLEVEL *:syn-foldlevel* + +:sy[ntax] foldlevel [start | minimum] + This defines how the foldlevel of a line is computed when using + foldmethod=syntax (see |fold-syntax| and |:syn-fold|): + + start: Use level of item containing start of line. + minimum: Use lowest local-minimum level of items on line. + + The default is 'start'. Use 'minimum' to search a line horizontally + for the lowest level contained on the line that is followed by a + higher level. This produces more natural folds when syntax items + may close and open horizontally within a line. + +:sy[ntax] foldlevel + Show either "syntax foldlevel start" or "syntax foldlevel minimum". + SPELL CHECKING *:syn-spell* :sy[ntax] spell [toplevel | notoplevel | default] @@ -3985,6 +4003,8 @@ This will make each {} block form one fold. The fold will start on the line where the item starts, and end where the item ends. If the start and end are within the same line, there is no fold. The 'foldnestmax' option limits the nesting of syntax folds. +See |:syn-foldlevel| to control how the foldlevel of a line is computed +from its syntax items. *:syn-contains* *E405* *E406* *E407* *E408* *E409* diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 383a45b9d3..6807bef3eb 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -458,7 +458,7 @@ au BufNewFile,BufRead *.desc setf desc au BufNewFile,BufRead *.d call dist#ft#DtraceCheck() " Desktop files -au BufNewFile,BufRead *.desktop,.directory setf desktop +au BufNewFile,BufRead *.desktop,*.directory setf desktop " Dict config au BufNewFile,BufRead dict.conf,.dictrc setf dictconf @@ -538,7 +538,7 @@ au BufNewFile,BufRead *.ecd setf ecd au BufNewFile,BufRead *.e,*.E call dist#ft#FTe() " Elinks configuration -au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks +au BufNewFile,BufRead elinks.conf setf elinks " ERicsson LANGuage; Yaws is erlang too au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang @@ -1130,8 +1130,17 @@ au BufNewFile,BufRead *.ora setf ora " Packet filter conf au BufNewFile,BufRead pf.conf setf pf +" Pacman Config (close enough to dosini) +au BufNewFile,BufRead */etc/pacman.conf setf dosini + +" Pacman hooks +au BufNewFile,BufRead *.hook + \ if getline(1) == '[Trigger]' | + \ setf dosini | + \ endif + " Pam conf -au BufNewFile,BufRead */etc/pam.conf setf pamconf +au BufNewFile,BufRead */etc/pam.conf setf pamconf " Pam environment au BufNewFile,BufRead pam_env.conf,.pam_environment setf pamenv @@ -1162,6 +1171,7 @@ else endif au BufNewFile,BufRead *.plx,*.al,*.psgi setf perl au BufNewFile,BufRead *.p6,*.pm6,*.pl6 setf perl6 +au BufNewFile,BufRead *.raku,*.rakumod setf perl6 " Perl, XPM or XPM2 au BufNewFile,BufRead *.pm @@ -1291,7 +1301,8 @@ au BufNewFile,BufRead *.pyx,*.pxd setf pyrex " Python, Python Shell Startup and Python Stub Files " Quixote (Python-based web framework) -au BufNewFile,BufRead *.py,*.pyw,.pythonstartup,.pythonrc,*.ptl,*.pyi setf python +au BufNewFile,BufRead *.py,*.pyw,.pythonstartup,.pythonrc setf python +au BufNewFile,BufRead *.ptl,*.pyi,SConstruct setf python " Radiance au BufNewFile,BufRead *.rad,*.mat setf radiance @@ -1613,10 +1624,12 @@ au BufNewFile,BufRead *.sqlj setf sqlj au BufNewFile,BufRead *.sqr,*.sqi setf sqr " OpenSSH configuration -au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig +au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig +au BufNewFile,BufRead */etc/ssh/ssh_config.d/*.conf setf sshconfig " OpenSSH server configuration -au BufNewFile,BufRead sshd_config setf sshdconfig +au BufNewFile,BufRead sshd_config setf sshdconfig +au BufNewFile,BufRead */etc/ssh/sshd_config.d/*.conf setf sshdconfig " Stata au BufNewFile,BufRead *.ado,*.do,*.imata,*.mata setf stata @@ -1647,8 +1660,9 @@ au BufNewFile,BufRead *.sil setf sil au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl " Systemd unit files -au BufNewFile,BufRead */systemd/*.{automount,mount,path,service,socket,swap,target,timer} setf systemd +au BufNewFile,BufRead */systemd/*.{automount,dnssd,link,mount,netdev,network,nspawn,path,service,slice,socket,swap,target,timer} setf systemd " Systemd overrides +au BufNewFile,BufRead */etc/systemd/*.conf.d/*.conf setf systemd au BufNewFile,BufRead */etc/systemd/system/*.d/*.conf setf systemd au BufNewFile,BufRead */.config/systemd/user/*.d/*.conf setf systemd " Systemd temp files diff --git a/runtime/indent/tex.vim b/runtime/indent/tex.vim index a748cfbb40..8a44ade1ac 100644 --- a/runtime/indent/tex.vim +++ b/runtime/indent/tex.vim @@ -64,14 +64,17 @@ " style) is supported. Thanks Miles Wheeler for reporting. " 2018/02/07 by Yichao Zhou <broken.zhou AT gmail.com> " (*) Make indentation more smart in the normal mode +" 2020/04/26 by Yichao Zhou <broken.zhou AT gmail.com> +" (*) Fix a bug related to \[ & \]. Thanks Manuel Boni for +" reporting. " " }}} " Document: {{{ " -" To set the following options (ok, currently it's just one), add a line like -" let g:tex_indent_items = 1 -" to your ~/.vimrc. +" For proper latex experience, please put +" let g:tex_flavor = "latex" +" into your vimrc. " " * g:tex_indent_brace " @@ -184,13 +187,18 @@ function! GetTeXIndent() " {{{ let line = substitute(getline(lnum), '\s*%.*', '','g') " last line let cline = substitute(getline(v:lnum), '\s*%.*', '', 'g') " current line + let ccol = 1 + while cline[ccol] =~ '\s' + let ccol += 1 + endwhile + " We are in verbatim, so do what our user what. - if synIDattr(synID(v:lnum, indent(v:lnum), 1), "name") == "texZone" + if synIDattr(synID(v:lnum, ccol, 1), "name") == "texZone" if empty(cline) return indent(lnum) else return indent(v:lnum) - end + endif endif if lnum == 0 @@ -253,13 +261,13 @@ function! GetTeXIndent() " {{{ let stay = 0 endif - if cline =~ '^\s*\\\?[\]}]' && s:CheckPairedIsLastCharacter(v:lnum, indent(v:lnum)) + if cline =~ '^\s*\\\?[\]}]' && s:CheckPairedIsLastCharacter(v:lnum, ccol) let ind -= shiftwidth() let stay = 0 endif if line !~ '^\s*\\\?[\]}]' - for i in range(indent(lnum)+1, strlen(line)-1) + for i in range(1, strlen(line)-1) let char = line[i] if char == ']' || char == '}' if s:CheckPairedIsLastCharacter(lnum, i) diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index 69c3c8a4dc..ce0a3de520 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -23,24 +23,41 @@ function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive) end +local yank_ns = api.nvim_create_namespace('hlyank') --- Highlight the yanked region --- --- use from init.vim via ---- au TextYankPost * lua require'vim.highlight'.on_yank() +--- au TextYankPost * lua vim.highlight.on_yank() --- customize highlight group and timeout via ---- au TextYankPost * lua require'vim.highlight'.on_yank("IncSearch", 500) +--- au TextYankPost * lua vim.highlight.on_yank {higroup="IncSearch", timeout=150} +--- customize conditions (here: do not highlight a visual selection) via +--- au TextYankPost * lua vim.highlight.on_yank {on_visual=false} --- --- @param higroup highlight group for yanked region --- @param timeout time in ms before highlight is cleared --- @param event event structure -function highlight.on_yank(higroup, timeout, event) - event = event or vim.v.event +-- @param opts dictionary 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`)', + }} + 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 - higroup = higroup or "IncSearch" - timeout = timeout or 500 + if (not on_visual) and event.visual then return end + + local higroup = opts.higroup or "IncSearch" + local timeout = opts.timeout or 150 local bufnr = api.nvim_get_current_buf() - local yank_ns = api.nvim_create_namespace('') api.nvim_buf_clear_namespace(bufnr, yank_ns, 0, -1) local pos1 = vim.fn.getpos("'[") diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 2fbc51481f..6fe1d15b7e 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -511,6 +511,7 @@ function lsp.start_client(config) or (not client.resolved_capabilities.type_definition and method == 'textDocument/typeDefinition') or (not client.resolved_capabilities.document_symbol and method == 'textDocument/documentSymbol') or (not client.resolved_capabilities.workspace_symbol and method == 'textDocument/workspaceSymbol') + or (not client.resolved_capabilities.call_hierarchy and method == 'textDocument/prepareCallHierarchy') then callback(unsupported_method(method), method, nil, client_id, bufnr) return @@ -586,9 +587,7 @@ do old_utf16_size) local _ = log.debug() and log.debug("on_lines", bufnr, changedtick, firstline, lastline, new_lastline, old_byte_size, old_utf32_size, old_utf16_size, nvim_buf_get_lines(bufnr, firstline, new_lastline, true)) - if old_byte_size == 0 then - return - end + -- Don't do anything if there are no clients attached. if tbl_isempty(all_buffer_active_clients[bufnr] or {}) then return @@ -879,11 +878,11 @@ function lsp.buf_request_sync(bufnr, method, params, timeout_ms) end --- Send a notification to a server --- @param bufnr [number] (optional): The number of the buffer --- @param method [string]: Name of the request method --- @param params [string]: Arguments to send to the server --- --- @returns true if any client returns true; false otherwise +--@param bufnr [number] (optional): The number of the buffer +--@param method [string]: Name of the request method +--@param params [string]: Arguments to send to the server +--- +--@returns true if any client returns true; false otherwise function lsp.buf_notify(bufnr, method, params) validate { bufnr = { bufnr, 'n', true }; diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua index 7a819f3c3d..476bb3ba6f 100644 --- a/runtime/lua/vim/lsp/buf.lua +++ b/runtime/lua/vim/lsp/buf.lua @@ -23,6 +23,9 @@ local function request(method, params, callback) return vim.lsp.buf_request(0, method, params, callback) end +--- Sends a notification through all clients associated with current buffer. +-- +--@return `true` if server responds. function M.server_ready() return not not vim.lsp.buf_notify(0, "window/progress", {}) end @@ -65,19 +68,22 @@ function M.completion(context) end function M.formatting(options) - validate { options = {options, 't', true} } - local sts = vim.bo.softtabstop; - options = vim.tbl_extend('keep', options or {}, { - tabSize = (sts > 0 and sts) or (sts < 0 and vim.bo.shiftwidth) or vim.bo.tabstop; - insertSpaces = vim.bo.expandtab; - }) - local params = { - textDocument = { uri = vim.uri_from_bufnr(0) }; - options = options; - } + local params = util.make_formatting_params(options) return request('textDocument/formatting', params) end +--- Perform |vim.lsp.buf.formatting()| synchronously. +--- +--- Useful for running on save, to make sure buffer is formatted prior to being +--- saved. {timeout_ms} is passed on to |vim.lsp.buf_request_sync()|. +function M.formatting_sync(options, timeout_ms) + local params = util.make_formatting_params(options) + local result = vim.lsp.buf_request_sync(0, "textDocument/formatting", params, timeout_ms) + if not result then return end + result = result[1].result + vim.lsp.util.apply_text_edits(result) +end + function M.range_formatting(options, start_pos, end_pos) validate { options = {options, 't', true}; @@ -116,7 +122,7 @@ function M.rename(new_name) -- TODO(ashkan) use prepareRename -- * result: [`Range`](#range) \| `{ range: Range, placeholder: string }` \| `null` describing the range of the string to rename and optionally a placeholder text of the string content to be renamed. If `null` is returned then it is deemed that a 'textDocument/rename' request is not valid at the given position. local params = util.make_position_params() - new_name = new_name or npcall(vfn.input, "New Name: ") + new_name = new_name or npcall(vfn.input, "New Name: ", vfn.expand('<cword>')) if not (new_name and #new_name > 0) then return end params.newName = new_name request('textDocument/rename', params) @@ -137,6 +143,44 @@ function M.document_symbol() request('textDocument/documentSymbol', params) end +local function pick_call_hierarchy_item(call_hierarchy_items) + if not call_hierarchy_items then return end + if #call_hierarchy_items == 1 then + return call_hierarchy_items[1] + end + local items = {} + for i, item in ipairs(call_hierarchy_items) do + local entry = item.detail or item.name + table.insert(items, string.format("%d. %s", i, entry)) + end + local choice = vim.fn.inputlist(items) + if choice < 1 or choice > #items then + return + end + return choice +end + +function M.incoming_calls() + local params = util.make_position_params() + request('textDocument/prepareCallHierarchy', params, function(_, _, result) + local call_hierarchy_item = pick_call_hierarchy_item(result) + vim.lsp.buf_request(0, 'callHierarchy/incomingCalls', { item = call_hierarchy_item }) + end) +end + +function M.outgoing_calls() + local params = util.make_position_params() + request('textDocument/prepareCallHierarchy', params, function(_, _, result) + local call_hierarchy_item = pick_call_hierarchy_item(result) + vim.lsp.buf_request(0, 'callHierarchy/outgoingCalls', { item = call_hierarchy_item }) + end) +end + +--- Lists all symbols in the current workspace in the quickfix window. +--- +--- The list is filtered against the optional argument {query}; +--- if the argument is omitted from the call, the user is prompted to enter a string on the command line. +--- An empty string means no filtering is done. function M.workspace_symbol(query) query = query or npcall(vfn.input, "Query: ") local params = {query = query} diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua index 4b14f0132d..1ed58995d0 100644 --- a/runtime/lua/vim/lsp/callbacks.lua +++ b/runtime/lua/vim/lsp/callbacks.lua @@ -214,6 +214,33 @@ M['textDocument/documentHighlight'] = function(_, _, result, _) util.buf_highlight_references(bufnr, result) end +-- direction is "from" for incoming calls and "to" for outgoing calls +local make_call_hierarchy_callback = function(direction) + -- result is a CallHierarchy{Incoming,Outgoing}Call[] + return function(_, _, result) + if not result then return end + local items = {} + for _, call_hierarchy_call in pairs(result) do + local call_hierarchy_item = call_hierarchy_call[direction] + for _, range in pairs(call_hierarchy_call.fromRanges) do + table.insert(items, { + filename = assert(vim.uri_to_fname(call_hierarchy_item.uri)), + text = call_hierarchy_item.name, + lnum = range.start.line + 1, + col = range.start.character + 1, + }) + end + end + util.set_qflist(items) + api.nvim_command("copen") + api.nvim_command("wincmd p") + end +end + +M['callHierarchy/incomingCalls'] = make_call_hierarchy_callback('from') + +M['callHierarchy/outgoingCalls'] = make_call_hierarchy_callback('to') + M['window/logMessage'] = function(_, _, result, client_id) local message_type = result.type local message = result.message diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua index 64911fe7bb..ef5e08680e 100644 --- a/runtime/lua/vim/lsp/protocol.lua +++ b/runtime/lua/vim/lsp/protocol.lua @@ -713,6 +713,9 @@ function protocol.make_client_capabilities() }; applyEdit = true; }; + callHierarchy = { + dynamicRegistration = false; + }; experimental = nil; } end @@ -897,7 +900,8 @@ function protocol.resolve_capabilities(server_capabilities) text_document_will_save = ifnil(textDocumentSync.willSave, false); text_document_will_save_wait_until = ifnil(textDocumentSync.willSaveWaitUntil, false); text_document_save = ifnil(textDocumentSync.save, false); - text_document_save_include_text = ifnil(textDocumentSync.save and textDocumentSync.save.includeText, false); + text_document_save_include_text = ifnil(type(textDocumentSync.save) == 'table' + and textDocumentSync.save.includeText, false); } else return nil, string.format("Invalid type for textDocumentSync: %q", type(textDocumentSync)) @@ -911,6 +915,7 @@ function protocol.resolve_capabilities(server_capabilities) general_properties.workspace_symbol = server_capabilities.workspaceSymbolProvider or false general_properties.document_formatting = server_capabilities.documentFormattingProvider or false general_properties.document_range_formatting = server_capabilities.documentRangeFormattingProvider or false + general_properties.call_hierarchy = server_capabilities.callHierarchyProvider or false if server_capabilities.codeActionProvider == nil then general_properties.code_action = false diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index dad1dc11f1..81c92bfe05 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -36,10 +36,12 @@ end --- Merges current process env with the given env and returns the result as --- a list of "k=v" strings. --- +--- <pre> --- Example: --- ---- { PRODUCTION="false", PATH="/usr/bin/", PORT=123, HOST="0.0.0.0", } ---- => { "PRODUCTION=false", "PATH=/usr/bin/", "PORT=123", "HOST=0.0.0.0", } +--- in: { PRODUCTION="false", PATH="/usr/bin/", PORT=123, HOST="0.0.0.0", } +--- out: { "PRODUCTION=false", "PATH=/usr/bin/", "PORT=123", "HOST=0.0.0.0", } +--- </pre> local function env_merge(env) if env == nil then return env diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 49e2557c16..52a6fe89f3 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -92,7 +92,7 @@ local function sort_by_key(fn) end end local edit_sort_key = sort_by_key(function(e) - return {e.A[1], e.A[2], e.i} + return {e.A[1], e.A[2], -e.i} end) --- Position is a https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position @@ -119,6 +119,7 @@ function M.apply_text_edits(text_edits, bufnr) if not api.nvim_buf_is_loaded(bufnr) then vim.fn.bufload(bufnr) end + api.nvim_buf_set_option(bufnr, 'buflisted', true) local start_line, finish_line = math.huge, -1 local cleaned = {} for i, e in ipairs(text_edits) do @@ -618,8 +619,10 @@ end --- --@param contents table of lines to trim and pad --@param opts dictionary with optional fields --- - pad_left amount of columns to pad contents at left (default 1) --- - pad_right amount of columns to pad contents at right (default 1) +-- - pad_left number of columns to pad contents at left (default 1) +-- - pad_right number of columns to pad contents at right (default 1) +-- - pad_top number of lines to pad contents at top (default 0) +-- - pad_bottom number of lines to pad contents at bottom (default 0) --@return contents table of trimmed and padded lines function M._trim_and_pad(contents, opts) validate { @@ -633,6 +636,16 @@ function M._trim_and_pad(contents, opts) for i, line in ipairs(contents) do contents[i] = string.format('%s%s%s', left_padding, line:gsub("\r", ""), right_padding) end + if opts.pad_top then + for _ = 1, opts.pad_top do + table.insert(contents, 1, "") + end + end + if opts.pad_bottom then + for _ = 1, opts.pad_bottom do + table.insert(contents, "") + end + end return contents end @@ -650,8 +663,12 @@ end -- - height of floating window -- - width of floating window -- - wrap_at character to wrap at for computing height --- - pad_left amount of columns to pad contents at left --- - pad_right amount of columns to pad contents at right +-- - max_width maximal width of floating window +-- - max_height maximal height of floating window +-- - pad_left number of columns to pad contents at left +-- - pad_right number of columns to pad contents at right +-- - pad_top number of lines to pad contents at top +-- - pad_bottom number of lines to pad contents at bottom -- - separator insert separator after code block --@return width,height size of float function M.fancy_floating_markdown(contents, opts) @@ -762,6 +779,8 @@ end -- - height of floating window -- - width of floating window -- - wrap_at character to wrap at for computing height +-- - max_width maximal width of floating window +-- - max_height maximal height of floating window --@return width,height size of float function M._make_floating_popup_size(contents, opts) validate { @@ -772,6 +791,9 @@ function M._make_floating_popup_size(contents, opts) local width = opts.width local height = opts.height + local wrap_at = opts.wrap_at + local max_width = opts.max_width + local max_height = opts.max_height local line_widths = {} if not width then @@ -782,11 +804,14 @@ function M._make_floating_popup_size(contents, opts) width = math.max(line_widths[i], width) end end + if max_width then + width = math.min(width, max_width) + wrap_at = math.min(wrap_at or max_width, max_width) + end if not height then height = #contents - local wrap_at = opts.wrap_at - if wrap_at and width > wrap_at then + if wrap_at and width >= wrap_at then height = 0 if vim.tbl_isempty(line_widths) then for _, line in ipairs(contents) do @@ -795,11 +820,14 @@ function M._make_floating_popup_size(contents, opts) end else for i = 1, #contents do - height = height + math.ceil(line_widths[i]/wrap_at) + height = height + math.max(1, math.ceil(line_widths[i]/wrap_at)) end end end end + if max_height then + height = math.min(height, max_height) + end return width, height end @@ -812,8 +840,12 @@ end -- - height of floating window -- - width of floating window -- - wrap_at character to wrap at for computing height --- - pad_left amount of columns to pad contents at left --- - pad_right amount of columns to pad contents at right +-- - max_width maximal width of floating window +-- - max_height maximal height of floating window +-- - pad_left number of columns to pad contents at left +-- - pad_right number of columns to pad contents at right +-- - pad_top number of lines to pad contents at top +-- - pad_bottom number of lines to pad contents at bottom --@return bufnr,winnr buffer and window number of floating window or nil function M.open_floating_preview(contents, filetype, opts) validate { @@ -841,7 +873,7 @@ function M.open_floating_preview(contents, filetype, opts) end api.nvim_buf_set_lines(floating_bufnr, 0, -1, true, contents) api.nvim_buf_set_option(floating_bufnr, 'modifiable', false) - M.close_preview_autocmd({"CursorMoved", "CursorMovedI", "BufHidden"}, floating_winnr) + M.close_preview_autocmd({"CursorMoved", "CursorMovedI", "BufHidden", "BufLeave"}, floating_winnr) return floating_bufnr, floating_winnr end @@ -859,6 +891,8 @@ do local severity_highlights = {} + local severity_floating_highlights = {} + local default_severity_highlight = { [protocol.DiagnosticSeverity.Error] = { guifg = "Red" }; [protocol.DiagnosticSeverity.Warning] = { guifg = "Orange" }; @@ -870,6 +904,7 @@ do for severity, hi_info in pairs(default_severity_highlight) do local severity_name = protocol.DiagnosticSeverity[severity] local highlight_name = "LspDiagnostics"..severity_name + local floating_highlight_name = highlight_name.."Floating" -- Try to fill in the foreground color with a sane default. local cmd_parts = {"highlight", "default", highlight_name} for k, v in pairs(hi_info) do @@ -877,7 +912,9 @@ do end api.nvim_command(table.concat(cmd_parts, ' ')) api.nvim_command('highlight link ' .. highlight_name .. 'Sign ' .. highlight_name) + api.nvim_command('highlight link ' .. highlight_name .. 'Floating ' .. highlight_name) severity_highlights[severity] = highlight_name + severity_floating_highlights[severity] = floating_highlight_name end function M.buf_clear_diagnostics(bufnr) @@ -926,7 +963,7 @@ do -- TODO(ashkan) make format configurable? local prefix = string.format("%d. ", i) - local hiname = severity_highlights[diagnostic.severity] + local hiname = severity_floating_highlights[diagnostic.severity] assert(hiname, 'unknown severity: ' .. tostring(diagnostic.severity)) local message_lines = split_lines(diagnostic.message) table.insert(lines, prefix..message_lines[1]) @@ -946,7 +983,9 @@ do end --- Saves the diagnostics (Diagnostic[]) into diagnostics_by_buf - -- + --- + --@param bufnr bufnr for which the diagnostics are for. + --@param diagnostics Diagnostics[] received from the language server. function M.buf_diagnostics_save_positions(bufnr, diagnostics) validate { bufnr = {bufnr, 'n', true}; @@ -1038,6 +1077,29 @@ do end end + --- Returns the number of diagnostics of given kind for current buffer. + --- + --- Useful for showing diagnostic counts in statusline. eg: + --- + --- <pre> + --- function! LspStatus() abort + --- let sl = '' + --- if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))') + --- let sl.='%#MyStatuslineLSP#E:' + --- let sl.='%#MyStatuslineLSPErrors#%{luaeval("vim.lsp.util.buf_diagnostics_count([[Error]])")}' + --- let sl.='%#MyStatuslineLSP# W:' + --- let sl.='%#MyStatuslineLSPWarnings#%{luaeval("vim.lsp.util.buf_diagnostics_count([[Warning]])")}' + --- else + --- let sl.='%#MyStatuslineLSPErrors#off' + --- endif + --- return sl + --- endfunction + --- let &l:statusline = '%#MyStatuslineLSP#LSP '.LspStatus() + --- </pre> + --- + --@param kind Diagnostic severity kind: See |vim.lsp.protocol.DiagnosticSeverity| + --- + --@return Count of diagnostics function M.buf_diagnostics_count(kind) local bufnr = vim.api.nvim_get_current_buf() local diagnostics = M.diagnostics_by_buf[bufnr] @@ -1058,6 +1120,16 @@ do [protocol.DiagnosticSeverity.Hint] = "LspDiagnosticsHintSign"; } + --- Place signs for each diagnostic in the sign column. + --- + --- Sign characters can be customized with the following commands: + --- + --- <pre> + --- sign define LspDiagnosticsErrorSign text=E texthl=LspDiagnosticsError linehl= numhl= + --- sign define LspDiagnosticsWarningSign text=W texthl=LspDiagnosticsWarning linehl= numhl= + --- sign define LspDiagnosticsInformationSign text=I texthl=LspDiagnosticsInformation linehl= numhl= + --- sign define LspDiagnosticsHintSign text=H texthl=LspDiagnosticsHint linehl= numhl= + --- </pre> function M.buf_diagnostics_signs(bufnr, diagnostics) for _, diagnostic in ipairs(diagnostics) do vim.fn.sign_place(0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1)}) @@ -1083,40 +1155,31 @@ function M.locations_to_items(locations) for _, d in ipairs(locations) do -- locations may be Location or LocationLink local uri = d.uri or d.targetUri - local fname = assert(vim.uri_to_fname(uri)) local range = d.range or d.targetSelectionRange - table.insert(grouped[fname], {start = range.start}) + table.insert(grouped[uri], {start = range.start}) end local keys = vim.tbl_keys(grouped) table.sort(keys) -- TODO(ashkan) I wish we could do this lazily. - for _, fname in ipairs(keys) do - local rows = grouped[fname] - + for _, uri in ipairs(keys) do + local rows = grouped[uri] table.sort(rows, position_sort) - local i = 0 - for line in io.lines(fname) do - for _, temp in ipairs(rows) do - local pos = temp.start - local row = pos.line - if i == row then - local col - if pos.character > #line then - col = #line - else - col = vim.str_byteindex(line, pos.character) - end - table.insert(items, { - filename = fname, - lnum = row + 1, - col = col + 1; - text = line; - }) - end - end - i = i + 1 + local bufnr = vim.uri_to_bufnr(uri) + vim.fn.bufload(bufnr) + local filename = vim.uri_to_fname(uri) + for _, temp in ipairs(rows) do + local pos = temp.start + local row = pos.line + local line = (api.nvim_buf_get_lines(bufnr, row, row + 1, false) or {""})[1] + local col = M.character_offset(bufnr, row, pos.character) + table.insert(items, { + filename = filename, + lnum = row + 1, + col = col + 1; + text = line; + }) end end return items @@ -1145,7 +1208,7 @@ end --- Convert symbols to quickfix list items --- ---@symbols DocumentSymbol[] or SymbolInformation[] +--@param symbols DocumentSymbol[] or SymbolInformation[] function M.symbols_to_items(symbols, bufnr) local function _symbols_to_items(_symbols, _items, _bufnr) for _, symbol in ipairs(_symbols) do @@ -1254,6 +1317,30 @@ function M.make_text_document_params() return { uri = vim.uri_from_bufnr(0) } end +--- Get visual width of tabstop. +--- +--@see |softtabstop| +--@param bufnr (optional, number): Buffer handle, defaults to current +--@returns (number) tabstop visual width +function M.get_effective_tabstop(bufnr) + validate { bufnr = {bufnr, 'n', true} } + local bo = bufnr and vim.bo[bufnr] or vim.bo + local sts = bo.softtabstop + return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop +end + +function M.make_formatting_params(options) + validate { options = {options, 't', true} } + options = vim.tbl_extend('keep', options or {}, { + tabSize = M.get_effective_tabstop(); + insertSpaces = vim.bo.expandtab; + }) + return { + textDocument = { uri = vim.uri_from_bufnr(0) }; + options = options; + } +end + -- @param buf buffer handle or 0 for current. -- @param row 0-indexed line -- @param col 0-indexed byte offset in line diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua index 384d22cb89..6e427665f2 100644 --- a/runtime/lua/vim/shared.lua +++ b/runtime/lua/vim/shared.lua @@ -347,16 +347,16 @@ function vim.tbl_flatten(t) return result end --- Determine whether a Lua table can be treated as an array. --- --- An empty table `{}` will default to being treated as an array. --- Use `vim.emtpy_dict()` to create a table treated as an --- empty dict. Empty tables returned by `rpcrequest()` and --- `vim.fn` functions can be checked using this function --- whether they represent empty API arrays and vimL lists. ---- ---@params Table ---@returns true: An array-like table, false: A dict-like or mixed table +--- Determine whether a Lua table can be treated as an array. +--- +--- An empty table `{}` will default to being treated as an array. +--- Use `vim.emtpy_dict()` to create a table treated as an +--- empty dict. Empty tables returned by `rpcrequest()` and +--- `vim.fn` functions can be checked using this function +--- whether they represent empty API arrays and vimL lists. +--- +--@param t Table +--@returns `true` if array-like table, else `false`. function vim.tbl_islist(t) if type(t) ~= 'table' then return false @@ -392,7 +392,7 @@ end --- </pre> --- --@see https://github.com/Tieske/Penlight/blob/master/lua/pl/tablex.lua ---@param Table +--@param t Table --@returns Number that is the number of the value in table function vim.tbl_count(t) vim.validate{t={t,'t'}} diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index c502e45bd0..927456708c 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -15,19 +15,33 @@ function Parser:parse() local changes self.tree, changes = self._parser:parse_buf(self.bufnr) self.valid = true - for _, cb in ipairs(self.change_cbs) do - cb(changes) + + if not vim.tbl_isempty(changes) then + for _, cb in ipairs(self.changedtree_cbs) do + cb(changes) + end end + return self.tree, changes end -function Parser:_on_lines(bufnr, _, start_row, old_stop_row, stop_row, old_byte_size) +function Parser:_on_lines(bufnr, changed_tick, start_row, old_stop_row, stop_row, old_byte_size) local start_byte = a.nvim_buf_get_offset(bufnr,start_row) local stop_byte = a.nvim_buf_get_offset(bufnr,stop_row) local old_stop_byte = start_byte + old_byte_size self._parser:edit(start_byte,old_stop_byte,stop_byte, start_row,0,old_stop_row,0,stop_row,0) self.valid = false + + for _, cb in ipairs(self.lines_cbs) do + cb(bufnr, changed_tick, start_row, old_stop_row, stop_row, old_byte_size) + end +end + +function Parser:set_included_ranges(ranges) + self._parser:set_included_ranges(ranges) + -- The buffer will need to be parsed again later + self.valid = false end local M = { @@ -69,9 +83,13 @@ function M.create_parser(bufnr, lang, id) if bufnr == 0 then bufnr = a.nvim_get_current_buf() end + + vim.fn.bufload(bufnr) + local self = setmetatable({bufnr=bufnr, lang=lang, valid=false}, Parser) self._parser = vim._create_ts_parser(lang) - self.change_cbs = {} + self.changedtree_cbs = {} + self.lines_cbs = {} self:parse() -- TODO(bfredl): use weakref to self, so that the parser is free'd is no plugin is -- using it. @@ -90,7 +108,7 @@ function M.create_parser(bufnr, lang, id) return self end -function M.get_parser(bufnr, ft, cb) +function M.get_parser(bufnr, ft, buf_attach_cbs) if bufnr == nil or bufnr == 0 then bufnr = a.nvim_get_current_buf() end @@ -102,9 +120,15 @@ function M.get_parser(bufnr, ft, cb) if parsers[id] == nil then parsers[id] = M.create_parser(bufnr, ft, id) end - if cb ~= nil then - table.insert(parsers[id].change_cbs, cb) + + if buf_attach_cbs and buf_attach_cbs.on_changedtree then + table.insert(parsers[id].changedtree_cbs, buf_attach_cbs.on_changedtree) end + + if buf_attach_cbs and buf_attach_cbs.on_lines then + table.insert(parsers[id].lines_cbs, buf_attach_cbs.on_lines) + end + return parsers[id] end diff --git a/runtime/lua/vim/tshighlighter.lua b/runtime/lua/vim/tshighlighter.lua index 1440acf0d0..6465751ae8 100644 --- a/runtime/lua/vim/tshighlighter.lua +++ b/runtime/lua/vim/tshighlighter.lua @@ -3,6 +3,7 @@ local a = vim.api -- support reload for quick experimentation local TSHighlighter = rawget(vim.treesitter, 'TSHighlighter') or {} TSHighlighter.__index = TSHighlighter +local ts_hs_ns = a.nvim_create_namespace("treesitter_hl") -- These are conventions defined by tree-sitter, though it -- needs to be user extensible also. @@ -24,9 +25,17 @@ TSHighlighter.hl_map = { function TSHighlighter.new(query, bufnr, ft) local self = setmetatable({}, TSHighlighter) - self.parser = vim.treesitter.get_parser(bufnr, ft, function(...) self:on_change(...) end) + self.parser = vim.treesitter.get_parser( + bufnr, + ft, + { + on_changedtree = function(...) self:on_changedtree(...) end, + on_lines = function() self.root = self.parser:parse():root() end + } + ) + self.buf = self.parser.bufnr - -- TODO(bfredl): perhaps on_start should be called uncondionally, instead for only on mod? + local tree = self.parser:parse() self.root = tree:root() self:set_query(query) @@ -34,11 +43,6 @@ function TSHighlighter.new(query, bufnr, ft) self.redraw_count = 0 self.line_count = {} a.nvim_buf_set_option(self.buf, "syntax", "") - a.nvim__buf_set_luahl(self.buf, { - on_start=function(...) return self:on_start(...) end, - on_window=function(...) return self:on_window(...) end, - on_line=function(...) return self:on_line(...) end, - }) -- Tricky: if syntax hasn't been enabled, we need to reload color scheme -- but use synload.vim rather than syntax.vim to not enable @@ -50,73 +54,63 @@ function TSHighlighter.new(query, bufnr, ft) return self end +local function is_highlight_name(capture_name) + local firstc = string.sub(capture_name, 1, 1) + return firstc ~= string.lower(firstc) +end + +function TSHighlighter:get_hl_from_capture(capture) + + local name = self.query.captures[capture] + + if is_highlight_name(name) then + -- From "Normal.left" only keep "Normal" + return vim.split(name, '.', true)[1] + else + -- Default to false to avoid recomputing + return TSHighlighter.hl_map[name] + end +end + function TSHighlighter:set_query(query) if type(query) == "string" then query = vim.treesitter.parse_query(self.parser.lang, query) end self.query = query - self.id_map = {} - for i, capture in ipairs(self.query.captures) do - local hl = 0 - local firstc = string.sub(capture, 1, 1) - local hl_group = self.hl_map[capture] - if firstc ~= string.lower(firstc) then - hl_group = vim.split(capture, '.', true)[1] - end - if hl_group then - hl = a.nvim_get_hl_id_by_name(hl_group) + self.hl_cache = setmetatable({}, { + __index = function(table, capture) + local hl = self:get_hl_from_capture(capture) + rawset(table, capture, hl) + + return hl end - self.id_map[i] = hl - end + }) - a.nvim__buf_redraw_range(self.buf, 0, a.nvim_buf_line_count(self.buf)) + self:on_changedtree({{self.root:range()}}) end -function TSHighlighter:on_change(changes) - for _, ch in ipairs(changes or {}) do - a.nvim__buf_redraw_range(self.buf, ch[1], ch[3]+1) - end - self.edit_count = self.edit_count + 1 -end +function TSHighlighter:on_changedtree(changes) + -- Get a fresh root + self.root = self.parser.tree:root() -function TSHighlighter:on_start(_, _buf, _tick) - local tree = self.parser:parse() - self.root = tree:root() -end + for _, ch in ipairs(changes or {}) do + -- Try to be as exact as possible + local changed_node = self.root:descendant_for_range(ch[1], ch[2], ch[3], ch[4]) -function TSHighlighter:on_window(_, _win, _buf, _topline, botline) - self.iter = nil - self.nextrow = 0 - self.botline = botline - self.redraw_count = self.redraw_count + 1 -end + a.nvim_buf_clear_namespace(self.buf, ts_hs_ns, ch[1], ch[3]) -function TSHighlighter:on_line(_, _win, buf, line) - if self.iter == nil then - self.iter = self.query:iter_captures(self.root,buf,line,self.botline) - end - while line >= self.nextrow do - local capture, node, match = self.iter() - local active = true - if capture == nil then - break - end - if match ~= nil then - active = self:run_pred(match) - match.active = active - end - local start_row, start_col, end_row, end_col = node:range() - local hl = self.id_map[capture] - if hl > 0 and active and end_row >= line then - a.nvim__put_attr(hl, start_row, start_col, end_row, end_col) - end - if start_row > line then - self.nextrow = start_row + for capture, node in self.query:iter_captures(changed_node, self.buf, ch[1], ch[3] + 1) do + local start_row, start_col, end_row, end_col = node:range() + local hl = self.hl_cache[capture] + if hl then + a.nvim__buf_add_decoration(self.buf, ts_hs_ns, hl, + start_row, start_col, + end_row, end_col, + {}) + end end end - self.line_count[line] = (self.line_count[line] or 0) + 1 - --return tostring(self.line_count[line]) end return TSHighlighter diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 28dc3256c7..6870bcec75 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -247,10 +247,12 @@ func s:StartDebug_term(dict) endif let response = '' - for lnum in range(1,200) - if len(getbufline(s:gdbbuf, lnum)) > 0 && getbufline(s:gdbbuf, lnum)[0] =~ 'new-ui mi ' + for lnum in range(1, 200) + let line1 = get(getbufline(s:gdbbuf, lnum), 0, '') + let line2 = get(getbufline(s:gdbbuf, lnum + 1), 0, '') + if line1 =~ 'new-ui mi ' " response can be in the same line or the next line - let response = getbufline(s:gdbbuf, lnum)[0] . getbufline(s:gdbbuf, lnum + 1)[0] + let response = line1 . line2 if response =~ 'Undefined command' echoerr 'Sorry, your gdb is too old, gdb 7.12 is required' call s:CloseBuffers() @@ -260,10 +262,9 @@ func s:StartDebug_term(dict) " Success! break endif - if response =~ 'Reading symbols from' && response !~ 'new-ui' - " Reading symbols might take a while - let try_count -= 1 - endif + elseif line1 =~ 'Reading symbols from' && line2 !~ 'new-ui mi ' + " Reading symbols might take a while, try more times + let try_count -= 1 endif endfor if response =~ 'New UI allocated' @@ -465,12 +466,17 @@ endfunc " Function called when pressing CTRL-C in the prompt buffer and when placing a " breakpoint. func s:PromptInterrupt() - if s:pid == 0 - echoerr 'Cannot interrupt gdb, did not find a process ID' + " call ch_log('Interrupting gdb') + if has('win32') + " Using job_stop() does not work on MS-Windows, need to send SIGTRAP to + " the debugger program so that gdb responds again. + if s:pid == 0 + echoerr 'Cannot interrupt gdb, did not find a process ID' + else + call debugbreak(s:pid) + endif else - "call ch_log('Interrupting gdb') - " Using job_stop(s:gdbjob, 'int') does not work. - call debugbreak(s:pid) + call jobstop(s:gdbjob) endif endfunc diff --git a/runtime/scripts.vim b/runtime/scripts.vim index c552f0202f..6aae2b1ec3 100644 --- a/runtime/scripts.vim +++ b/runtime/scripts.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types in scripts " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last change: 2019 Jun 25 +" Last change: 2020 Jun 07 " This file is called by an autocommand for every file that has just been " loaded into a buffer. It checks if the type of file can be recognized by @@ -35,10 +35,12 @@ let s:line1 = getline(1) if s:line1 =~# "^#!" " A script that starts with "#!". - " Check for a line like "#!/usr/bin/env VAR=val bash". Turn it into + " Check for a line like "#!/usr/bin/env {options} bash". Turn it into " "#!/usr/bin/bash" to make matching easier. + " Recognize only a few {options} that are commonly used. if s:line1 =~# '^#!\s*\S*\<env\s' let s:line1 = substitute(s:line1, '\S\+=\S\+', '', 'g') + let s:line1 = substitute(s:line1, '\(-[iS]\|--ignore-environment\|--split-string\)', '', '') let s:line1 = substitute(s:line1, '\<env\s\+', '', '') endif diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim index 363c781d0f..b3a8f96b6b 100644 --- a/runtime/syntax/tex.vim +++ b/runtime/syntax/tex.vim @@ -1,8 +1,8 @@ " Vim syntax file " Language: TeX -" Maintainer: Charles E. Campbell <NdrchipO@ScampbellPfamily.AbizM> -" Last Change: May 14, 2019 -" Version: 114 +" Maintainer: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM> +" Last Change: Jun 07, 2020 +" Version: 118 " URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX " " Notes: {{{1 @@ -147,6 +147,11 @@ if exists("g:tex_nospell") && g:tex_nospell else let s:tex_nospell = 0 endif +if exists("g:tex_excludematcher") + let s:tex_excludematcher= g:tex_excludematcher +else + let s:tex_excludematcher= 0 +endif " Clusters: {{{1 " -------- @@ -156,8 +161,12 @@ if !s:tex_no_error endif syn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatement syn cluster texFoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texItalStyle,texEmphStyle,texNoSpell -syn cluster texBoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texBoldItalStyle,texNoSpell -syn cluster texItalGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texItalStyle,texEmphStyle,texItalBoldStyle,texNoSpell +syn cluster texBoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texBoldItalStyle,texNoSpell +syn cluster texItalGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texItalStyle,texEmphStyle,texItalBoldStyle,texNoSpell +if !s:tex_excludematcher + syn cluster texBoldGroup add=texMatcher + syn cluster texItalGroup add=texMatcher +endif if !s:tex_nospell syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell @@ -305,11 +314,6 @@ if s:tex_conceal !~# 'b' endif syn match texTypeStyle "\\textmd\>" syn match texTypeStyle "\\textrm\>" -syn match texTypeStyle "\\textsc\>" -syn match texTypeStyle "\\textsf\>" -syn match texTypeStyle "\\textsl\>" -syn match texTypeStyle "\\texttt\>" -syn match texTypeStyle "\\textup\>" syn match texTypeStyle "\\mathbb\>" syn match texTypeStyle "\\mathbf\>" @@ -386,12 +390,18 @@ if s:tex_fast =~# 'b' syn region texItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell syn region texItalBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell syn region texEmphStyle matchgroup=texTypeStyle start="\\emph\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@Spell + syn region texEmphStyle matchgroup=texTypeStyle start="\\texts[cfl]\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell + syn region texEmphStyle matchgroup=texTypeStyle start="\\textup\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell + syn region texEmphStyle matchgroup=texTypeStyle start="\\texttt\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup,@Spell else syn region texBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup syn region texBoldItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup syn region texItalStyle matchgroup=texTypeStyle start="\\textit\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup syn region texItalBoldStyle matchgroup=texTypeStyle start="\\textbf\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texBoldGroup syn region texEmphStyle matchgroup=texTypeStyle start="\\emph\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup + syn region texEmphStyle matchgroup=texTypeStyle start="\\texts[cfl]\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texEmphGroup + syn region texEmphStyle matchgroup=texTypeStyle start="\\textup\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texEmphGroup + syn region texEmphStyle matchgroup=texTypeStyle start="\\texttt\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texEmphGroup endif endif endif @@ -624,7 +634,7 @@ if s:tex_fast =~# 'r' syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite endif -syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite +syn match texRefZone '\\cite\%([tp]\*\=\)\=\>' nextgroup=texRefOption,texCite " Handle newcommand, newenvironment : {{{1 syn match texNewCmd "\\newcommand\>" nextgroup=texCmdName skipwhite skipnl @@ -745,6 +755,8 @@ if has("conceal") && &enc == 'utf-8' \ ['lceil' , '⌈'], \ ['ldots' , '…'], \ ['le' , '≤'], + \ ['left|' , '|'], + \ ['left\|' , '‖'], \ ['left(' , '('], \ ['left\[' , '['], \ ['left\\{' , '{'], @@ -795,6 +807,8 @@ if has("conceal") && &enc == 'utf-8' \ ['quad' , ' '], \ ['qquad' , ' '], \ ['rfloor' , '⌋'], + \ ['right|' , '|'], + \ ['right\\|' , '‖'], \ ['right)' , ')'], \ ['right]' , ']'], \ ['right\\}' , '}'], @@ -1047,6 +1061,7 @@ if has("conceal") && &enc == 'utf-8' call s:SuperSub('texSuperscript','\^','R','ᴿ') call s:SuperSub('texSuperscript','\^','T','ᵀ') call s:SuperSub('texSuperscript','\^','U','ᵁ') + call s:SuperSub('texSuperscript','\^','V','ⱽ') call s:SuperSub('texSuperscript','\^','W','ᵂ') call s:SuperSub('texSuperscript','\^',',','︐') call s:SuperSub('texSuperscript','\^',':','︓') |