aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2021-11-29 20:31:19 -0700
committerDundar Göc <gocdundar@gmail.com>2021-11-30 09:03:41 +0100
commitb6e531c1d90da143d4351442baee8fef0479a6f7 (patch)
tree22560e5c2bdf16240104901cbcdaccc939a53391 /runtime/lua
parentbc1d13bb368298988e87983307e6d92f20441f56 (diff)
downloadrneovim-b6e531c1d90da143d4351442baee8fef0479a6f7.tar.gz
rneovim-b6e531c1d90da143d4351442baee8fef0479a6f7.tar.bz2
rneovim-b6e531c1d90da143d4351442baee8fef0479a6f7.zip
docs(lsp): add annotations for private functions
Diffstat (limited to 'runtime/lua')
-rw-r--r--runtime/lua/vim/lsp.lua24
-rw-r--r--runtime/lua/vim/lsp/buf.lua1
-rw-r--r--runtime/lua/vim/lsp/log.lua1
-rw-r--r--runtime/lua/vim/lsp/sync.lua1
-rw-r--r--runtime/lua/vim/lsp/util.lua6
-rw-r--r--runtime/lua/vim/shared.lua1
6 files changed, 25 insertions, 9 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index f59b8824ab..61a700bd15 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -137,12 +137,6 @@ local all_buffer_active_clients = {}
local uninitialized_clients = {}
---@private
---- Invokes a function for each LSP client attached to the buffer {bufnr}.
----
----@param bufnr (Number) of buffer
----@param fn (function({client}, {client_id}, {bufnr}) Function to run on
----each client attached to that buffer.
----@param restrict_client_ids table list of client ids on which to restrict function application.
local function for_each_buffer_client(bufnr, fn, restrict_client_ids)
validate {
fn = { fn, 'f' };
@@ -327,6 +321,7 @@ do
--- timer?: uv_timer
local state_by_client = {}
+ ---@private
function changetracking.init(client, bufnr)
local state = state_by_client[client.id]
if not state then
@@ -348,6 +343,7 @@ do
state.buffers[bufnr] = nvim_buf_get_lines(bufnr, 0, -1, true)
end
+ ---@private
function changetracking.reset_buf(client, bufnr)
changetracking.flush(client)
local state = state_by_client[client.id]
@@ -356,6 +352,7 @@ do
end
end
+ ---@private
function changetracking.reset(client_id)
local state = state_by_client[client_id]
if state then
@@ -364,6 +361,7 @@ do
end
end
+ ---@private
function changetracking.prepare(bufnr, firstline, lastline, new_lastline)
local incremental_changes = function(client)
local cached_buffers = state_by_client[client.id].buffers
@@ -447,6 +445,7 @@ do
end
--- Flushes any outstanding change notification.
+ ---@private
function changetracking.flush(client)
local state = state_by_client[client.id]
if state then
@@ -1297,6 +1296,7 @@ function lsp._vim_exit_handler()
local poll_time = 50
+ ---@private
local function check_clients_closed()
for client_id, timeout in pairs(timeouts) do
timeouts[client_id] = timeout - poll_time
@@ -1683,7 +1683,17 @@ function lsp.get_log_path()
return log.get_filename()
end
---- Call {fn} for every client attached to {bufnr}
+--- Invokes a function for each LSP client attached to a buffer.
+---
+---@param bufnr number Buffer number
+---@param fn function Function to run on each client attached to buffer
+--- {bufnr}. The function takes the client, client ID, and
+--- buffer number as arguments. Example:
+--- <pre>
+--- vim.lsp.for_each_buffer_client(0, function(client, client_id, bufnr)
+--- print(vim.inspect(client))
+--- end)
+--- </pre>
function lsp.for_each_buffer_client(bufnr, fn)
return for_each_buffer_client(bufnr, fn)
end
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index be9bd9d223..d42f5b6cf8 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -263,6 +263,7 @@ function M.rename(new_name)
request('textDocument/rename', params)
end
+ ---@private
local function prepare_rename(err, result)
if err == nil and result == nil then
vim.notify('nothing to rename', vim.log.levels.INFO)
diff --git a/runtime/lua/vim/lsp/log.lua b/runtime/lua/vim/lsp/log.lua
index 4597f1919a..dbc473b52c 100644
--- a/runtime/lua/vim/lsp/log.lua
+++ b/runtime/lua/vim/lsp/log.lua
@@ -101,6 +101,7 @@ function log.set_level(level)
end
--- Gets the current log level.
+---@return string current log level
function log.get_level()
return current_log_level
end
diff --git a/runtime/lua/vim/lsp/sync.lua b/runtime/lua/vim/lsp/sync.lua
index f29c0a3f38..5df2a4d144 100644
--- a/runtime/lua/vim/lsp/sync.lua
+++ b/runtime/lua/vim/lsp/sync.lua
@@ -74,6 +74,7 @@ local function byte_to_utf(line, byte, offset_encoding)
return utf_idx + 1
end
+---@private
local function compute_line_length(line, offset_encoding)
local length
local _
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 2879c4a565..e9155a7231 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -158,6 +158,7 @@ end
local function get_lines(bufnr, rows)
rows = type(rows) == "table" and rows or { rows }
+ ---@private
local function buf_lines()
local lines = {}
for _, row in pairs(rows) do
@@ -262,6 +263,7 @@ local function get_line_byte_from_position(bufnr, position, offset_encoding)
end
--- Process and return progress reports from lsp server
+---@private
function M.get_progress_messages()
local new_messages = {}
@@ -657,7 +659,7 @@ function M.rename(old_fname, new_fname, opts)
api.nvim_buf_delete(oldbuf, { force = true })
end
-
+---@private
local function create_file(change)
local opts = change.options or {}
-- from spec: Overwrite wins over `ignoreIfExists`
@@ -669,7 +671,7 @@ local function create_file(change)
vim.fn.bufadd(fname)
end
-
+---@private
local function delete_file(change)
local opts = change.options or {}
local fname = vim.uri_to_fname(change.uri)
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index bf77f0c776..1cf618725d 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -559,6 +559,7 @@ do
return type(val) == t or (t == 'callable' and vim.is_callable(val))
end
+ ---@private
local function is_valid(opt)
if type(opt) ~= 'table' then
return false, string.format('opt: expected table, got %s', type(opt))