aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
Commit message (Collapse)AuthorAge
...
* refactor(lsp): tidy up loggingLewis Russell2024-02-08
|
* refactor(lsp): move client code to a regular Lua classLewis Russell2024-02-07
| | | | | | | | | | Problem: The LSP client code is implemented as a complicated closure-class (class defined in a single function). Solution: Move LSP client code to a more conventional Lua class and move to a separate file.
* fix(lsp): fix infinite loop on vim.lsp.tagfuncJongwook Choi2024-02-03
| | | | | | | | Problem: vim.lsp.tagfunc() causes an infinite loop. This is a bug happened while introducing deferred loading. Solution: Rename the private module to `vim.lsp._tagfunc`.
* refactor: create function for deferred loadingdundargoc2024-02-03
| | | | | | | | | | | | | | | | The benefit of this is that users only pay for what they use. If e.g. only `vim.lsp.buf_get_clients()` is called then they don't need to load all modules under `vim.lsp` which could lead to significant startuptime saving. Also `vim.lsp.module` is a bit nicer to user compared to `require("vim.lsp.module")`. This isn't used for some nested modules such as `filetype` as it breaks tests with error messages such as "attempt to index field 'detect'". It's not entirely certain the reason for this, but it is likely it is due to filetype being precompiled which would imply deferred loading isn't needed for performance reasons.
* docs: various #25289Justin M. Keyes2024-01-18
| | | | | | Co-authored-by: Jongwook Choi <wookayin@gmail.com> Co-authored-by: Oliver Marriott <hello@omarriott.com> Co-authored-by: Benoit de Chezelles <bew@users.noreply.github.com> Co-authored-by: Jongwook Choi <wookayin@gmail.com>
* fix(lsp): fix incorrect typing and doc for `vim.lsp.rpc`Jongwook Choi2024-01-14
| | | | | | | | | | | | Typings introduced in #26032 and #26552 have a few conflicts, so we merge and clean them up. We also fix some incorrect type annotation in the `vim.lsp.rpc` package. See the associated PR for more details. Summary: - vim.rpc.Dispatchers -> vim.lsp.rpc.Dispatchers - vim.lsp.rpc.Error -> lsp.ResponseError - Revise docs
* feat(lua): add noref to deepcopyLewis Russell2024-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Currently `deepcopy` hashes every single tables it copies so it can be reused. For tables of mostly unique items that are non recursive, this hashing is unnecessarily expensive Solution: Port the `noref` argument from Vimscripts `deepcopy()`. The below benchmark demonstrates the results for two extreme cases of tables of different sizes. One table that uses the same table lots of times and one with all unique tables. | test | `noref=false` (ms) | `noref=true` (ms) | | -------------------- | ------------------ | ----------------- | | unique tables (50) | 6.59 | 2.62 | | shared tables (50) | 3.24 | 6.40 | | unique tables (2000) | 23381.48 | 2884.53 | | shared tables (2000) | 3505.54 | 14038.80 | The results are basically the inverse of each other where `noref` is much more performance on tables with unique fields, and `not noref` is more performant on tables that reuse fields.
* docs(lsp): add supports_method to vim.lsp.client docs (#26852)Mathias Fußenegger2024-01-02
|
* refactor: fix luals warningsdundargoc2023-12-30
|
* refactor: use vim.deprecate on all deprecated functionsdundargoc2023-12-27
|
* fix(lsp): filetype matching to documentSelector in dynamic capabilities (#25425)Michal Liszcz2023-12-22
| | | | | | | Use the get_language_id client option to resolve the filetype when matching the document selector in a dynamic capability. Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
* refactor(lsp): move changetracking to separate file (#26577)Lewis Russell2023-12-17
| | | | | | | | | | | | | | | * refactor(lsp): move changetracking to separate file - Prefixed changetracking types with `vim.lsp.` * fixup!: make _reset_timer a local function * fixup!: remove @private annotations * fixup!: changetracking.lua -> _changetracking.lua * fixup! types * fixup! add send_changes_for_group
* feat(lsp): more annotationsLewis Russell2023-12-14
|
* 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
|