aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
Commit message (Collapse)AuthorAge
...
* fix(lsp): handle out-of-bounds character positions #30288Tristan Knight2024-09-08
| | | | | | | | | | | Problem: str_byteindex_enc could return an error if the index was longer than the lline length. This was handled in each of the calls to it individually Solution: * Fix the call at the source level so that if the index is higher than the line length, line length is returned as per LSP specification * Remove pcalls on str_byteindex_enc calls. No longer needed now that str_byteindex_enc has a bounds check.
* fix(lsp): handle locations exceeding line length #30253Tristan Knight2024-09-05
| | | | | | | | | | | Problem: LSP spec [states](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position) that "if the character value is greater than the line length it defaults back to the line length", but `locations_to_items` fails in that case. Solution: Adjust locations_to_items to follow the spec. closes #28281
* test(lsp): refactor and tidyLewis Russell2024-08-11
| | | | | | | - Merge all the top level 'LSP' describe blocks - Refactor text edit tests - Fix typing errors - Add linebreaks between tests
* fix(lsp): revert text edit application order change (#29877)Mathias Fußenegger2024-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reverts https://github.com/neovim/neovim/pull/29212 and adds a few additional test cases From the spec > All text edits ranges refer to positions in the document they are > computed on. They therefore move a document from state S1 to S2 without > describing any intermediate state. Text edits ranges must never overlap, > that means no part of the original document must be manipulated by more > than one edit. However, it is possible that multiple edits have the same > start position: multiple inserts, or any number of inserts followed by a > single remove or replace edit. If multiple inserts have the same > position, the order in the array defines the order in which the inserted > strings appear in the resulting text. The previous fix seems wrong. The important part: > If multiple inserts have the same position, the order in the array > defines the order in which the inserted strings appear in the > resulting text. Emphasis on _appear in the resulting text_ Which means that in: local edits1 = { make_edit(0, 3, 0, 3, { 'World' }), make_edit(0, 3, 0, 3, { 'Hello' }), } `World` must appear before `Hello` in the final text. That means the old logic was correct, and the fix was wrong.
* refactor: use `vim._with` where possibledundargoc2024-06-28
| | | | | This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`.
* refactor(lsp): use metatable for buf_versions (#29304)Ilia Choly2024-06-14
| | | | | | This reduces the number of nil checks around buf_versions usage Test changes were lifted from 5c33815 Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
* refactor(lua): improve type annotationsLewis Russell2024-06-11
|
* feat(lsp): include end_col, end_lnum in vim.lsp.buf.locations_to_items #29164Tom Praschan2024-06-09
|
* fix(lsp): fix reverse sorting of same position text edits (#29212)Al Colmenar2024-06-07
| | | | | | | | Problem: Text edits with the same position (both line and character) were being reverse sorted prior to being applied which differs from the lsp spec Solution: Change the sort order for just the same position edits
* fix(lsp): revert buf_versions deprecation/replacement (#29217)Mathias Fußenegger2024-06-07
| | | | | | | | | * Revert "fix(lsp): account for changedtick version gap on modified reset (#29170)" This reverts commit 2e6d295f799c27372e5c0c44727fa613c81717fd. * Revert "refactor(lsp): replace util.buf_versions with changedtick (#28943)" This reverts commit 5c33815448e11b514678f39cecc74e68131d4628.
* fix(lsp): account for changedtick version gap on modified reset (#29170)Mathias Fußenegger2024-06-04
| | | | Follow up to https://github.com/neovim/neovim/pull/28943 Fixes https://github.com/neovim/neovim/issues/29163
* refactor(lsp): use predefined types in util function signatures (#29095)Ilia Choly2024-05-31
|
* refactor(lsp): replace util.buf_versions with changedtick (#28943)Mathias Fußenegger2024-05-30
| | | | | | | `lsp.util.buf_versions` was already derived from changedtick (`on_lines` from `buf_attach` synced the version) As far as I can tell there is no need to keep track of the state in a separate table.
* refactor: fix luals type warningsdundargoc2024-05-27
|
* feat: remove deprecated featuresdundargoc2024-05-16
| | | | | | | | | | | | | | | | | | | Remove following functions: - vim.lsp.util.extract_completion_items - vim.lsp.util.get_progress_messages - vim.lsp.util.parse_snippet() - vim.lsp.util.text_document_completion_list_to_complete_items - LanguageTree:for_each_child - health#report_error - health#report_info - health#report_ok - health#report_start - health#report_warn - vim.health.report_error - vim.health.report_info - vim.health.report_ok - vim.health.report_start - vim.health.report_warn
* docs: small fixes (#27364)dundargoc2024-03-12
| | | | | | | | Co-authored-by: C.D. MacEachern <craig.daniel.maceachern@gmail.com> Co-authored-by: Ynda Jas <yndajas@gmail.com> Co-authored-by: Owen Hines <TheOdd@users.noreply.github.com> Co-authored-by: Wanten <41904684+WantenMN@users.noreply.github.com> Co-authored-by: lukasvrenner <118417051+lukasvrenner@users.noreply.github.com> Co-authored-by: cuinix <915115094@qq.com>
* fix(lsp): directly rename the existing buffers when renaming (#27690)Jaehwang Jung2024-03-02
| | | | | | | | | | | | | | | | Problem: `vim.lsp.util.rename()` deletes the buffers that are affected by renaming. This has undesireable side effects. For example, when renaming a directory, all buffers under that directory are deleted and windows displaying those buffers are closed. Also, buffer options may change after renaming. Solution: Rename the buffers with :saveas. An alternative approach is to record all the relevant states and restore it after renaming, but that seems to be more complex. In fact, the older version was attempting to restore the states but only partially and incorrectly.
* docs: improve/add documentation of Lua typesLewis Russell2024-03-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to.
* fix(lsp): rename undofile when renaming (#27684)Jaehwang Jung2024-03-01
| | | | | | | Problem: After `rename()`, the undo information for the renamed file(s) are lost. Solution: Rename the undofile as well.
* fix(lsp): remove unnecessary file load/write when renaming (#27621)Jaehwang Jung2024-02-28
| | | | | | | | | Previously rename would unconditionally read the to-be-renamed file from the disk and write it to the disk. This is redundant in some cases If the file is not already loaded, it's not attached to lsp client, so nvim doesn't need to care about this file. If the file is loaded but has no change, it doesn't need to be written.
* feat(lsp): support completion itemDefaultsMaria José Solano2024-02-27
|
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
* fix(lsp): add assertion for explicit bufnr in apply_text_edits (#27614)Gregory Anders2024-02-24
| | | | | Assert that the buffer number passed to apply_text_edits is fully resolved (not 0 or null). Pass the known buffer number to apply_text_edits from lsp.formatexpr().
* fix(lsp): when renaming directory, check path prefix of buffer names (#27603)Jaehwang Jung2024-02-24
| | | | | For example, when renaming /path/to/dir, buffers like fern://drawer/file:///path/to/dir, /path/to/dir123 should not be matched.
* refactor(lsp): remove redundant code (#27601)Jaehwang Jung2024-02-24
| | | | * use builtin function * buffer:// was removed in 236c20795eb9f11e21e0719b735ea741711acc08.
* fix(lsp): rename: load and list new buffer if attached to window (#27408)Tomasz N2024-02-14
|
* fix(lsp): rename fails on missing parent directory #27291Tomasz N2024-02-08
| | | | | | | | Problem: If a rename results in a path that has missing parent directory(s), it will fail. Solution: Do a recursive mkdir before attempting the rename.
* 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.
* refactor(lsp): deprecate `vim.lsp.util.lookup_section`Jongwook Choi2024-01-16
| | | | | | | | This function is used only in the `workspace/configuration` handler, and does not warrant a public API because of its confusing return types. The only caller `vim.lsp.handlers["workspace.configuration"]` is also refactored to use `vim.tbl_get()` instead.
* docs: add lua typing for `vim.NIL`Jongwook Choi2024-01-15
|
* fix(doc): improve doc generation of types using lpegLewis Russell2024-01-11
| | | | Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
* fix(docs): clean up non-docstring comments for vimdoc genJongwook Choi2024-01-02
| | | | | These non-docstring comments can be included into doxygen's brief description and then appear in the succeeding function documentation.
* revert: "fix: correct versions in deprecation warnings"dundargoc2023-12-27
| | | | | | | | | | | | | | This reverts commit 5cb906e91cb56302d0737aa80e2d890dde452029. They were intentionally fast-tracked. - `parse_snippet()` because of limited scope, and given that it's kinda semi-broken (arbitrary formatting rules, not that useful for what it was used for) - `extract_completion_items()` doesn't work if we want to add the LSP completionlist capability - `text_document_completion_list_to_complete_items()` also doesn't work for completionlist
* fix: correct versions in deprecation warningsdundargoc2023-12-27
| | | | | | | | | The following functions should be removed in 0.12 according to the deprecation strategy in MAINTAIN.md: - vim.lsp.util.extract_completion_items() - vim.lsp.util.parse_snippet() - vim.lsp.util.text_document_completion_list_to_complete_items()
* refactor: use vim.deprecate on all deprecated functionsdundargoc2023-12-27
|
* feat(lsp): add type annotations for lsp.util.locations_to_items (#26694)Mathias Fußenegger2023-12-22
| | | | Problem: luals reported many warnings Solution: Add type annotations
* feat(lsp): more annotationsLewis Russell2023-12-14
|
* refactor(lsp): deprecate completion util methodsMathias Fussenegger2023-10-21
| | | | Relates to https://github.com/neovim/neovim/issues/25272
* 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
* feat(lsp): add snippet API (#25301)Maria José Solano2023-10-21
|
* docs: do not hardcode LSP version in URL #25648Maria José Solano2023-10-16
|
* fix(lsp): handle NUL bytes in popup text (#25612)zeertzjq2023-10-12
| | | Fix #25610
* fix(lsp): account for border height in max floating popup height (#25539)LW2023-10-08
|
* feat(lsp)!: replace snippet parser by lpeg grammarMaria José Solano2023-10-02
|
* refactor(lsp): deprecate util methods (#25400)Maria José Solano2023-09-29
|
* fix(lsp): handle absence of a trailing newline #25194Sergey Slipchenko2023-09-21
| | | | | | | | | | | | Fixes #24339 rust-analyzer sends "Invalid offset" error in such cases. Some other servers handle it specially. LSP spec mentions that "A range is comparable to a selection in an editor". Most editors don't handle trailing newlines the same way Neovim/Vim does, it's clearly visible if it's present or not. With that in mind it's understandable why sending end position as simply the start of the line after the last one is considered invalid in such cases.
* fix(lsp)!: deprecate trim_empty_linesMaria José Solano2023-09-19
|
* feat(lsp): use treesitter for stylize markdownMaria José Solano2023-09-19
|
* fix(api): more intuitive cursor updates in nvim_buf_set_textSergey Slipchenko2023-09-11
| | | | Fixes #22526
* feat(lsp): improve control over placement of floating windows (#24494)Grace Petryk2023-09-10
|