aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
Commit message (Collapse)AuthorAge
* fix(gen_vimdoc.py): spacing around inline elements #16092Gregory Anders2021-10-19
| | | | | The spacing fix drew attention to a couple of places that were using incorrect formatting such as the key listing for `nvim_open_win`, so those were fixed too.
* refactor(diagnostic)!: replace 'show_*' functions with 'open_float' (#16057)Gregory Anders2021-10-19
| | | | | | | | | | | | | | | | | | | | 'show_line_diagnostics()' and 'show_position_diagnostics()' are almost identical; they differ only in the fact that the latter also accepts a column to form a full position, rather than just a line. This is not enough to justify two separate interfaces for this common functionality. Renaming this to simply 'show_diagnostics()' is one step forward, but that is also not a good name as the '_diagnostics()' suffix is redundant. However, we cannot name it simply 'show()' since that function already exists with entirely different semantics. Instead, combine these two into a single 'open_float()' function that handles all of the cases of showing diagnostics in a floating window. Also add a "float" key to 'vim.diagnostic.config()' to provide global values of configuration options that can be overridden ephemerally. This makes the float API consistent with the rest of the diagnostic API. BREAKING CHANGE
* feat(lsp): set codelens virtual text hl_mode to combine (#16048)sim2021-10-19
| | | | | It looks a bit off with the extmark going over the cursorline. (With hl_mode combine it keeps the background of the cursorline under the codelens virtualtext)
* feat(lsp): use vim.ui.select() in codelenses (#16004)Josa Gesell2021-10-18
| | | Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com> Mathias Fußenegger <mfussenegger@users.noreply.github.com>
* fix(lsp): fix cursor row after textEdits (#16038)hrsh7th2021-10-18
|
* fix(lsp): persist diagnostic config for clientsGregory Anders2021-10-18
| | | | | Persist configuration settings set with `vim.lsp.with` and `vim.lsp.diagnostic.on_publish_diagnostics` by setting the config for the namespace associated with the client.
* fix(diagnostic): do not override existing config settings #16043Gregory Anders2021-10-17
| | | | | | | | | | | When using `true` as the value of a configuration option, the option is configured to use default values. For example, if a user configures virtual text to include the source globally (using vim.diagnostic.config) and a specific namespace or producer configures virtual text with `virt_text = true`, the user's global configuration is overriden. Instead, interpret a value of `true` to mean "use existing settings if defined, otherwise use defaults".
* fix: correctly capture uri scheme on windows (#16027)Michael Lingelbach2021-10-15
| | | | | | closes https://github.com/neovim/neovim/issues/15261 * normalize uri path to forward slashes on windows * use a capture group on windows that avoids mistaking drive letters as uri scheme
* fix(lsp): maintain client_ids table structure when filtering (#15991)Jose Alvarez2021-10-11
|
* fix(lsp): do not invoke handlers for unsupported methods (#15926)Michael Lingelbach2021-10-10
| | | | | | | Closes https://github.com/neovim/neovim/issues/15174 Instead of invoking handlers with unsupported methods, pre-compute which clients support a given method and only notify the user if no clients support the given method.
* fix(lsp): add done flag to messages returned in util.get_progress_messages() ↵jdrouhard2021-10-10
| | | | (#15985)
* fix(lsp): add textDocument/prepareRename to capability map (#15961)francisco souza2021-10-08
| | | | | | | | | | This is a simple fix for #15899, as it should at least stop calling `prepareRename` on servers that don't support renaming. I imagine a better fix would be to inspect the actual value for, but that requires some plumbing changes on how capabilities are evaluated before sending requests out. Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
* fix(diagnostic): error on invalid severity value (#15965)Gregory Anders2021-10-08
| | | | | | | Users can pass string values for severities that match with the enum names (e.g. "Warn" or "Info") which are converted to the corresponding numerical value in `to_severity`. Invalid strings were simply left as-is, which caused confusing errors later on. Instead, report an invalid severity string right up front to make the problem clear.
* fix(lsp): expose ContentModified error code to callbacks (#15262)Rishikesh Vaishnav2021-10-08
|
* feat(lsp): utilize textEdit.range for startbyte in omnifunc (#15957)Mathias Fußenegger2021-10-08
| | | Closes https://github.com/neovim/neovim/issues/15784
* fix: support severity_sort option for show_diagnostic functions (#15948)Gregory Anders2021-10-07
| | | Support the severity_sort option for show_{line,position}_diagnostics.
* feat(diagnostic): update jumplist on goto_next/prev (#15942)Sean Dewar2021-10-07
|
* feat(lsp): improve json deserialization performance (#15854)Michael Lingelbach2021-10-05
| | | | | | | | | | * Add optional second table argument to vim.json.decode which takes a table 'luanil' which can include the 'object' and/or 'array' keys. These options use luanil when converting NULL in json objects and arrays respectively. The default behavior matches the original lua-cjson. * Remove recursive_convert_NIL function from rpc.lua, use vim.json.decode with luanil = { object = true } instead. This removes a hotpath in the json deserialization pipeline by dropping keys with json NULL values throughout the deserialized table.
* fix(healthcheck): update builtins to the new convention #15914Javier Lopez2021-10-05
| | | Adjust some builtin healthchecks to use Lua, after #15259
* Merge #15218 from gpanders/split-trimemptyJustin M. Keyes2021-10-03
|\ | | | | feat(lua): add "noempty" param to vim.split()
| * refactor: use kwargs parameter in vim.splitGregory Anders2021-09-25
| |
| * feat: add trimempty optional parameter to vim.splitGregory Anders2021-09-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `split()` VimL function trims empty items from the returned list by default, so that, e.g. split("\nhello\nworld\n\n", "\n") returns ["hello", "world"] The Lua implementation of vim.split does not do this. For example, vim.split("\nhello\nworld\n\n", "\n") returns {'', 'hello', 'world', '', ''} Add an optional parameter to the vim.split function that, when true, trims these empty elements from the front and back of the returned table. This is only possible for vim.split and not vim.gsplit; because vim.gsplit is an iterator, there is no way for it to know if the current item is the last non-empty item. Note that in order to preserve backward compatibility, the parameter for the Lua vim.split function is `trimempty`, while the VimL function uses `keepempty` (i.e. they are opposites). This means there is a disconnect between these two functions that may surprise users.
* | Merge pull request #15786 from gpanders/diagnostic-signs-unique-severityGregory Anders2021-10-02
|\ \
| * | refactor(diagnostics): always make 'set' go through 'show'Gregory Anders2021-10-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always make calls to `vim.diagnostic.set` call `vim.diagnostic.show`. This creates an easier to reason about code path and is also less surprising when users wish to override override `vim.diagnostic.show` with custom behavior and `vim.diagnostic.set` is called with empty diagnostics. Functionally, the end result is the same: when `show` is called with an empty diagnostics list, it just calls `hide` and then returns, which is exactly what `reset` does right now.
* | | docs(lsp): clarify parameters of some util functions (#15851)zeertzjq2021-10-02
| | | | | | | | | | | | `pad_left` and `pad_right` are unused List used keys of `opts` in `make_floating_popup_options`
* | | fix(float)!: always anchor to corner of window including border #15832zeertzjq2021-10-02
|/ / | | | | | | | | | | | | | | | | | | N, W, S, E are all inclusive, i.e., always anchor to the exact corner of the window (including border). This line may also need change in this case (change 0 to -1): This is most consistent and easiest to reason about, especially with GUIs whose border do not need to have width/height of 1/1 in cell units. Fix #15789
* | feat(diagnostics): add vim.diagnostic.get_namespaces (#15866)Michael Lingelbach2021-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many vim.diagnostic functions expect the user to pass in a namespace id. This PR allows the user to list active diagnostic namespaces: ```lua :lua print(vim.inspect(vim.diagnostic.get_namespaces())) { [7] = { name = "vim.lsp.client-1", opts = {}, sign_group = "vim.diagnostic.vim.lsp.client-1" } } ```
* | docs(diagnostics): add "priority" option to signs table (#15860)Gregory Anders2021-10-01
| | | | | | | | This feature was added in #15785, but the docs for vim.diagnostic.config() weren't updated.
* | feat(lsp): add codeAction/resolve support (#15818)Mathias Fußenegger2021-09-28
| | | | | | Closes https://github.com/neovim/neovim/issues/15339 and https://github.com/neovim/neovim/issues/15828
* | feat(lsp): add client command support to codelens (#15820)Mathias Fußenegger2021-09-28
| | | | | | | | Also adds a check against the server capabilities to fix https://github.com/neovim/neovim/issues/15183
* | refactor(lsp): remove json encode/decode wrappers (#15826)Mathias Fußenegger2021-09-28
| |
* | fix(ui): s/format_entry/format_item to match docs (#15819)Mathias Fußenegger2021-09-27
| | | | | | Follow up to https://github.com/neovim/neovim/pull/15771
* | feat(ui): add vim.ui.select and use in code actions (#15771)Mathias Fußenegger2021-09-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Continuation of https://github.com/neovim/neovim/pull/15202 A plugin like telescope could override it with a fancy implementation and then users would get the telescope-ui within each plugin that utilizes the vim.ui.select function. There are some plugins which override the `textDocument/codeAction` handler solely to provide a different UI. With custom client commands and soon codeAction resolve support, it becomes more difficult to implement the handler right - so having a dedicated way to override the picking function will be useful.
* | fix(lsp): avoid serializing boolean as key (#15810)Michael Lingelbach2021-09-27
| | | | | | | | | | | | In vim.lsp.buf.references, the key vim.type_idx (which evaluates to a boolean) was set to equal vim.types.dictionary. This resulted in a boolean key in json which is not allowed by the json spec, and which lua-cjson fails to serialize.
* | refactor(diagnostic): use sign priority for severity_sort #15785Gregory Anders2021-09-26
| | | | | | | | | | | | | | Rather than relying on the order in which signs are placed to dictate the order in which they are displayed, explicitly set the priority of the sign according to the severity of the diagnostic and the value of severity_sort. If severity_sort is false or unset then all signs use the same priority.
* | feat(lsp): allow subset of CodeActionContext as arg to code_action methods ↵Mathias Fußenegger2021-09-26
| | | | | | | | | | | | | | | | | | (#15793) This makes it easier to filter the code actions. For example: vim.lsp.buf.code_action { only = 'refactor' }
* | feat(lsp): use cjson for lsp rpc (#15759)Michael Lingelbach2021-09-26
|/
* fix(lsp): guard textDocument/codeAction command logic #15769Chris Kipp2021-09-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Error executing vim.schedule lua callback: ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: command: expected string, got nil stack traceback: ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: in function 'execute_command' ...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:151: in function <...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:113> ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:465: in function 'callback' ...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:1325: in function 'handler' ...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:899: in function 'cb' vim.lua:281: in function <vim.lua:281> Solution: This is a follow-up to the work done in https://github.com/neovim/neovim/commit/6c03601e3adb4c3c4d47f148df8df20401b88677. There are valid situations where a `textDocument/codeAction` is returned without a command, since a command in optional. For example from Metals, the Scala language server when you get a code action to add a missing import, it looks like this: ```json Result: [ { "title": "Import \u0027Instant\u0027 from package \u0027java.time\u0027", "kind": "quickfix", "diagnostics": [ { "range": { "start": { "line": 6, "character": 10 }, "end": { "line": 6, "character": 17 } }, "severity": 1, "source": "bloop", "message": "not found: value Instant" } ], "edit": { "changes": { "file:///Users/ckipp/Documents/scala-workspace/sanity/src/main/scala/Thing.scala": [ { "range": { "start": { "line": 6, "character": 10 }, "end": { "line": 6, "character": 17 } }, "newText": "Instant" }, { "range": { "start": { "line": 1, "character": 0 }, "end": { "line": 1, "character": 0 } }, "newText": "\nimport java.time.Instant\n" } ] } } } ] ``` This change just wraps the logic that grabs the command in a conditional to skip it if there is no command.
* fix(diagnostic): check for nil in show_diagnostics (#15772)Gregory Anders2021-09-23
|
* fix(diagnostic): don't return nil when callers expect a table (#15765)Gregory Anders2021-09-23
| | | | | | diagnostic_lines() returns a table, so make the early exit condition an empty table rather than 'nil'. This way, functions that use the input from diagnostic_lines don't have to do a bunch of defensive nil checking and can always assume they're operating on a table.
* feat(diagnostic): allow customized diagnostic messages (#15742)Gregory Anders2021-09-22
| | | | Provide a 'format' option for virtual text and floating window previews that allows the displayed text of a diagnostic to be customized.
* Merge pull request #14115 from mfussenegger/lsp-commandsMichael Lingelbach2021-09-22
|\ | | | | lsp: Add a registry for client side code action commands
| * feat(lsp): add a registry for client side code action commandsMathias Fussenegger2021-09-20
| | | | | | | | | | This builds on https://github.com/neovim/neovim/pull/14112 and closes https://github.com/neovim/neovim/issues/12326
| * feat(lsp): include original request params in handler ctxMathias Fussenegger2021-09-20
| | | | | | | | | | | | | | | | | | | | | | This is mostly motivated by https://github.com/neovim/neovim/issues/12326 Client side commands might need to access the original request parameters. Currently this is already possible by using closures with `vim.lsp.buf_request`, but the global handlers so far couldn't access the request parameters.
* | refactor(diagnostic): remove get_virt_text_chunks()Gregory Anders2021-09-21
| | | | | | | | | | | | | | | | | | This function isn't compatible with including diagnostic sources when "source" is "if_many" since it only has access to diagnostics for a single line. Rather than having an inconsistent or incomplete interface, make this function private. It is still exported as part of the module for backward compatibility with vim.lsp.diagnostics, but it can eventually be made into a local function.
* | feat(diagnostic): add option to include diagnostic sourceGregory Anders2021-09-21
| | | | | | | | | | Add an option to virtual text display and floating window previews to include diagnostic source in the diagnostic message.
* | fix(diagnostic): preserve fields from LSP diagnostics via user_data (#15735)masterGregory Anders2021-09-21
| | | | | | * preserve fields from LSP diagnostics via adding a user_data table to the diagnostic, which can hold arbitrary data in addition to the lsp diagnostic information.
* | fix(lsp): update lsp-handler signature in call_hierarchy (#15738)Mathias Fußenegger2021-09-21
|/ | | | | | | | This fixes the handler signature and also prevents n+1 requests firing if there are multiple clients. (The first `prepareCallHierarchy` handler is called once per client, each invocation used `buf_request` to make more requests using *all* clients)
* fix(diagnostic): clamp line numbers in display layer (#15729)Gregory Anders2021-09-20
| | | | | | Some parts of LSP need to use cached diagnostics as sent from the LSP server unmodified. Rather than fixing invalid line numbers when diagnostics are first set, fix them when they are displayed to the user (e.g. in show() or one of the get_next/get_prev family of functions).
* feat(diagnostic): match(), tolist(), fromlist() #15704Gregory Anders2021-09-19
| | | | | | * feat(diagnostic): add vim.diagnostic.match() Provide vim.diagnostic.match() to generate a diagnostic from a string and a Lua pattern. * feat(diagnostic): add tolist() and fromlist()