aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
Commit message (Collapse)AuthorAge
* feat(lsp)!: vim.lsp.inlay_hint.get(), enable(), is_enabled() #25512LW2023-11-12
| | | | | | | | | | | | | | | | | | refactor!: `vim.lsp.inlay_hint()` -> `vim.lsp.inlay_hint.enable()` Problem: The LSP specification allows inlay hints to include tooltips, clickable label parts, and code actions; but Neovim provides no API to query for these. Solution: Add minimal viable extension point from which plugins can query for inlay hints in a range, in order to build functionality on top of. Possible Next Steps --- - Add `virt_text_idx` field to `vim.fn.getmousepos()` return value, for usage in mappings of `<LeftMouse>`, `<C-LeftMouse>`, etc
* refactor(lsp): move completion logic into _completion moduleMathias Fussenegger2023-10-21
| | | | | To reduce cross-chatter between modules and for https://github.com/neovim/neovim/issues/25272 Also preparing for https://github.com/neovim/neovim/issues/25714
* fix(lsp): display initialization errors (#25409)Maria José Solano2023-10-11
|
* docs: replace <pre> with ``` (#25136)Gregory Anders2023-09-14
|
* feat(lsp): remove notify from vim.lsp.buf_detach_client (#25140)Mathias Fußenegger2023-09-14
| | | Closes https://github.com/neovim/neovim/issues/19838
* refactor(lsp): add type annotation for lsp.Client.server_capabilities (#24925)Jongwook Choi2023-08-31
| | | | | | | | | | | | | | The class `lsp.Client` has a public member `server_capabilities`, which is assumed to be non-nil once initialized, as documented in `:help vim.lsp.client`. Due to the possibility that it may be nil before initialization, `lsp.Client` was not having a proper lua type annotations on the field `server_capabilities`. Instead of having a nil `server_capabilities` until initialized in the RPC response callback, we can have an initial value of empty table. This CHANGES the behavior of the `server_capabilities` field in a way that it is no longer `nil` until initialization. Note that, as already documented, `server_capabilities` should never be nil when it is once initialized and thus ready to be used in user configs.
* fix(lsp): only disable inlay hints / diagnostics if no other clients are ↵Chris AtLee2023-08-31
| | | | | | | | | | | | | | | | | | | connected (#24535) This fixes the issue where the LspNotify handlers for inlay_hint / diagnostics would end up refreshing all attached clients. The handler would call util._refresh, which called vim.lsp.buf_request, which calls the method on all attached clients. Now util._refresh takes an optional client_id parameter, which is used to specify a specific client to update. This commit also fixes util._refresh's handling of the `only_visible` flag. Previously if `only_visible` was false, two requests would be made to the server: one for the visible region, and one for the entire file. Co-authored-by: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com> Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
* fix(lsp): extra "." when completing with tsserver #24646Raphael2023-08-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: With tsserver LSP, omni completion after "." inserts an extra "." Solution: Apply adjust_start_col() regardless of `filterText`. adjust_start_col() is explained here: https://github.com/neovim/neovim/blob/0ea8dfeb3dc347579753169d9e3588f6306ab703/runtime/lua/vim/lsp.lua#L2334-L2351 The `filterText` field is used in the following situations rather than as a condition for obtaining column values: 1. Real-time filtering: When the user types characters in the editor, the language server can use the filterText field to filter the list of suggestions and only return suggestions that match the typed characters. This helps to provide more precise recommendations. 2. Fuzzy matching: The filterText field can be used to perform fuzzy matching, allowing matching in the middle or beginning of input characters, not limited to prefix matching. This can provide a more flexible code completion experience. Inspecting usage of `filtertext` in vim-lsp and coc and lsp-mode: - vim-lsp uses a `refresh_pattern` to judge filterText as completionitem word (although I think this is not the correct usage). - coc uses it for filtering. Fix #22803
* fix(lua): improve annotations for stricter luals diagnostics (#24609)Christian Clason2023-08-09
| | | | | | | | | | | | | | | Problem: luals returns stricter diagnostics with bundled luarc.json Solution: Improve some function and type annotations: * use recognized uv.* types * disable diagnostic for global `vim` in shared.lua * docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type) * add type alias for lpeg pattern * fix return annotation for `vim.secure.trust` * rename local Range object in vim.version (shadows `Range` in vim.treesitter) * fix some "missing fields" warnings * add missing required fields for test functions in eval.lua * rename lsp meta files for consistency
* refactor(lsp): use protocol.Methods instead of strings #24570Raphael2023-08-05
|
* fix(lsp): do not assume client capability exists in watchfiles check (#24550)Sean Dewar2023-08-04
| | | | | | | | | | | | | | | | | | | | | PR #23689 assumes `client.config.capabilities.workspace.didChangeWatchedFiles` exists when checking `dynamicRegistration`, but thats's true only if it was passed to `vim.lsp.start{_client}`. This caused #23806 (still an issue in v0.9.1; needs manual backport), but #23681 fixed it by defaulting `config.capabilities` to `make_client_capabilities` if not passed to `vim.lsp.start{_client}`. However, the bug resurfaces on HEAD if you provide a non-nil `capabilities` to `vim.lsp.start{_client}` with missing fields (e.g: not made via `make_client_capabilities`). From what I see, the spec says such missing fields should be interpreted as an absence of the capability (including those indicated by missing sub-fields): https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#clientCapabilities Also, suggest `vim.empty_dict()` for an empty dict in `:h vim.lsp.start_client()` (`{[vim.type_idx]=vim.types.dictionary}` no longer works anyway, probably since the cjson switch).
* refactor(lsp): use protocol.Methods instead of strings #24537Raphael2023-08-03
|
* feat(lsp): add actionable advice to lsp client quit error msg (#24510)Mathias Fußenegger2023-07-29
| | | Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(lsp): replace @private with @nodoc for public client functions (#24415)Mathias Fußenegger2023-07-24
| | | | | | | | | * fix(lsp): replace @private with @nodoc for public client functions To prevent lua-ls warnings in plugins which use the functions. * fix(lsp): remove duplicate type annotations/class definitions These annotations became duplicate with https://github.com/neovim/neovim/pull/23750
* refactor(lsp): use LspNotify for inlay_hint (#24411)Chris AtLee2023-07-22
|
* feat(lsp): implement textDocument/diagnostic (#24128)Chris AtLee2023-07-20
|
* feat(lsp): handle multiple clients in omnifunc (#24381)Mathias Fußenegger2023-07-19
| | | | | Also fixes https://github.com/neovim/neovim/issues/24369 by adding an extra `vim.schedule` to ensure the `vim.fn.complete` call happens outside of a luv callback
* 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>
* feat(lsp)!: rename vim.lsp.get_active_clients to get_clients (#24113)Mathias Fußenegger2023-07-17
|
* feat(lsp): map K to hover by default #24331Mathias Fußenegger2023-07-14
| | | Related: https://github.com/neovim/neovim/issues/24252
* feat(lsp): add method filter to get_active_clients (#24319)Mathias Fußenegger2023-07-12
|
* fix(lint): lint warnings #24226Raphael2023-07-10
|
* 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
* Merge #24116 from justinmk/docJustin M. Keyes2023-06-25
|\
| * docs: autocmds, miscJustin M. Keyes2023-06-25
| |
* | build(luarc.json): disable luadoc-miss-see-name #24108Raphael2023-06-23
|/
* feat(lsp): soft deprecate vim.lsp.for_each_buffer_client (#24104)Mathias Fußenegger2023-06-22
| | | | | | | There is no need for two ways to access all clients of a buffer. This doesn't add a `vim.deprecate` call yet, as the function is probably used a lot, but removes it from the documentation and annotates it with `@deprecated`
* test: spellcheck :help (vimdoc) files #24109Justin M. Keyes2023-06-22
| | | | | | | Enforce consistent terminology (defined in `gen_help_html.lua:spell_dict`) for common misspellings. This does not spellcheck English in general (perhaps a future TODO, though it may be noisy).
* perf(lsp): remove grouping logic from lsp.status (#24096)Mathias Fußenegger2023-06-22
| | | | With the title carry-over logic in the `$/progress` handler it's not necessary to group again in vim.lsp.status
* refactor(lsp): report full Nvim version string in clientInfoJustin M. Keyes2023-06-21
|
* fix(lsp): always return boolean in lsp.buf_client_attach (#24077)Sooryakiran Ponnath2023-06-20
| | | Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
* refactor(lsp): extract common execute command functionality (#24065)Mathias Fußenegger2023-06-20
|
* 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
* docs #24061Justin M. Keyes2023-06-19
| | | | | | | | | | | | | | - nvim requires rpc responses in reverse order. https://github.com/neovim/neovim/issues/19932 - NVIM_APPNAME: UIs normally should NOT set this. ref #23520 fix #24050 fix #23660 fix #23353 fix #23337 fix #22213 fix #19161 fix #18088 fix #20693
* fix(lsp): handle stale bufnr on LspRequest autocmd trigger (#24013)Mathias Fußenegger2023-06-13
| | | | | | Fixes a `Invalid buffer id: 123` race when the buffer gets deleted before the callback triggered. Alternative to https://github.com/neovim/neovim/pull/23981
* feat(lsp): add handlers for inlay hints (#23736)Chinmay Dalal2023-06-11
| | | initial support; public API left for a follow-up PR
* fix(lsp): use percentage format on lsp.status (#23971)Raphael2023-06-10
|
* 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
* fix(lsp): reduce diagnostics and add more types (#23948)Lewis Russell2023-06-07
|
* feat(lua): rename vim.loop -> vim.uv (#22846)Lewis Russell2023-06-03
|
* feat(lsp): set client offset_encoding if server supports positionEncodingGregory Anders2023-06-01
| | | | | | If the server sends the positionEncoding capability in its initialization response, automatically set the client's offset_encoding to use the value provided.
* fix(lsp): add param assert in client_is_stopped (#23857)Raphael2023-06-01
|
* feat(lsp)!: promote LspRequest to a full autocmd and enrich with additional ↵jdrouhard2023-05-30
| | | | | | | | | | | | | | | | | | | | | data (#23694) BREAKING CHANGE: LspRequest is no longer a User autocmd but is now a first class citizen. LspRequest as a User autocmd had limited functionality. Namely, the only thing you could do was use the notification to do a lookup on all the clients' requests tables to figure out what changed. Promoting the autocmd to a full autocmd lets us set the buffer the request was initiated on (so people can set buffer-local autocmds for listening to these events). Additionally, when used from Lua, we can pass additional metadata about the request along with the notification, including the client ID, the request ID, and the actual request object stored on the client's requests table. Users can now listen for these events and act on them proactively instead of polling all of the requests tables and looking for changes.
* 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>
* docs: small fixesdundargoc2023-05-13
| | | | | | | | | Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: HiPhish <hiphish@posteo.de> Co-authored-by: Julio B <julio.bacel@gmail.com> Co-authored-by: T727 <74924917+T-727@users.noreply.github.com> Co-authored-by: camoz <camoz@users.noreply.github.com> Co-authored-by: champignoom <66909116+champignoom@users.noreply.github.com>
* docs(lsp): fix `config.cmd` argument for `vim.lsp.start_client` (#23560)hituzi no sippo2023-05-09
|
* docs(lsp): fix type of `config.cmd` argument for `vim.lsp.start_client` (#23550)hituzi no sippo2023-05-09
|
* feat(lua): vim.tbl_contains supports general tables and predicates (#23040)Christian Clason2023-04-14
| | | | | | | | | | | | * feat(lua): vim.tbl_contains supports general tables and predicates Problem: `vim.tbl_contains` only works for list-like tables (integer keys without gaps) and primitive values (in particular, not for nested tables). Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new `vim.tbl_contains` that works for general tables and optionally allows `value` to be a predicate function that is checked for every key.
* 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.