aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/handlers.lua
Commit message (Collapse)AuthorAge
* fix(lsp): call `on_list()` even for single location (#25830)Evgeni Chasnovski2023-10-31
| | | | | | | | Problem: Currently there is no way of customizing behavior of `declaration`, `definition`, `typeDefinition`, and `implementation` methods in `vim.lsp.buf` when LSP server returns `Location`. Instead, cursor jumps to that location directly. Solution: Normalize LSP response to be `Location[]` for those four cases.
* fix(lsp): highlight active parameter in signature help #25663Maria José Solano2023-10-16
| | | Fixes #25662
* docs: do not hardcode LSP version in URL #25648Maria José Solano2023-10-16
|
* fix(lsp)!: deprecate trim_empty_linesMaria José Solano2023-09-19
|
* feat(lsp): use treesitter for stylize markdownMaria José Solano2023-09-19
|
* docs: replace <pre> with ``` (#25136)Gregory Anders2023-09-14
|
* feat(lsp): improve control over placement of floating windows (#24494)Grace Petryk2023-09-10
|
* fix(lsp): wrong iterator in registerCapability handler (#24971)TheBlob422023-09-01
|
* refactor(lsp): use protocol.Methods instead of strings #24537Raphael2023-08-03
|
* feat(lsp): implement textDocument/diagnostic (#24128)Chris AtLee2023-07-20
|
* docs(lua): more improvements (#24387)Lewis Russell2023-07-18
| | | | | | | | | | | | | | | | | * docs(lua): teach lua2dox how to table * docs(lua): teach gen_vimdoc.py about local functions No more need to mark local functions with @private * docs(lua): mention @nodoc and @meta in dev-lua-doc * fixup! Co-authored-by: Justin M. Keyes <justinkz@gmail.com> --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(lint): lint warnings #24226Raphael2023-07-10
|
* fix(vim.ui.open): return (don't show) error messageJustin M. Keyes2023-07-05
| | | | | | | | | | Problem: Showing an error via vim.notify() makes it awkward for callers such as lsp/handlers.lua to avoid showing redundant errors. Solution: Return the message instead of showing it. Let the caller decide whether and when to show the message.
* fix(gx): visual selection, expand env varsJustin M. Keyes2023-07-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --- Rejected experiment: move vim.ui.open() to vim.env.open() Problem: `vim.ui` is where user-interface "providers" live, which can be overridden. It would also be useful to have a "providers" namespace for platform-specific features such as "open", clipboard, python, and the other providers listed in `:help providers`. We could overload `vim.ui` to serve that purpose as the single "providers" namespace, but `vim.ui.nodejs()` for example seems awkward. Solution: `vim.env` currently has too narrow of a purpose. Overload it to also be a namespace for `vim.env.open`. diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index 913f1fe20348..17d05ff37595 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -37,8 +37,28 @@ local options_info = setmetatable({}, { end, }) -vim.env = setmetatable({}, { - __index = function(_, k) +vim.env = setmetatable({ + open = setmetatable({}, { + __call = function(_, uri) + print('xxxxx'..uri) + return true + end, + __tostring = function() + local v = vim.fn.getenv('open') + if v == vim.NIL then + return nil + end + return v + end, + }) + }, + { + __index = function(t, k, ...) + if k == 'open' then + error() + -- vim.print({...}) + -- return rawget(t, k) + end local v = vim.fn.getenv(k) if v == vim.NIL then return nil
* feat(vim.ui): vim.ui.open, "gx" without netrwmarshmallow2023-07-04
| | | | | | Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com> Co-authored-by: ii14 <59243201+ii14@users.noreply.github.com>
* feat(lsp): move inlay_hint() to vim.lsp (#24130)Mathias Fußenegger2023-06-30
| | | | | | Allows to keep more functions hidden and gives a path forward for further inlay_hint related functions - like applying textEdits. See https://github.com/neovim/neovim/pull/23984#pullrequestreview-1486624668
* feat(lsp): inlay hints #23984Chinmay Dalal2023-06-19
| | | | | | | | | | | Add automatic refresh and a public interface on top of #23736 * add on_reload, on_detach handlers in `enable()` buf_attach, and LspDetach autocommand in case of manual detach * unify `__buffers` and `hint_cache_by_buf` * use callback bufnr in `on_lines` callback, bufstate: remove __index override * move user-facing functions into vim.lsp.buf, unify enable/disable/toggle Closes #18086
* feat(lsp): add handlers for inlay hints (#23736)Chinmay Dalal2023-06-11
| | | initial support; public API left for a follow-up PR
* feat(lsp)!: add vim.lsp.status, client.progress and promote ↵Mathias Fußenegger2023-06-09
| | | | | | | | | | | | | | | | | | | | | LspProgressUpdate (#23958) `client.messages` could grow unbounded because the default handler only added new messages, never removing them. A user either had to consume the messages by calling `vim.lsp.util.get_progress_messages` or by manually removing them from `client.messages.progress`. If they didn't do that, using LSP effectively leaked memory. To fix this, this deprecates the `messages` property and instead adds a `progress` ring buffer that only keeps at most 50 messages. In addition it deprecates `vim.lsp.util.get_progress_messages` in favour of a new `vim.lsp.status()` and also promotes the `LspProgressUpdate` user autocmd to a regular autocmd to allow users to pattern match on the progress kind. Also closes https://github.com/neovim/neovim/pull/20327
* feat(lsp): initial support for dynamic capabilities (#23681)Folke Lemaitre2023-05-28
| | | | | | | | | | | | - `client.dynamic_capabilities` is an object that tracks client register/unregister - `client.supports_method` will additionally check if a dynamic capability supports the method, taking document filters into account. But only if the client enabled `dynamicRegistration` for the capability - updated the default client capabilities to include dynamicRegistration for: - formatting - rangeFormatting - hover - codeAction - hover - rename
* refactor(options): deprecate nvim[_buf|_win]_[gs]et_optionLewis Russell2023-05-21
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: famiu <famiuhaque@protonmail.com>
* refactor: remove modelines from Lua filesGregory Anders2023-04-13
| | | | Now that we have builtin EditorConfig support and a formatting check in CI, these are not necessary.
* fix(lsp): add missing silent check in lsp hover handler (#22763)Micah Halter2023-03-25
| | | Fixup to #21531.
* feat(lsp): implement workspace/didChangeWatchedFiles (#22405)Jon Huhn2023-03-05
|
* Revert "feat(lsp): implement workspace/didChangeWatchedFiles (#21293)"Mathias Fussenegger2023-02-25
| | | | | | This reverts commit 5732aa706c639b3d775573d91d1139f24624629c. Causes editor to freeze in projects with many watcher registrations
* feat(lsp): implement workspace/didChangeWatchedFiles (#21293)Jon Huhn2023-02-25
|
* fix(lsp): assert workspace/applyEdit receives params (#21945)Mathias Fußenegger2023-01-22
| | | | | | | | | | | | | According to the specification `workspace/applyEdit` must be called with `ApplyWorkspaceEditParams`. So far the client just returned, which could lead to a misleading error on the server side because `workspace/applyEdit` must respond with a `ApplyWorkspaceEditResult`. This adds an assertion to clarify that the server is violating the specification. See https://github.com/neovim/neovim/issues/21925
* feat(float): open float relative to mouse #21531Sebastian Lyng Johansen2023-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: No easy way to position a LSP hover window relative to mouse. Solution: Introduce another option to the `relative` key in `nvim_open_win()`. With this PR it should be possible to override the handler and do something similar to this https://github.com/neovim/neovim/pull/19481#issuecomment-1193248674 to have hover information displayed from the mouse. Test case: ```lua local util = require('vim.lsp.util') local function make_position_param(window, offset_encoding) window = window or 0 local buf = vim.api.nvim_win_get_buf(window) local row, col local mouse = vim.fn.getmousepos() row = mouse.line col = mouse.column offset_encoding = offset_encoding or util._get_offset_encoding(buf) row = row - 1 local line = vim.api.nvim_buf_get_lines(buf, row, row + 1, true)[1] if not line then return { line = 0, character = 0 } end if #line < col then return { line = 0, character = 0 } end col = util._str_utfindex_enc(line, col, offset_encoding) return { line = row, character = col } end local make_params = function(window, offset_encoding) window = window or 0 local buf = vim.api.nvim_win_get_buf(window) offset_encoding = offset_encoding or util._get_offset_encoding(buf) return { textDocument = util.make_text_document_params(buf), position = make_position_param(window, offset_encoding), } end local hover_timer = nil vim.o.mousemoveevent = true vim.keymap.set({ '', 'i' }, '<MouseMove>', function() if hover_timer then hover_timer:close() end hover_timer = vim.defer_fn(function() hover_timer = nil local params = make_params() vim.lsp.buf_request( 0, 'textDocument/hover', params, vim.lsp.with(vim.lsp.handlers.hover, { silent = true, focusable = false, relative = 'mouse', }) ) end, 500) return '<MouseMove>' end, { expr = true }) ```
* fix(lsp): call show_document with correct argsMathias Fussenegger2022-12-04
| | | | Closes https://github.com/neovim/neovim/issues/21177
* docs(gen): support language annotation in docstringsChristian Clason2022-12-02
|
* feat(lsp): support set title in lsp relate floatwindow (#21110)Raphael2022-11-21
|
* fix(lsp): ignore hover and signatureHelp responses on buffer change (#21121)Grzegorz Rozdzialik2022-11-19
| | | | | | | | | | | | | | | | | | | Language servers can take some time to respond to the `textDocument/hover` and `textDocument/signatureHelp` messages. During that time, the user could have already moved to another buffer. The popup was always shown in the current buffer, which could be a different one than the buffer for which the request was sent. This was particularly annoying when moving to a buffer with a `BufLeave` autocmd, as that autocmd was triggered when the hover popup was shown for the original buffer. Ignoring the response from these 2 messages if they are for a buffer that is not the current one leads to less noise. The popup will only be shown for the buffer for which it was requested. A more robust solution could involve cancelling the hover/signatureHelp request if the buffer changes so the language server can free its resources. It could be implemented in the future.
* feat(lsp): run handler in coroutine to support async response (#21026)Mathias Fußenegger2022-11-19
| | | | To illustrate a use-case this also changes `window/showMessageRequest` to use `vim.ui.select`
* fix(lsp/window_showDocument): correctly handle external resources #20867lvimuser2022-10-30
| | | | | - since cmd is a list, it runs directly ('no shell') and we shouldn't escape. - typo: shellerror -> shell_error
* fix(lua): properly configure luacheck and remove `local vim = ...` lines ↵Folke Lemaitre2022-10-09
| | | | (#20551)
* feat(lsp): support window/showDocument (#19977)lvimuser2022-10-08
|
* fix(docs): invalid :help links #20345Justin M. Keyes2022-09-25
| | | | | Fix those naughty single quotes. closes #20159
* fix(lsp): prevent unexpected position jumps (#19370)rhcher2022-08-03
|
* feat(lsp): provide feedback if server can't compute rename result (#19546)Mathias Fußenegger2022-07-27
| | | | | Without some form of feedback a user cannot easily tell if the server is still computing the result (which can take a while in large projects), or whether the server couldn't compute the rename result.
* feat(lsp): allow passing custom list handler to LSP functions that return ↵Dalius Dobravolskas2022-07-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lists (#19213) Currently LSP allows only using loclist or quickfix list window. I normally prefer to review all quickfix items without opening quickfix window. This fix allows passing `on_list` option which allows full control what to do with list. Here is example how to use it with quick fix list: ```lua local function on_list(options) vim.fn.setqflist({}, ' ', options) vim.api.nvim_command('cfirst') end local bufopts = { noremap=true, silent=true, buffer=bufnr } vim.keymap.set('n', '<leader>ad', function() vim.lsp.buf.declaration{on_list=on_list} end, bufopts) vim.keymap.set('n', '<leader>d', function() vim.lsp.buf.definition{on_list=on_list} end, bufopts) vim.keymap.set('n', '<leader>ai', function() vim.lsp.buf.implementation{on_list=on_list} end, bufopts) vim.keymap.set('n', '<leader>at', function() vim.lsp.buf.type_definition{on_list=on_list} end, bufopts) vim.keymap.set('n', '<leader>af', function() vim.lsp.buf.references(nil, {on_list=on_list}) end, bufopts) ``` If you prefer loclist do something like this: ```lua local function on_list(options) vim.fn.setloclist(0, {}, ' ', options) vim.api.nvim_command('lopen') end ``` close #19182 Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
* refactor(lsp): use autocmd api (#19407)ii142022-07-17
| | | | | | | * refactor(lsp): use autocmd api * refactor(lsp): inline BufWritePost and VimLeavePre callbacks
* refactor: use `local api = vim.api`ii142022-07-15
|
* refactor(lsp): make the use of local aliases more consistentii142022-07-15
|
* refactor(lua): reformat with stylua 0.14.0 (#19264)Christian Clason2022-07-07
| | | | * reformat Lua runtime to make lint CI pass * reduce max line length to 100
* fix(lsp): include cancellable in progress message table (#18809)Chris Kipp2022-05-31
| | | | | | | | Currently the `title`, `message` and `percentage` is stored for a progress, but there is also an optional `cancellable` that comes in with both the `WorkDoneProgressBegin` and also `WorkDoneProgressReport`. This change also stores that value so that a plugin can access it when they do a lookup in `client.messages`.
* feat(lsp): option to reuse_win for jump actions (#18577)Lewis Russell2022-05-18
|
* chore: format runtime with styluaChristian Clason2022-05-09
|
* fix(handlers): more specific error messages (#16772)kylo2522022-04-30
| | | | Specify which message, or request, was last received in case of an error instead of the same generic message
* chore(lsp): remove capabilities sanitization (#17814)Michael Lingelbach2022-04-30
| | | | | | | | | | | | | | | | * feat(lsp)!: remove capabilities sanitization Users must now access client.server_capabilities which matches the same structure as the protocol. https://microsoft.github.io/language-server-protocol/specification client.resolved_capabilities is no longer used to gate capabilities, and will be removed in a future release. BREAKING CHANGE Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
* feat(lsp): show feedback on empty hover response (#18308)Mathias Fußenegger2022-04-29
| | | | Without any feedback it gives the impression that the language server is not working properly, which isn't the case.