diff options
-rw-r--r-- | .travis.yml | 19 | ||||
-rwxr-xr-x | ci/before_install.sh | 2 | ||||
-rw-r--r-- | ci/common/test.sh | 2 | ||||
-rw-r--r-- | runtime/doc/api.txt | 94 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 71 | ||||
-rw-r--r-- | runtime/doc/lua.txt | 20 | ||||
-rw-r--r-- | runtime/doc/options.txt | 1 | ||||
-rw-r--r-- | runtime/doc/ui.txt | 1 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 3 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/query.lua | 42 | ||||
-rw-r--r-- | src/nvim/CMakeLists.txt | 14 | ||||
-rw-r--r-- | src/nvim/api/buffer.c | 18 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/options.lua | 3 | ||||
-rw-r--r-- | src/nvim/regexp.c | 17 | ||||
-rw-r--r-- | src/nvim/regexp_nfa.c | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 2 | ||||
-rw-r--r-- | src/nvim/spell.c | 2 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | test/functional/lua/treesitter_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/ui/options_spec.lua | 7 | ||||
-rw-r--r-- | test/helpers.lua | 15 |
22 files changed, 196 insertions, 150 deletions
diff --git a/.travis.yml b/.travis.yml index 34ff492bb6..4aebae3986 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -dist: xenial +dist: bionic language: c @@ -99,12 +99,21 @@ jobs: - stage: baseline name: clang-asan os: linux - compiler: clang + compiler: clang-11 # Use Lua so that ASAN can test our embedded Lua support. 8fec4d53d0f6 env: - CLANG_SANITIZER=ASAN_UBSAN - CMAKE_FLAGS="$CMAKE_FLAGS -DPREFER_LUA=ON" + - SYMBOLIZER=asan_symbolize-11 - *common-job-env + addons: + apt: + sources: + - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' + key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' + packages: + - *common-apt-packages + - clang-11 - name: gcc-coverage (gcc 9) os: linux compiler: gcc-9 @@ -116,15 +125,15 @@ jobs: - BUSTED_ARGS="--coverage" - *common-job-env addons: + snaps: + - name: powershell + confinement: classic apt: sources: - sourceline: 'ppa:ubuntu-toolchain-r/test' - - sourceline: 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/prod xenial main' - key_url: 'https://packages.microsoft.com/keys/microsoft.asc' packages: - *common-apt-packages - gcc-9 - - powershell - if: branch = master AND commit_message !~ /\[skip.lint\]/ name: lint os: linux diff --git a/ci/before_install.sh b/ci/before_install.sh index 1cf60edf73..c3fd8bdbde 100755 --- a/ci/before_install.sh +++ b/ci/before_install.sh @@ -22,7 +22,7 @@ if [[ "${TRAVIS_OS_NAME}" != osx ]] && command -v pyenv; then echo 'Setting Python versions via pyenv' # Prefer Python 2 over 3 (more conservative). - pyenv global 2.7.15:3.7.1 + pyenv global 2.7:3.8 echo 'Updated Python info:' ( diff --git a/ci/common/test.sh b/ci/common/test.sh index b2fbeaf2da..4ef6260339 100644 --- a/ci/common/test.sh +++ b/ci/common/test.sh @@ -82,7 +82,7 @@ valgrind_check() { check_sanitizer() { if test -n "${CLANG_SANITIZER}"; then - check_logs "${1}" "*san.*" + check_logs "${1}" "*san.*" | ${SYMBOLIZER:-cat} fi } diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 851f63ead2..b80ca9edd7 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -336,7 +336,7 @@ callbacks. These callbacks are called frequently in various contexts; |textlock| prevents changing buffer contents and window layout (use |vim.schedule| to defer such operations to the main loop instead). -|nvim_buf_attach| will take keyword args for the callbacks. "on_lines" will +|nvim_buf_attach()| will take keyword args for the callbacks. "on_lines" will receive parameters ("lines", {buf}, {changedtick}, {firstline}, {lastline}, {new_lastline}, {old_byte_size}[, {old_utf32_size}, {old_utf16_size}]). Unlike remote channel events the text contents are not passed. The new text can @@ -355,7 +355,7 @@ was changed. The parameters recieved are ("changedtick", {buf}, {changedtick}). *api-lua-detach* In-process Lua callbacks can detach by returning `true`. This will detach all -callbacks attached with the same |nvim_buf_attach| call. +callbacks attached with the same |nvim_buf_attach()| call. ============================================================================== @@ -537,6 +537,12 @@ nvim__put_attr({id}, {start_row}, {start_col}, {end_row}, {end_col}) should probably be derived from a reformed bufhl/virttext interface with full support for multi-line ranges etc +nvim__screenshot({path}) *nvim__screenshot()* + TODO: Documentation + + Attributes: ~ + {fast} + nvim__stats() *nvim__stats()* Gets internal stats. @@ -1565,12 +1571,6 @@ 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 @@ -1603,19 +1603,20 @@ nvim_buf_add_highlight({buffer}, {src_id}, {hl_group}, {line}, marks do. Namespaces are used for batch deletion/updating of a set of - highlights. To create a namespace, use |nvim_create_namespace| - which returns a namespace id. Pass it in to this function as - `ns_id` to add highlights to the namespace. All highlights in - the same namespace can then be cleared with single call to - |nvim_buf_clear_namespace|. If the highlight never will be - deleted by an API call, pass `ns_id = -1` . + highlights. To create a namespace, use + |nvim_create_namespace()| which returns a namespace id. Pass + it in to this function as `ns_id` to add highlights to the + namespace. All highlights in the same namespace can then be + cleared with single call to |nvim_buf_clear_namespace()|. If + the highlight never will be deleted by an API call, pass + `ns_id = -1` . As a shorthand, `ns_id = 0` can be used to create a new namespace for the highlight, the allocated id is then returned. If `hl_group` is the empty string no highlight is added, but a new `ns_id` is still returned. This is supported for backwards compatibility, new code should use - |nvim_create_namespace| to create a new empty namespace. + |nvim_create_namespace()| to create a new empty namespace. Parameters: ~ {buffer} Buffer handle, or 0 for current buffer @@ -1766,13 +1767,16 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()* Map of maps describing commands. *nvim_buf_get_extmark_by_id()* -nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}) +nvim_buf_get_extmark_by_id({buffer}, {ns_id}, {id}, {opts}) Returns position for a given extmark id Parameters: ~ {buffer} Buffer handle, or 0 for current buffer {ns_id} Namespace id from |nvim_create_namespace()| {id} Extmark id + {opts} Optional parameters. Keys: + • limit: Maximum number of marks to return + • details Whether to include the details dict Return: ~ (row, col) tuple or empty list () if extmark id was absent @@ -1821,6 +1825,7 @@ nvim_buf_get_extmarks({buffer}, {ns_id}, {start}, {end}, {opts}) extmark id (whose position defines the bound) {opts} Optional parameters. Keys: • limit: Maximum number of marks to return + • details Whether to include the details dict Return: ~ List of [extmark_id, row, col] tuples in "traversal @@ -1919,28 +1924,6 @@ nvim_buf_get_var({buffer}, {name}) *nvim_buf_get_var()* Return: ~ Variable value - *nvim_buf_get_virtual_text()* -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 - inner lists have either one or two elements. The first element - is the actual text, the optional second element is the - highlight group. - - The format is exactly the same as given to - nvim_buf_set_virtual_text(). - - If there is no virtual text associated with the given line, an - empty list is returned. - - Parameters: ~ - {buffer} Buffer handle, or 0 for current buffer - {line} Line to get the virtual text from (zero-indexed) - - Return: ~ - List of virtual text chunks - nvim_buf_is_loaded({buffer}) *nvim_buf_is_loaded()* Checks if a buffer is valid and loaded. See |api-buffer| for more info about unloaded buffers. @@ -1974,22 +1957,35 @@ nvim_buf_line_count({buffer}) *nvim_buf_line_count()* Line count, or 0 for unloaded buffer. |api-buffer| *nvim_buf_set_extmark()* -nvim_buf_set_extmark({buffer}, {ns_id}, {id}, {line}, {col}, {opts}) +nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts}) Creates or updates an extmark. To create a new extmark, pass id=0. The extmark id will be - returned. It is also allowed to create a new mark by passing - in a previously unused id, but the caller must then keep track - of existing and unused ids itself. (Useful over RPC, to avoid + returned. To move an existing mark, pass its id. + + It is also allowed to create a new mark by passing in a + previously unused id, but the caller must then keep track of + existing and unused ids itself. (Useful over RPC, to avoid waiting for the return value.) + Using the optional arguments, it is possible to use this to + highlight a range of text, and also to associate virtual text + to the mark. + Parameters: ~ {buffer} Buffer handle, or 0 for current buffer {ns_id} Namespace id from |nvim_create_namespace()| - {id} Extmark id, or 0 to create new {line} Line number where to place the mark {col} Column where to place the mark - {opts} Optional parameters. Currently not used. + {opts} Optional parameters. + • id : id of the extmark to edit. + • end_line : ending line of the mark, 0-based + inclusive. + • end_col : ending col of the mark, 0-based + inclusive. + • hl_group : name of the highlight group used to + highlight this mark. + • virt_text : virtual text to link to this mark. Return: ~ Id of the created/updated extmark @@ -2066,12 +2062,12 @@ nvim_buf_set_virtual_text({buffer}, {src_id}, {line}, {chunks}, Namespaces are used to support batch deletion/updating of virtual text. To create a namespace, use - |nvim_create_namespace|. Virtual text is cleared using - |nvim_buf_clear_namespace|. The same `ns_id` can be used for + |nvim_create_namespace()|. Virtual text is cleared using + |nvim_buf_clear_namespace()|. The same `ns_id` can be used for both virtual text and highlights added by - |nvim_buf_add_highlight|, both can then be cleared with a - single call to |nvim_buf_clear_namespace|. If the virtual text - never will be cleared by an API call, pass `ns_id = -1` . + |nvim_buf_add_highlight()|, both can then be cleared with a + single call to |nvim_buf_clear_namespace()|. If the virtual + text never will be cleared by an API call, pass `ns_id = -1` . As a shorthand, `ns_id = 0` can be used to create a new namespace for the virtual text, the allocated id is then diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index 98a7927ea4..0300ba55b3 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -419,7 +419,7 @@ client() *vim.lsp.client* |vim.lsp.get_active_clients()|. • Methods: - • request(method, params, [callback], bufnr) Send a request + • request(method, params, [callback], bufnr) Sends a request to the server. This is a thin wrapper around {client.rpc.request} with some additional checking. If {callback} is not specified, it will use @@ -431,13 +431,13 @@ client() *vim.lsp.client* If {status} is `true` , the function returns {request_id} as the second result. You can use this with `client.cancel_request(request_id)` to cancel the request. - • notify(method, params) Send a notification to an LSP + • notify(method, params) Sends a notification to an LSP server. Returns: a boolean to indicate if the notification was successful. If it is false, then it will always be false (the client has shutdown). • cancel_request(id) Cancels a request with a given request id. Returns: same as `notify()` . - • stop([force]) Stop a client, optionally with force. By + • stop([force]) Stops a client, optionally with force. By default, it will just ask the server to shutdown without force. If you request to stop a client which has previously been requested to shutdown, it will @@ -688,7 +688,7 @@ clear_references() *vim.lsp.buf.clear_references()* Removes document highlights from current buffer. code_action({context}) *vim.lsp.buf.code_action()* - Select a code action from the input list that is available at + Selects a code action from the input list that is available at the current cursor position. Parameters: ~ @@ -733,7 +733,7 @@ document_symbol() *vim.lsp.buf.document_symbol()* window. execute_command({command}) *vim.lsp.buf.execute_command()* - Execute an LSP server command. + Executes an LSP server command. Parameters: ~ {command} A valid `ExecuteCommandParams` object @@ -755,7 +755,7 @@ formatting({options}) *vim.lsp.buf.formatting()* *vim.lsp.buf.formatting_sync()* formatting_sync({options}, {timeout_ms}) - Perform |vim.lsp.buf.formatting()| synchronously. + Performs |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 @@ -790,15 +790,13 @@ outgoing_calls() *vim.lsp.buf.outgoing_calls()* *vim.lsp.buf.range_formatting()* range_formatting({options}, {start_pos}, {end_pos}) - 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()|. + Formats a given range. Parameters: ~ - {options} Table with valid `FormattingOptions` entries - {timeout_ms} (number) Request timeout + {options} Table with valid `FormattingOptions` entries. + {start_pos} ({number, number}, optional) mark-indexed + position. Defaults to the end of the last + visual selection. references({context}) *vim.lsp.buf.references()* Lists all the references to the symbol under the cursor in the @@ -918,7 +916,7 @@ rpc_response_error({code}, {message}, {data}) *vim.lsp.rpc.start()* start({cmd}, {cmd_args}, {handlers}, {extra_spawn_params}) - Start an LSP server process and create an LSP RPC client + Starts an LSP server process and create an LSP RPC client object to interact with it. Parameters: ~ @@ -959,9 +957,6 @@ Lua module: vim.lsp.util *lsp-util* *vim.lsp.util.apply_text_document_edit()* apply_text_document_edit({text_document_edit}) - Apply a `TextDocumentEdit` , which is a list of changes to a - single document. - Parameters: ~ {text_document_edit} (table) a `TextDocumentEdit` object @@ -984,7 +979,7 @@ apply_workspace_edit({workspace_edit}) {workspace_edit} (table) `WorkspaceEdit` buf_clear_diagnostics({bufnr}) *vim.lsp.util.buf_clear_diagnostics()* - Clear diagnostics for a buffer. + Clears diagnostics for a buffer. Parameters: ~ {bufnr} (number) buffer id @@ -1037,7 +1032,7 @@ buf_diagnostics_save_positions({bufnr}, {diagnostics}) *vim.lsp.util.buf_diagnostics_signs()* buf_diagnostics_signs({bufnr}, {diagnostics}) - Place signs for each diagnostic in the sign column. + Places signs for each diagnostic in the sign column. Sign characters can be customized with the following commands: > @@ -1058,7 +1053,7 @@ buf_diagnostics_underline({bufnr}, {diagnostics}) *vim.lsp.util.buf_diagnostics_virtual_text()* buf_diagnostics_virtual_text({bufnr}, {diagnostics}) - Given a list of diagnostics, set the corresponding virtual + Given a list of diagnostics, sets the corresponding virtual text for a buffer. Parameters: ~ @@ -1067,7 +1062,7 @@ buf_diagnostics_virtual_text({bufnr}, {diagnostics}) *vim.lsp.util.buf_highlight_references()* buf_highlight_references({bufnr}, {references}) - Show a list of document highlights for a certain buffer. + Shows a list of document highlights for a certain buffer. Parameters: ~ {bufnr} buffer id @@ -1089,7 +1084,7 @@ character_offset({buf}, {row}, {col}) *vim.lsp.util.character_offset()* *vim.lsp.util.close_preview_autocmd()* close_preview_autocmd({events}, {winnr}) - Create autocommands to close a preview window when events + Creates autocommands to close a preview window when events happen. Parameters: ~ @@ -1101,7 +1096,7 @@ close_preview_autocmd({events}, {winnr}) *vim.lsp.util.convert_input_to_markdown_lines()* convert_input_to_markdown_lines({input}, {contents}) - Convert any of `MarkedString` | `MarkedString[]` | + Converts any of `MarkedString` | `MarkedString[]` | `MarkupContent` into a list of lines containing valid markdown. Useful to populate the hover window for `textDocument/hover` , for parsing the result of @@ -1121,7 +1116,7 @@ convert_input_to_markdown_lines({input}, {contents}) *vim.lsp.util.convert_signature_help_to_markdown_lines()* convert_signature_help_to_markdown_lines({signature_help}) - Convert `textDocument/SignatureHelp` response to markdown + Converts `textDocument/SignatureHelp` response to markdown lines. Parameters: ~ @@ -1163,11 +1158,11 @@ extract_completion_items({result}) *vim.lsp.util.fancy_floating_markdown()* fancy_floating_markdown({contents}, {opts}) - Convert markdown into syntax highlighted regions by stripping + Converts 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 + in a floating preview. Parameters: ~ {contents} table of lines to show in window @@ -1193,9 +1188,9 @@ focusable_float({unique_name}, {fn}) *vim.lsp.util.focusable_float()* *vim.lsp.util.focusable_preview()* focusable_preview({unique_name}, {fn}) - Focus/unfocus the floating preview window associated with the - current buffer via the window variable `unique_name` . If no - such preview window exists, make a new one. + Focuses/unfocuses the floating preview window associated with + the current buffer via the window variable `unique_name` . If + no such preview window exists, makes a new one. Parameters: ~ {unique_name} (string) Window variable @@ -1206,7 +1201,7 @@ focusable_preview({unique_name}, {fn}) be created get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* - Get visual width of tabstop. + Returns visual width of tabstop. Parameters: ~ {bufnr} (optional, number): Buffer handle, defaults to @@ -1219,7 +1214,7 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* |softtabstop| get_line_diagnostics() *vim.lsp.util.get_line_diagnostics()* - Get list of diagnostics for the current line. + Gets list of diagnostics for the current line. Return: ~ (table) list of `Diagnostic` tables @@ -1229,7 +1224,7 @@ get_line_diagnostics() *vim.lsp.util.get_line_diagnostics()* *vim.lsp.util.get_severity_highlight_name()* get_severity_highlight_name({severity}) - Get the name of a severity's highlight group. + Gets the name of a severity's highlight group. Parameters: ~ {severity} A member of @@ -1319,7 +1314,7 @@ make_text_document_params() *vim.lsp.util.make_text_document_params()* *vim.lsp.util.open_floating_preview()* open_floating_preview({contents}, {filetype}, {opts}) - Show contents in a floating window + Shows contents in a floating window. Parameters: ~ {contents} table of lines to show in window @@ -1340,7 +1335,7 @@ parse_snippet({input}) *vim.lsp.util.parse_snippet()* (string) parsed snippet preview_location({location}) *vim.lsp.util.preview_location()* - Preview a location in a floating window + Previews a location in a floating window behavior depends on type of location: • for Location, range is shown (e.g., function definition) @@ -1355,7 +1350,7 @@ preview_location({location}) *vim.lsp.util.preview_location()* or nil set_lines({lines}, {A}, {B}, {new_lines}) *vim.lsp.util.set_lines()* - Replace text in a range with new text. + Replaces text in a range with new text. CAUTION: Changes in-place! @@ -1389,7 +1384,7 @@ show_line_diagnostics() *vim.lsp.util.show_line_diagnostics()* hover window. symbols_to_items({symbols}, {bufnr}) *vim.lsp.util.symbols_to_items()* - Convert symbols to quickfix list items + Converts symbols to quickfix list items. Parameters: ~ {symbols} DocumentSymbol[] or SymbolInformation[] @@ -1414,7 +1409,7 @@ text_document_completion_list_to_complete_items({result}, {prefix}) |complete-items| trim_empty_lines({lines}) *vim.lsp.util.trim_empty_lines()* - Remove empty lines from the beginning and end. + Removes empty lines from the beginning and end. Parameters: ~ {lines} (table) list of lines to trim @@ -1435,4 +1430,4 @@ try_trim_markdown_code_blocks({lines}) Return: ~ (string) filetype or 'markdown' if it was unchanged. - vim:tw=78:ts=8:sw=2:et:ft=help:norl: + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 67a1554aa5..509ed7bf2c 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -756,14 +756,15 @@ Here is a list of built-in predicates : ((node1) @left (node2) @right (#eq? @left @right)) < `match?` *ts-predicate-match?* - This will match if the provived lua regex matches the text + `vim-match?` *ts-predicate-vim-match?* + This will match if the provived vim regex matches the text corresponding to a node : > ((idenfitier) @constant (#match? @constant "^[A-Z_]+$")) < Note: the `^` and `$` anchors will respectively match the start and end of the node's text. - `vim-match?` *ts-predicate-vim-match?* - This will match the same way than |match?| but using vim + `lua-match?` *ts-predicate-lua-match?* + This will match the same way than |match?| but using lua regexes. `contains?` *ts-predicate-contains?* @@ -1460,13 +1461,12 @@ tbl_isempty({t}) *vim.tbl_isempty()* https://github.com/premake/premake-core/blob/master/src/base/table.lua tbl_islist({t}) *vim.tbl_islist()* - Determine whether a Lua table can be treated as an array. + Tests if 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. + Empty table `{}` is assumed to be an array, unless it was + created by |vim.empty_dict()| or returned as a dict-like |API| + or Vimscript result, for example from |rpcrequest()| or + |vim.fn|. Parameters: ~ {t} Table @@ -1567,4 +1567,4 @@ validate({opt}) *vim.validate()* • msg: (optional) error string if validation fails - vim:tw=78:ts=8:sw=2:et:ft=help:norl: + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 00fa947f6d..190d6f9229 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4022,7 +4022,6 @@ A jump table for the options with a short description can be found at |Q_op|. *'mousefocus'* *'mousef'* *'nomousefocus'* *'nomousef'* 'mousefocus' 'mousef' boolean (default off) global - {only works in the GUI} The window that the mouse pointer is on is automatically activated. When changing the window layout or window focus in another way, the mouse pointer is moved to the window with keyboard focus. Off is the diff --git a/runtime/doc/ui.txt b/runtime/doc/ui.txt index 990f58b291..e5c6b9b1b7 100644 --- a/runtime/doc/ui.txt +++ b/runtime/doc/ui.txt @@ -185,6 +185,7 @@ the editor. 'guifont' 'guifontwide' 'linespace' + 'mousefocus' 'pumblend' 'showtabline' 'termguicolors' diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index bb78b5654c..1acf888821 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -98,7 +98,8 @@ function TSHighlighter:get_hl_from_capture(capture) return vim.split(name, '.', true)[1] else -- Default to false to avoid recomputing - return a.nvim_get_hl_id_by_name(TSHighlighter.hl_map[name]) + local hl = TSHighlighter.hl_map[name] + return hl and a.nvim_get_hl_id_by_name(hl) or 0 end end diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index 55e69f177f..ca27a50c6a 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -60,7 +60,7 @@ local predicate_handlers = { return true end, - ["match?"] = function(match, _, bufnr, predicate) + ["lua-match?"] = function(match, _, bufnr, predicate) local node = match[predicate[2]] local regex = predicate[3] local start_row, _, end_row, _ = node:range() @@ -71,7 +71,7 @@ local predicate_handlers = { return string.find(M.get_node_text(node, bufnr), regex) end, - ["vim-match?"] = (function() + ["match?"] = (function() local magic_prefixes = {['\\v']=true, ['\\m']=true, ['\\M']=true, ['\\V']=true} local function check_magic(str) if string.len(str) < 2 or magic_prefixes[string.sub(str,1,2)] then @@ -114,6 +114,9 @@ local predicate_handlers = { end } +-- As we provide lua-match? also expose vim-match? +predicate_handlers["vim-match?"] = predicate_handlers["match?"] + --- Adds a new predicates to be used in queries -- -- @param name the name of the predicate, without leading # @@ -132,25 +135,38 @@ function M.list_predicates() return vim.tbl_keys(predicate_handlers) end +local function xor(x, y) + return (x or y) and not (x and y) +end + function Query:match_preds(match, pattern, bufnr) local preds = self.info.patterns[pattern] - if not preds then - return true - end - for _, pred in pairs(preds) do + + for _, pred in pairs(preds or {}) do -- Here we only want to return if a predicate DOES NOT match, and -- continue on the other case. This way unknown predicates will not be considered, -- which allows some testing and easier user extensibility (#12173). -- Also, tree-sitter strips the leading # from predicates for us. + local pred_name + local is_not if string.sub(pred[1], 1, 4) == "not-" then - local pred_name = string.sub(pred[1], 5) - if predicate_handlers[pred_name] and - predicate_handlers[pred_name](match, pattern, bufnr, pred) then - return false - end + pred_name = string.sub(pred[1], 5) + is_not = true + else + pred_name = pred[1] + is_not = false + end + + local handler = predicate_handlers[pred_name] + + if not handler then + a.nvim_err_writeln(string.format("No handler for %s", pred[1])) + return false + end + + local pred_matches = handler(match, pattern, bufnr, pred) - elseif predicate_handlers[pred[1]] and - not predicate_handlers[pred[1]](match, pattern, bufnr, pred) then + if not xor(is_not, pred_matches) then return false end end diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 7b4438b896..2d98f1a659 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -624,9 +624,19 @@ if(CLANG_ASAN_UBSAN) message(STATUS "Enabling Clang address sanitizer and undefined behavior sanitizer for nvim.") check_c_compiler_flag(-fno-sanitize-recover=all SANITIZE_RECOVER_ALL) if(SANITIZE_RECOVER_ALL) - set(SANITIZE_RECOVER -fno-sanitize-recover=all) # Clang 3.6+ + if(TRAVIS_CI_BUILD) + # Try to recover from all sanitize issues so we get reports about all failures + set(SANITIZE_RECOVER -fsanitize-recover=all) # Clang 3.6+ + else() + set(SANITIZE_RECOVER -fno-sanitize-recover=all) # Clang 3.6+ + endif() else() - set(SANITIZE_RECOVER -fno-sanitize-recover) # Clang 3.5- + if(TRAVIS_CI_BUILD) + # Try to recover from all sanitize issues so we get reports about all failures + set(SANITIZE_RECOVER -fsanitize-recover) # Clang 3.5- + else() + set(SANITIZE_RECOVER -fno-sanitize-recover) # Clang 3.5- + endif() endif() set_property(TARGET nvim APPEND PROPERTY COMPILE_DEFINITIONS EXITFREE) set_property(TARGET nvim APPEND PROPERTY COMPILE_OPTIONS ${SANITIZE_RECOVER} -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address -fsanitize=undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/src/.asan-blacklist) diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index cc9dd51cf6..5290011325 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1535,17 +1535,17 @@ Boolean nvim_buf_del_extmark(Buffer buffer, /// like signs and marks do. /// /// Namespaces are used for batch deletion/updating of a set of highlights. To -/// create a namespace, use |nvim_create_namespace| which returns a namespace +/// create a namespace, use |nvim_create_namespace()| which returns a namespace /// id. Pass it in to this function as `ns_id` to add highlights to the /// namespace. All highlights in the same namespace can then be cleared with -/// single call to |nvim_buf_clear_namespace|. If the highlight never will be +/// single call to |nvim_buf_clear_namespace()|. If the highlight never will be /// deleted by an API call, pass `ns_id = -1`. /// /// As a shorthand, `ns_id = 0` can be used to create a new namespace for the /// highlight, the allocated id is then returned. If `hl_group` is the empty /// string no highlight is added, but a new `ns_id` is still returned. This is /// supported for backwards compatibility, new code should use -/// |nvim_create_namespace| to create a new empty namespace. +/// |nvim_create_namespace()| to create a new empty namespace. /// /// @param buffer Buffer handle, or 0 for current buffer /// @param ns_id namespace to use or -1 for ungrouped highlight @@ -1647,7 +1647,7 @@ void nvim_buf_clear_namespace(Buffer buffer, /// Clears highlights and virtual text from namespace and range of lines /// -/// @deprecated use |nvim_buf_clear_namespace|. +/// @deprecated use |nvim_buf_clear_namespace()|. /// /// @param buffer Buffer handle, or 0 for current buffer /// @param ns_id Namespace to clear, or -1 to clear all. @@ -1711,11 +1711,11 @@ free_exit: /// begin one cell (|lcs-eol| or space) after the ordinary text. /// /// Namespaces are used to support batch deletion/updating of virtual text. -/// To create a namespace, use |nvim_create_namespace|. Virtual text is -/// cleared using |nvim_buf_clear_namespace|. The same `ns_id` can be used for -/// both virtual text and highlights added by |nvim_buf_add_highlight|, both -/// can then be cleared with a single call to |nvim_buf_clear_namespace|. If the -/// virtual text never will be cleared by an API call, pass `ns_id = -1`. +/// To create a namespace, use |nvim_create_namespace()|. Virtual text is +/// cleared using |nvim_buf_clear_namespace()|. The same `ns_id` can be used for +/// both virtual text and highlights added by |nvim_buf_add_highlight()|, both +/// can then be cleared with a single call to |nvim_buf_clear_namespace()|. If +/// the virtual text never will be cleared by an API call, pass `ns_id = -1`. /// /// As a shorthand, `ns_id = 0` can be used to create a new namespace for the /// virtual text, the allocated id is then returned. diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index eb8f051b9c..02fa7ac216 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -512,6 +512,7 @@ EXTERN long p_mle; // 'modelineexpr' EXTERN long p_mls; // 'modelines' EXTERN char_u *p_mouse; // 'mouse' EXTERN char_u *p_mousem; // 'mousemodel' +EXTERN long p_mousef; // 'mousefocus' EXTERN long p_mouset; // 'mousetime' EXTERN int p_more; // 'more' EXTERN char_u *p_opfunc; // 'operatorfunc' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 79fea1f628..f1221a52a2 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1588,7 +1588,8 @@ return { full_name='mousefocus', abbreviation='mousef', type='bool', scope={'global'}, vi_def=true, - enable_if=false, + redraw={'ui_option'}, + varname='p_mousef', defaults={if_true={vi=false}} }, { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 9705896e9b..bcf02af4ef 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1270,8 +1270,9 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags) int len; int flags; - if (expr == NULL) - EMSG_RET_NULL(_(e_null)); + if (expr == NULL) { + IEMSG_RET_NULL(_(e_null)); + } init_class_tab(); @@ -3483,7 +3484,7 @@ static long bt_regexec_both(char_u *line, /* Be paranoid... */ if (prog == NULL || line == NULL) { - EMSG(_(e_null)); + IEMSG(_(e_null)); goto theend; } @@ -4789,7 +4790,7 @@ static bool regmatch( break; default: - EMSG(_(e_re_corr)); + IEMSG(_(e_re_corr)); #ifdef REGEXP_DEBUG printf("Illegal op code %d\n", op); #endif @@ -5147,7 +5148,7 @@ static bool regmatch( * We get here only if there's trouble -- normally "case END" is * the terminating point. */ - EMSG(_(e_re_corr)); + IEMSG(_(e_re_corr)); #ifdef REGEXP_DEBUG printf("Premature EOL\n"); #endif @@ -5552,8 +5553,8 @@ do_class: } break; - default: /* Oh dear. Called inappropriately. */ - EMSG(_(e_re_corr)); + default: // Oh dear. Called inappropriately. + IEMSG(_(e_re_corr)); #ifdef REGEXP_DEBUG printf("Called regrepeat with op code %d\n", OP(p)); #endif @@ -6911,7 +6912,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, } } else if (*s == NUL) { // we hit NUL. if (copy) { - EMSG(_(e_re_damg)); + IEMSG(_(e_re_damg)); } goto exit; } else { diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 506c4e87db..7cd1ae93d2 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -6519,7 +6519,7 @@ static long nfa_regexec_both(char_u *line, colnr_T startcol, /* Be paranoid... */ if (prog == NULL || line == NULL) { - EMSG(_(e_null)); + IEMSG(_(e_null)); goto theend; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index c68a90d6e3..fde6b1ceeb 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6211,7 +6211,7 @@ void win_grid_alloc(win_T *wp) || grid->Rows != rows || grid->Columns != cols) { if (want_allocation) { - grid_alloc(grid, rows, cols, wp->w_grid.valid, wp->w_grid.valid); + grid_alloc(grid, rows, cols, wp->w_grid.valid, false); grid->valid = true; } else { // Single grid mode, all rendering will be redirected to default_grid. diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 05bb501fa2..dc1bfe25b4 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -4405,8 +4405,6 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so } break; - FALLTHROUGH; - case STATE_INS: // Insert one byte. Repeat this for each possible byte at this // node. diff --git a/src/nvim/version.c b/src/nvim/version.c index bf80de6026..d6d933245b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -464,7 +464,7 @@ static const int included_patches[] = { 1457, 1456, // 1455, - // 1454, + 1454, 1453, 1452, 1451, diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua index c041478af6..5bca42a4fc 100644 --- a/test/functional/lua/treesitter_spec.lua +++ b/test/functional/lua/treesitter_spec.lua @@ -250,13 +250,13 @@ void ui_refresh(void) }, res) end) - it('allow loading query with escaped quotes and capture them with `match?` and `vim-match?`', function() + it('allow loading query with escaped quotes and capture them with `lua-match?` and `vim-match?`', function() if not check_parser() then return end insert('char* astring = "Hello World!";') local res = exec_lua([[ - cquery = vim.treesitter.parse_query("c", '((_) @quote (vim-match? @quote "^\\"$")) ((_) @quote (match? @quote "^\\"$"))') + cquery = vim.treesitter.parse_query("c", '((_) @quote (vim-match? @quote "^\\"$")) ((_) @quote (lua-match? @quote "^\\"$"))') parser = vim.treesitter.get_parser(0, "c") tree = parser:parse() res = {} @@ -323,7 +323,7 @@ void ui_refresh(void) return list ]] - eq({ 'contains?', 'eq?', 'is-main?', 'match?', 'vim-match?' }, res_list) + eq({ 'contains?', 'eq?', 'is-main?', 'lua-match?', 'match?', 'vim-match?' }, res_list) end) it('supports highlighting', function() @@ -373,7 +373,7 @@ static int nlua_schedule(lua_State *const lstate) ; Use lua regexes ((identifier) @Identifier (#contains? @Identifier "lua_")) -((identifier) @Constant (#match? @Constant "^[A-Z_]+$")) +((identifier) @Constant (#lua-match? @Constant "^[A-Z_]+$")) ((identifier) @Normal (#vim-match? @Constant "^lstate$")) ((binary_expression left: (identifier) @WarningMsg.left right: (identifier) @WarningMsg.right) (#eq? @WarningMsg.left @WarningMsg.right)) diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 1593f04f41..2f113f6ac6 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -17,6 +17,7 @@ describe('UI receives option updates', function() guifontwide='', linespace=0, pumblend=0, + mousefocus=false, showtabline=1, termguicolors=false, ttimeout=true, @@ -109,6 +110,12 @@ describe('UI receives option updates', function() eq(expected, screen.options) end) + command("set mousefocus") + expected.mousefocus = true + screen:expect(function() + eq(expected, screen.options) + end) + command("set nottimeout") expected.ttimeout = false screen:expect(function() diff --git a/test/helpers.lua b/test/helpers.lua index 40b93d9935..7817345617 100644 --- a/test/helpers.lua +++ b/test/helpers.lua @@ -200,14 +200,25 @@ function module.check_logs() end end fd:close() - os.remove(file) if #lines > 0 then + local status, f local out = io.stdout + if os.getenv('SYMBOLIZER') then + status, f = pcall(module.popen_r, os.getenv('SYMBOLIZER'), '-l', file) + end out:write(start_msg .. '\n') - out:write('= ' .. table.concat(lines, '\n= ') .. '\n') + if status then + for line in f:lines() do + out:write('= '..line..'\n') + end + f:close() + else + out:write('= ' .. table.concat(lines, '\n= ') .. '\n') + end out:write(select(1, start_msg:gsub('.', '=')) .. '\n') table.insert(runtime_errors, file) end + os.remove(file) end end end |