aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp
Commit message (Collapse)AuthorAge
...
* perf(lsp): load buffer contents once when processing semantic tokens ↵jdrouhard2023-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | responses (#23484) perf(lsp): load buffer contents once when processing semantic token responses Using _get_line_byte_from_position() for each token's boundaries was a pretty huge bottleneck, since that function would load individual buffer lines via nvim_buf_get_lines() (plus a lot of extra overhead). So each token caused two calls to nvim_buf_get_lines() (once for the start position, and once for the end position). For semantic tokens, we only attach to buffers that have already been loaded, so we can safely just get all the lines for the entire buffer at once, and lift the rest of the _get_line_byte_from_position() implementation directly while bypassing the part that loads the buffer line. While I was looking at get_lines (used by _get_line_byte_from_position), I noticed that we were checking for non-file URIs before we even looked to see if we already had the buffer loaded. Moving the buffer-loaded check to be the first thing done in get_lines() more than halved the average time spent transforming the token list into highlight ranges vs when it was still using _get_line_byte_from_position. I ended up improving that loop more by not using get_lines, but figured the performance improvement it provided was worth leaving in.
* perf(lsp): process semantic tokens response in a coroutine that yields every ↵jdrouhard2023-05-01
| | | | 5ms (#23375)
* feat(lsp): enable workspace/didChangeWatchedFiles by default (#23190)Jon Huhn2023-04-22
|
* refactor: deprecate checkhealth functionsdundargoc2023-04-15
| | | | | | | | | | | | | | | | | | | | | | | The following functions are deprecated and will be removed in Nvim v0.11: - health#report_start() - health#report_info() - health#report_ok() - health#report_warn() - health#report_error() - vim.health.report_start() - vim.health.report_info() - vim.health.report_ok() - vim.health.report_warn() - vim.health.report_error() Users should instead use these: - vim.health.start() - vim.health.info() - vim.health.ok() - vim.health.warn() - vim.health.error()
* 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.
* fix(diagnostic): use correct field name for tags (#22835)Akin2023-03-31
| | | | LSP tags are added to the diagnostic as "tags" but referred to as "_tags" in the diagnostic underline handler
* feat(diagnostic): add support for tagsLewis Russell2023-03-30
| | | | | | The LSP spec supports two tags that can be added to diagnostics: unnecessary and deprecated. Extend vim.diagnostic to be able to handle these.
* feat(lsp): render markdown in docs hover #22766Roberto Pommella Alegro2023-03-25
| | | | | | | | | | | Problem: LSP docs hover (textDocument/hover) doesn't handle HTML escape seqs in markdown. Solution: Convert common HTML escape seqs to a nicer form, to display in the float. closees #22757 Signed-off-by: Kasama <robertoaall@gmail.com>
* fix(lsp): add missing silent check in lsp hover handler (#22763)Micah Halter2023-03-25
| | | Fixup to #21531.
* fix(lsp): Jump to tag locations reliably when :ltag is used (#22750)meredith2023-03-23
|
* fix(lsp): kill buffers after renaming a directory #22618Ivan2023-03-14
| | | | | | | | | | | | | | | Problem: When LSP client renames a directory, opened buffers in the edfitor are not renamed or closed. Then `:wall` shows errors. https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/util.lua#L776 works correctly if you try to rename a single file, but doesn't delete old buffers with `old_fname` is a dir. Solution: Update the logic in runtime/lua/vim/lsp/util.lua:rename() Fixes #22617
* fix(lsp): vim.lsp.util.apply_text_edits cursor validation #22636hrsh7th2023-03-14
| | | | | | | | Problem Using wrong variable when checking the cursor position is valid or not in vim.lsp.util.apply_text_edits. Solution Use the correct variable.
* fix(lsp): remove_workspace_folders fails if client has no workspace_folders ↵Dan Strokirk2023-03-13
| | | | | | #22633 When a client has no workspace_folders, (e.g., copilot), `pairs` code would crash.
* fix(lsp): use line start/end for visual line selection (#22632)Mathias Fußenegger2023-03-12
| | | Fixes https://github.com/neovim/neovim/issues/22629
* refactor(lsp): remove _resolve_capabilities_compat (#22628)Raphael2023-03-11
|
* revert: "fix(lsp): use buffer scheme for files not stored on disk" (#22604)Mathias Fußenegger2023-03-11
| | | | | | | | | | | Although using `buffer://` for unsaved file buffers fixes issues with language servers like eclipse.jdt.ls or ansible-language-server, it breaks completion and signature help for clangd. A regression is worse than a fix for something else, so this reverts commit 896d672736b32a8f4a4fa51844b44f266dcdcc6c. The spec change is also still in dicussion, see https://github.com/microsoft/language-server-protocol/pull/1679#discussion_r1130704886
* perf(lsp): better binary search mid calculation in semantic token (#22607)Null Chilly2023-03-10
| | | This commit replaces the usage of math.floor((lo + hi) / 2) with the faster and equivalent bit.rshift(lo + hi, 1) for calculating the midpoint in binary search.
* fix(lsp): change LspTokenUpdate to use buffer instead of pattern (#22559)jdrouhard2023-03-07
|
* docs(lsp): change type annotations from number → integer (#22510)Jaehwang Jung2023-03-07
|
* feat(lsp)!: add rule-based sem token highlighting (#22022)swarn2023-03-06
| | | | | | | | | | | | | feat(lsp)!: change semantic token highlighting Change the default highlights used, and add more highlights per token. Add an LspTokenUpdate event and a highlight_token function. :Inspect now shows any highlights applied by token highlighting rules, default or user-defined. BREAKING CHANGE: change the default highlight groups used by semantic token highlighting.
* fix(lsp): don't monitor files if workspace_folders is nil (#22531)Mathias Fußenegger2023-03-05
| | | | | | | | Fixes: Error SERVER_REQUEST_HANDLER_ERROR: "...di/dev/neovim/neovim/runtime/lua/vim/lsp/_watchfiles.lua :200: bad argument #1 to 'ipairs' (table expected, got nil)" Language servers can be started without root_dir or workspace_folders.
* feat(lsp): implement workspace/didChangeWatchedFiles (#22405)Jon Huhn2023-03-05
|
* fix(lsp): use buffer scheme for files not stored on disk (#22407)Mathias Fußenegger2023-03-01
| | | | | | Sending `didOpen` with a `file` scheme causes problems with some language servers because they expect the file to exist on disk. See https://github.com/microsoft/language-server-protocol/pull/1679
* perf(lsp): only redraw the windows containing LSP tokensbfredl2023-02-28
| | | | | | | | redraw! redraws the entire screen instead of just the windows with the buffer which were actually changed. I considered trying to calculating the range for the delta but it looks tricky. Could a follow-up.
* fix(lsp): fix some type annotations (#22397)Mathias Fußenegger2023-02-25
|
* 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
|
* refactor(lsp): remove workaround for missing bit module (#22373)Mathias Fußenegger2023-02-23
|
* fix(lsp): check if the buffer is a directory before w! it (#22289)Eduard Baturin2023-02-18
|
* fix(lsp): check method is supported when range formatting (#21970)Sean Dewar2023-01-24
| | | | | | `vim.lsp.buf.format()` silently did nothing if no servers supported `textDocument/rangeFormatting` when formatting with a range. Issue found by `@hwrd:matrix.org` in the Matrix chat.
* 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(lsp): add triggerKind option for vim.lsp.buf.code_action (#21905)kishii2023-01-21
|
* fix(lsp): fix `removed` param value in add_workspace_folder (#21915)Raphael2023-01-20
|
* docs(lsp): fix type annotation on convert_input_to_markdown_lines (#21772)Chris Kipp2023-01-12
| | | | | This small changes just ensures that if you're using `convert_input_to_markdown_lines` without `contents` you don't get a warning (when using something like neodev) that there is an expected second param, since it can be nil.
* fix(lsp): revert semantic token gravity change from #21574 (#21763)jdrouhard2023-01-12
|
* docs(lsp): update buf_notify and rpc.notify params types (#21753)Chris Kipp2023-01-11
| | | | | | | | Small, but I was getting warnings about my usage of `vim.lsp.buf_notify(bufnr, method, {example = example})` since the docs say that `params` must be a string, however this can really be anything when it's passed to `rpc.notify` since we just end up calling `vim.json.encode(payload)` on it. This fixes the docs in those two places and regenerates them.
* 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 }) ```
* feat(lsp): show active clients in :checkhealth vim.lsp (#21670)Mathias Fußenegger2023-01-08
| | | | | For users using vim.lsp.start it can be useful to get an overview of active client that is less verbose than a full `:lua =vim.lsp.get_active_clients()`
* fix(lsp): partially revert semantic token gravity change from #21574 (#21680)jdrouhard2023-01-08
|
* fix(lsp): correct callHierarchy capability to fix lsp.buf.incoming_calls() ↵2023-01-06
| | | | | (#21665) Co-authored-by: maozhongzhou <maozhongzhou@wps.cn>
* docs(lua): adjust some type annotationsnotomo2023-01-04
|
* feat(lsp): add function to clear codelens (#21504)Mathias Fußenegger2022-12-31
| | | | | | | | Currently once you retrieve the lenses you're pretty much stuck with them as saving new lenses is additive. Adding a dedicated method to reset lenses allows users to toggle lenses on/off which can be useful for language servers where they are noisy or expensive and you only want to see them temporary.
* fix(lsp): adjust gravity of semantic tokens extmarks (#21574)jdrouhard2022-12-30
| | | | | Fixes #21543 This should provide a better user experience when appending or prepending text to a word that has a semantic token extmark. More often than not, the appended/prepended text to the word will end up becoming part of the token anyway, so just use that extmark as the user types.
* fix(lsp): token_edit.data might be null on deletion (#21462)tiagovla2022-12-19
|
* feat: `vim.inspect_pos`, `vim.show_pos`, `:Inspect`Folke Lemaitre2022-12-17
|
* feat(lsp): add function to get semantic tokens at cursorChristian Clason2022-12-13
|
* feat(lsp): highlight semantic token modifiers (#21390)Christian Clason2022-12-12
| | | | | | | | Apply semantic token modifiers as separate extmarks with corresponding highlight groups (e.g., `@readonly`). This is a low-effort PR to enable the most common use cases (applying, e.g., italics or backgrounds on top of type highlights; language-specific fallbacks like `@global.lua` are also available). This can be replaced by more complicated selector-style themes later on.
* perf(lsp): update semantic tokens algorithm for parsing modifiers (#21383)jdrouhard2022-12-12
| | | | | | | | Instead of testing for every possible modifier type, only test bits up to the highest set in the token array. Saves many bit ops and comparisons when there are no modifiers or when the highest set bit is a lower bit than the highest possible in the legend on average. Can be further simplified when non-luaJIT gets the full bit module (see #21222)
* docs #20986Justin M. Keyes2022-12-11
| | | | | | - https://github.com/neovim/tree-sitter-vimdoc v1.2.4 eliminates most errors in pi_netrw.txt, so we can remove that workaround from ignore_parse_error(). - improved codeblock