diff options
-rw-r--r-- | .github/ISSUE_TEMPLATE/bug_report.yml | 7 | ||||
-rw-r--r-- | runtime/doc/lsp.txt | 12 | ||||
-rw-r--r-- | runtime/doc/treesitter.txt | 17 | ||||
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 33 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/query.lua | 4 | ||||
-rw-r--r-- | src/nvim/api/buffer.c | 2 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 2 | ||||
-rw-r--r-- | src/nvim/buffer_updates.c | 12 | ||||
-rw-r--r-- | src/nvim/undo.c | 4 |
9 files changed, 57 insertions, 36 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 643a06c2cf..e5530a1511 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -43,14 +43,9 @@ body: attributes: label: "Steps to reproduce" description: | - Steps to reproduce using `nvim -u NORC`. + Steps to reproduce using `nvim -u NORC` and/or `nvim -u NONE` (please test both). If you are reporting build failures, please list the exact sequence of steps including all CMake flags (if any). - - type: checkboxes - attributes: - options: - - label: "Please check the box if it's possible to reproduce the bug with `nvim --clean` as well" - - type: input attributes: label: "Vim" diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index a15c74d148..5a27e195bc 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -322,6 +322,18 @@ To configure the behavior of a builtin |lsp-handler|, the convenient method } } < + Some handlers do not have an explicitly named handler function (such as + |on_publish_diagnostics()|). To override these, first create a reference + to the existing handler: > + + local on_references = vim.lsp.handlers["textDocument/references"] + vim.lsp.handlers["textDocument/references"] = vim.lsp.with( + on_references, { + -- Use location list instead of quickfix list + loclist = true, + } + ) +< *lsp-handler-resolution* Handlers can be set by: diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index cabcb67921..69aacedaa4 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -169,7 +169,7 @@ a tree, using a simple to write lisp-like format. See https://tree-sitter.github.io/tree-sitter/using-parsers#query-syntax for more information on how to write queries. -Note: The perdicates listed in the web page above differ from those Neovim +Note: The predicates listed in the web page above differ from those Neovim supports. See |lua-treesitter-predicates| for a complete list of predicates supported by Neovim. @@ -433,8 +433,13 @@ get_query_files({lang}, {query_name}, {is_included}) {is_included} Internal parameter, most of the time left as `nil` +list_directives() *list_directives()* + Return: ~ + The list of supported directives. + list_predicates() *list_predicates()* - TODO: Documentation + Return: ~ + The list of supported predicates. parse_query({lang}, {query}) *parse_query()* Parse {query} as a string. (If the query is in a file, the @@ -514,11 +519,9 @@ Query:iter_matches({self}, {node}, {source}, {start}, {stop}) for id, node in pairs(match) do local name = query.captures[id] -- `node` was captured by the `name` capture in the match -< -> - local node_data = metadata[id] -- Node level metadata -< -> + + local node_data = metadata[id] -- Node level metadata + ... use the info here ... end end diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index acd20a3e0b..a77c88e2dc 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -190,30 +190,41 @@ end --@private ---- Return a function that converts LSP responses to quickfix items and opens the qflist --- ---@param map_result function `((resp, bufnr) -> list)` to convert the response ---@param entity name of the resource used in a `not found` error message -local function response_to_qflist(map_result, entity) - return function(_, _, result, _, bufnr) +--- Return a function that converts LSP responses to list items and opens the list +--- +--- The returned function has an optional {config} parameter that accepts a table +--- with the following keys: +--- +--- loclist: (boolean) use the location list (default is to use the quickfix list) +--- +--- @param map_result function `((resp, bufnr) -> list)` to convert the response +--- @param entity name of the resource used in a `not found` error message +local function response_to_list(map_result, entity) + return function(_, _, result, _, bufnr, config) if not result or vim.tbl_isempty(result) then vim.notify('No ' .. entity .. ' found') else - util.set_qflist(map_result(result, bufnr)) - api.nvim_command("copen") + config = config or {} + if config.loclist then + util.set_loclist(map_result(result, bufnr)) + api.nvim_command("lopen") + else + util.set_qflist(map_result(result, bufnr)) + api.nvim_command("copen") + end end end end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_references -M['textDocument/references'] = response_to_qflist(util.locations_to_items, 'references') +M['textDocument/references'] = response_to_list(util.locations_to_items, 'references') --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol -M['textDocument/documentSymbol'] = response_to_qflist(util.symbols_to_items, 'document symbols') +M['textDocument/documentSymbol'] = response_to_list(util.symbols_to_items, 'document symbols') --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_symbol -M['workspace/symbol'] = response_to_qflist(util.symbols_to_items, 'symbols') +M['workspace/symbol'] = response_to_list(util.symbols_to_items, 'symbols') --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_rename M['textDocument/rename'] = function(_, _, result) diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index 0ba44ced1a..4ecd91d295 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -351,12 +351,12 @@ function M.add_directive(name, handler, force) directive_handlers[name] = handler end ---- Returns the list of currently supported directives +--- @return The list of supported directives. function M.list_directives() return vim.tbl_keys(directive_handlers) end ---- Returns the list of currently supported predicates +--- @return The list of supported predicates. function M.list_predicates() return vim.tbl_keys(predicate_handlers) end diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index b371c08d2a..78e36e5ef0 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -315,7 +315,7 @@ ArrayOf(String) nvim_buf_get_lines(uint64_t channel_id, } rv.size = (size_t)(end - start); - rv.items = xcalloc(sizeof(Object), rv.size); + rv.items = xcalloc(rv.size, sizeof(Object)); if (!buf_collect_lines(buf, rv.size, start, (channel_id != VIML_INTERNAL_CALL), &rv, err)) { diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9b0782f589..bbcfe173c5 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1696,7 +1696,7 @@ void nvim_put(ArrayOf(String) lines, String type, Boolean after, FUNC_API_SINCE(6) FUNC_API_CHECK_TEXTLOCK { - yankreg_T *reg = xcalloc(sizeof(yankreg_T), 1); + yankreg_T *reg = xcalloc(1, sizeof(yankreg_T)); if (!prepare_yankreg_from_object(reg, type, lines.size)) { api_set_error(err, kErrorTypeValidation, "Invalid type: '%s'", type.data); goto cleanup; diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index f46cac4637..1d131cc4b1 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -50,7 +50,7 @@ bool buf_updates_register(buf_T *buf, uint64_t channel_id, if (send_buffer) { Array args = ARRAY_DICT_INIT; args.size = 6; - args.items = xcalloc(sizeof(Object), args.size); + args.items = xcalloc(args.size, sizeof(Object)); // the first argument is always the buffer handle args.items[0] = BUFFER_OBJ(buf->handle); @@ -68,7 +68,7 @@ bool buf_updates_register(buf_T *buf, uint64_t channel_id, if (line_count >= 1) { linedata.size = line_count; - linedata.items = xcalloc(sizeof(Object), line_count); + linedata.items = xcalloc(line_count, sizeof(Object)); buf_collect_lines(buf, line_count, 1, true, &linedata, NULL); } @@ -93,7 +93,7 @@ void buf_updates_send_end(buf_T *buf, uint64_t channelid) { Array args = ARRAY_DICT_INIT; args.size = 1; - args.items = xcalloc(sizeof(Object), args.size); + args.items = xcalloc(args.size, sizeof(Object)); args.items[0] = BUFFER_OBJ(buf->handle); rpc_send_event(channelid, "nvim_buf_detach_event", args); } @@ -211,7 +211,7 @@ void buf_updates_send_changes(buf_T *buf, // send through the changes now channel contents now Array args = ARRAY_DICT_INIT; args.size = 6; - args.items = xcalloc(sizeof(Object), args.size); + args.items = xcalloc(args.size, sizeof(Object)); // the first argument is always the buffer handle args.items[0] = BUFFER_OBJ(buf->handle); @@ -230,7 +230,7 @@ void buf_updates_send_changes(buf_T *buf, if (num_added > 0) { STATIC_ASSERT(SIZE_MAX >= MAXLNUM, "size_t smaller than MAXLNUM"); linedata.size = (size_t)num_added; - linedata.items = xcalloc(sizeof(Object), (size_t)num_added); + linedata.items = xcalloc((size_t)num_added, sizeof(Object)); buf_collect_lines(buf, (size_t)num_added, firstline, true, &linedata, NULL); } @@ -394,7 +394,7 @@ void buf_updates_changedtick_single(buf_T *buf, uint64_t channel_id) { Array args = ARRAY_DICT_INIT; args.size = 2; - args.items = xcalloc(sizeof(Object), args.size); + args.items = xcalloc(args.size, sizeof(Object)); // the first argument is always the buffer handle args.items[0] = BUFFER_OBJ(buf->handle); diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 7afabc7913..3096fe84c0 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1018,14 +1018,14 @@ static ExtmarkUndoObject *unserialize_extmark(bufinfo_T *bi, bool *error, extup->type = type; if (type == kExtmarkSplice) { n_elems = (size_t)sizeof(ExtmarkSplice) / sizeof(uint8_t); - buf = xcalloc(sizeof(uint8_t), n_elems); + buf = xcalloc(n_elems, sizeof(uint8_t)); if (!undo_read(bi, buf, n_elems)) { goto error; } extup->data.splice = *(ExtmarkSplice *)buf; } else if (type == kExtmarkMove) { n_elems = (size_t)sizeof(ExtmarkMove) / sizeof(uint8_t); - buf = xcalloc(sizeof(uint8_t), n_elems); + buf = xcalloc(n_elems, sizeof(uint8_t)); if (!undo_read(bi, buf, n_elems)) { goto error; } |