diff options
author | Chris AtLee <chris@atlee.ca> | 2023-07-20 03:03:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-20 09:03:48 +0200 |
commit | 63b3408551561127f7845470eb51404bcd6f547b (patch) | |
tree | 8dd17a411e61db4592662b2d014e5c5a5e4ff655 /runtime/lua/vim/lsp/util.lua | |
parent | 86ce3878d662c1dbfec61a5ad8e7c16c4283ed5c (diff) | |
download | rneovim-63b3408551561127f7845470eb51404bcd6f547b.tar.gz rneovim-63b3408551561127f7845470eb51404bcd6f547b.tar.bz2 rneovim-63b3408551561127f7845470eb51404bcd6f547b.zip |
feat(lsp): implement textDocument/diagnostic (#24128)
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 9a6114c35b..0b06d2bbb5 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -2183,6 +2183,46 @@ function M.lookup_section(settings, section) return settings end +---@private +--- Request updated LSP information for a buffer. +--- +---@param method string LSP method to call +---@param opts (nil|table) Optional arguments +--- - bufnr (integer, default: 0): Buffer to refresh +--- - only_visible (boolean, default: false): Whether to only refresh for the visible regions of the buffer +function M._refresh(method, opts) + opts = opts or {} + local bufnr = opts.bufnr + if bufnr == nil or bufnr == 0 then + bufnr = api.nvim_get_current_buf() + end + local only_visible = opts.only_visible or false + for _, window in ipairs(api.nvim_list_wins()) do + if api.nvim_win_get_buf(window) == bufnr then + local first = vim.fn.line('w0', window) + local last = vim.fn.line('w$', window) + local params = { + textDocument = M.make_text_document_params(bufnr), + range = { + start = { line = first - 1, character = 0 }, + ['end'] = { line = last, character = 0 }, + }, + } + vim.lsp.buf_request(bufnr, method, params) + end + end + if not only_visible then + local params = { + textDocument = M.make_text_document_params(bufnr), + range = { + start = { line = 0, character = 0 }, + ['end'] = { line = api.nvim_buf_line_count(bufnr), character = 0 }, + }, + } + vim.lsp.buf_request(bufnr, method, params) + end +end + M._get_line_byte_from_position = get_line_byte_from_position ---@nodoc |