aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
Commit message (Collapse)AuthorAge
* 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.
* 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 }) ```
* docs(lua): adjust some type annotationsnotomo2023-01-04
|
* fix(lsp): fix get_active_clients bufnr parameter (#21366)Mathias Fußenegger2022-12-09
| | | Follow up to https://github.com/neovim/neovim/pull/21337
* refactor(lsp): remove deprecated vim.lsp.buf_get_clients calls (#21337)Raphael2022-12-08
|
* fix(lsp): render <pre>{lang} code blocks and set separator default to false ↵Folke Lemaitre2022-12-03
| | | | (#21271)
* docs: fix typos (#21196)dundargoc2022-11-29
| | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com>
* feat(lsp): support set title in lsp relate floatwindow (#21110)Raphael2022-11-21
|
* fix(lua): properly configure luacheck and remove `local vim = ...` lines ↵Folke Lemaitre2022-10-09
| | | | (#20551)
* feat(lsp): support window/showDocument (#19977)lvimuser2022-10-08
|
* docs: fix typos (#20394)dundargoc2022-09-30
| | | | | Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: smjonas <jonas.strittmatter@gmx.de> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* feat(gen_help_html.lua): adapt to new parserJustin M. Keyes2022-09-28
| | | | | - adapt to parser changes from https://github.com/vigoux/tree-sitter-vimdoc/pull/16 - numerous other generator improvements
* fix(docs): invalid :help links #20345Justin M. Keyes2022-09-25
| | | | | Fix those naughty single quotes. closes #20159
* fix(lsp): create missing directory before creating file (#19835)shaunsingh2022-09-24
| | | Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
* fix(lsp): out of bounds error in lsp.util.apply_text_edits (#20137)ofwinterpassed2022-09-20
| | | Co-authored-by: Jonas Strittmatter <40792180+smjonas@users.noreply.github.com>
* fix(lsp): set end_col in formatexpr (#19676)Mathias Fußenegger2022-08-08
| | | | The last line was excluded from formatting via formatexpr because the character in the params was set to 0 instead of the end of line.
* fix(lsp): avoid ^M character in hover window on Windows (#19640)Cai.MY2022-08-05
|
* feat(lsp): add range option to code_action; deprecate range_code_action (#19551)Mathias Fußenegger2022-07-28
| | | | | | | | | | | | | | | `code_action` gained extra functions (`filter` and `apply`) which `range_code_action` didn't have. To close this gap, this adds a `range` option to `code_action` and deprecates `range_code_action`. The option defaults to the current selection if in visual mode. This allows users to setup a mapping like `vim.keymap.set({'v', 'n'}, '<a-CR>', vim.lsp.buf.code_action)` `range_code_action` used to use the `<` and `>` markers to get the _last_ selection which required using a `<Esc><Cmd>lua vim.lsp.buf.range_code_action()<CR>` (note the `<ESC>`) mapping.
* fix: add group in autocmd api #19412Raphael2022-07-17
| | | | regression from PR #19283: custom close autocommands for the preview window were not cleaned up after the window was closed.
* refactor: use `local api = vim.api`ii142022-07-15
|
* refactor(lsp): make the use of local aliases more consistentii142022-07-15
|
* fix(lsp): pcall nvim_del_augroup_by_name (#19302)Christian Clason2022-07-10
| | | fixup for #19283
* refactor: remove functions marked for deprecation in 0.8 (#19299)Gregory Anders2022-07-09
|
* refactor(lua): replace vim.cmd use with API calls (#19283)Raphael2022-07-09
| | | Signed-off-by: Raphael <glephunter@gmail.com>
* 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): set buflisted before switching to buffer (#18854)zeertzjq2022-06-04
|
* fix(lsp): respect global syntax setting in open float preview (#15225)Elton Leander Pinto2022-05-25
|
* refactor: add warnings for deprecated functions (#18662)dundargoc2022-05-21
|
* feat(lsp): option to reuse_win for jump actions (#18577)Lewis Russell2022-05-18
|
* chore: format runtime with styluaChristian Clason2022-05-09
|
* docs: change wrap_at type to number (#18456)Noval Maulana2022-05-07
|
* fix(lsp): add missing bufnr argument (#18382)Jose Alvarez2022-05-03
|
* feat(lsp): add vim.lsp.buf.format (#18193)Michael Lingelbach2022-04-30
|
* fix(lsp): unify progress message handling (#18040)runiq2022-04-20
| | | | | | | | | | | The LSP progress handler would put non-progress messages (such as from clangd or pyls; not part of the LSP spec) directly into `client.messages`, while `vim.lsp.util.get_progress_messages()` would try to fetch them from `client.messages.messages` instead (and come up empty everytime). This would result in these messages never being cleaned up by `get_progress_messages()`. This commit fixes that by treating those messages like show-once progress messages (by setting `done=true` immediately).
* fix(lsp): fix lookup of boolean values in workspace/configuration (#18026)Fredrik Ekre2022-04-15
|
* docs(lsp): remove outdated offset_encoding default value for apply_text_editsAndrea Cappuccio2022-03-30
|
* fix(lsp): use "text" filetype for plaintext (#17898)Jaehwang Jung2022-03-28
|
* fix(lsp): set tabSize from 'shiftwidth', not 'softtabstop' (#17787)Tim Pope2022-03-20
| | | | | | | | | The use of 'softtabstop' to set tabSize was introduced in 5d5b068, replacing 'tabstop'. If we look past the name tabSize and at the actual purpose of the field, it's the indentation width used when formatting. This corresponds to the Vim option 'shiftwidth', not 'softtabstop'. The latter has the comparatively mundane purpose of controlling what happens when you hit the tab key (and even this is incomplete, as it fails to account for 'smarttab').
* fix(lsp): respect all of 'fixeol', 'eol', and 'binary' applying edits (#17574)Tim Pope2022-03-02
|
* refactor(highlight)!: optional arguments for highlight.range as table (#17462)Christian Clason2022-02-21
| | | | | | | | | also update documentation BREAKING CHANGE: signature of highlight.range is now vim.highlight.range(bufnr, ns, hlgroup, start, finish, { regtype = regtype, inclusive = inclusive, priority = priority }) Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
* fix: lsp and diagnostic highlight priority (#17461)Michael Lingelbach2022-02-19
| | | | | | | | | Closes https://github.com/neovim/neovim/issues/17456 * treesitter uses the default highlight priority of 50 * diagnostic highlights have a priority of 150 * lsp reference highlights have a priority of 200 This ensures proper ordering.
* feat: use nvim_buf_set_extmark for vim.highlight (#16963)Michael Lingelbach2022-01-15
| | | | | | | | | Closes https://github.com/neovim/neovim/issues/13647 This allows customizing the priority of the highlights. * Add default priority of 50 * Use priority of 200 for highlight on yank * use priority of 40 for highlight references (LSP)
* fix(lsp): always split text edits on \r, \r\n, and \n (#17087)Michael Lingelbach2022-01-14
| | | | | | | | | | Closes: https://github.com/neovim/neovim/issues/17053 Servers can return a mix of line endings per the language server protocol. See: https://microsoft.github.io/language-server-protocol/specification.html#textDocuments All should be equally treated as line endings.
* fix(lsp): forward offset_encoding in rename handler (#17079)Michael Lingelbach2022-01-13
|
* fix(lsp): forward offset_encoding to apply_text_edits (#17075)Michael Lingelbach2022-01-13
|
* fix(lsp): strictly enforce passing offset encoding (#17049)Michael Lingelbach2022-01-13
| | | | | | | | | | This removes the "fallback" to utf-16 in many of our helper functions. We should always explicitly pass these around when possible except in two locations: * generating params with help utilities called by buf.lua functions * the buf.lua functions themselves Anything that is called by the handler should be passed the offset encoding.
* fix(lsp): handle negative activeSignature in signatureHelp (#17064)Mathias Fußenegger2022-01-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | omnisharp-roslyn can send negative values: { activeParameter = 0, activeSignature = -1, signatures = { { documentation = "", label = "TestEntity.TestEntity()", parameters = {} } } } In 3.16 of the specification `activeSignature` is defined as `uinteger` and therefore negative values shouldn't be allowed, but within 3.15 it was defined as `number` which makes me think we can be a bit lenient in this case and handle them. The expected behavior is quite clear: The active signature. If omitted or the value lies outside the range of `signatures` the value defaults to zero or is ignored if the `SignatureHelp` has no signatures. Fixes an error: util.lua:1685: attempt to get length of local 'lines' (a nil value) util.lua:1685: in function 'trim_empty_lines' handlers.lua:334: in function 'textDocument/signatureHelp'
* fix(lsp): fix applying multiple out-of-range TextEdits (#17037)hrsh7th2022-01-13
|
* fix(lsp): resolve bufnr for get_lines (#16986)Michael Lingelbach2022-01-08
| | | | | | | Closes https://github.com/neovim/neovim/issues/16985 * get_lines checks if buf_loaded using bufnr 0, which is typically used as a sentinel value, but here must be resolved to the true bufnr
* feat(lua): add notify_once() (#16956)Gregory Anders2022-01-06
| | | Like vim.notify(), but only displays the notification once.