aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorYi Ming <ofseed@foxmail.com>2025-07-13 13:00:10 +0800
committerGitHub <noreply@github.com>2025-07-12 22:00:10 -0700
commit73fbc693b593faa62337aa3ae8142bb3f5798541 (patch)
treec7609c374791b70aeb1f6e21c134dd06c0158b75 /runtime/lua/vim/lsp/util.lua
parent89b946aa87d2414bd268f0766d5354cedc5702ff (diff)
downloadrneovim-73fbc693b593faa62337aa3ae8142bb3f5798541.tar.gz
rneovim-73fbc693b593faa62337aa3ae8142bb3f5798541.tar.bz2
rneovim-73fbc693b593faa62337aa3ae8142bb3f5798541.zip
refactor(lsp): drop vim.lsp.util._refresh() #33903
Problem: - util._refresh() is only used by `inlay_hint.lua` and `document_color.lua`, and both have their own wrapper functions; - util._refresh() provides unified parameters, but this layer of wrapping is almost meaningless because - document color does not need the range parameter; - inlay hint requires a range parameter, but it is not complicated Therefore, it can be considered redundant. ref https://github.com/neovim/neovim/pull/32887#discussion_r1996413602 Solution: Remove it.
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua58
1 files changed, 1 insertions, 57 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index ad1804db24..db221ddc68 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -2224,7 +2224,7 @@ end
---@param end_line integer
---@param position_encoding 'utf-8'|'utf-16'|'utf-32'
---@return lsp.Range
-local function make_line_range_params(bufnr, start_line, end_line, position_encoding)
+function M._make_line_range_params(bufnr, start_line, end_line, position_encoding)
local last_line = api.nvim_buf_line_count(bufnr) - 1
---@type lsp.Position
@@ -2284,62 +2284,6 @@ function M._cancel_requests(filter)
end
end
----@class (private) vim.lsp.util._refresh.Opts
----@field bufnr integer? Buffer to refresh (default: 0)
----@field only_visible? boolean Whether to only refresh for the visible regions of the buffer (default: false)
----@field client_id? integer Client ID to refresh (default: all clients)
----@field handler? lsp.Handler
-
---- Request updated LSP information for a buffer.
----
----@param method vim.lsp.protocol.Method.ClientToServer.Request LSP method to call
----@param opts? vim.lsp.util._refresh.Opts Options table
-function M._refresh(method, opts)
- opts = opts or {}
- local bufnr = vim._resolve_bufnr(opts.bufnr)
-
- local clients = vim.lsp.get_clients({ bufnr = bufnr, method = method, id = opts.client_id })
-
- if #clients == 0 then
- return
- end
-
- local textDocument = M.make_text_document_params(bufnr)
-
- if opts.only_visible then
- 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)
- M._cancel_requests({
- bufnr = bufnr,
- clients = clients,
- method = method,
- type = 'pending',
- })
- for _, client in ipairs(clients) do
- client:request(method, {
- textDocument = textDocument,
- range = make_line_range_params(bufnr, first - 1, last - 1, client.offset_encoding),
- }, opts.handler, bufnr)
- end
- end
- end
- else
- for _, client in ipairs(clients) do
- client:request(method, {
- textDocument = textDocument,
- range = make_line_range_params(
- bufnr,
- 0,
- api.nvim_buf_line_count(bufnr) - 1,
- client.offset_encoding
- ),
- }, opts.handler, bufnr)
- end
- end
-end
-
---@param feature string
---@param client_id? integer
local function make_enable_var(feature, client_id)