aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r--runtime/lua/vim/lsp.lua40
1 files changed, 20 insertions, 20 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 0e72aae188..f6870cbd94 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -4,15 +4,15 @@ local lsp_rpc = require('vim.lsp.rpc')
local protocol = require('vim.lsp.protocol')
local util = require('vim.lsp.util')
local sync = require('vim.lsp.sync')
-local api = vim.api
local vim = vim
+local a = vim.api
local nvim_err_writeln, nvim_buf_get_lines, nvim_command, nvim_buf_get_option, nvim_exec_autocmds =
- vim.api.nvim_err_writeln,
- vim.api.nvim_buf_get_lines,
- vim.api.nvim_command,
- vim.api.nvim_buf_get_option,
- vim.api.nvim_exec_autocmds
+ a.nvim_err_writeln,
+ a.nvim_buf_get_lines,
+ a.nvim_command,
+ a.nvim_buf_get_option,
+ a.nvim_exec_autocmds
local uv = vim.loop
local tbl_isempty, tbl_extend = vim.tbl_isempty, vim.tbl_extend
local validate = vim.validate
@@ -79,7 +79,7 @@ end
local function resolve_bufnr(bufnr)
validate({ bufnr = { bufnr, 'n', true } })
if bufnr == nil or bufnr == 0 then
- return vim.api.nvim_get_current_buf()
+ return a.nvim_get_current_buf()
end
return bufnr
end
@@ -216,7 +216,7 @@ end
---@returns (string) the command
---@returns (list of strings) its arguments
function lsp._cmd_parts(input)
- vim.validate({
+ validate({
cmd = {
input,
function()
@@ -230,7 +230,7 @@ function lsp._cmd_parts(input)
local cmd_args = {}
-- Don't mutate our input.
for i, v in ipairs(input) do
- vim.validate({ ['cmd argument'] = { v, 's' } })
+ validate({ ['cmd argument'] = { v, 's' } })
if i > 1 then
table.insert(cmd_args, v)
end
@@ -505,7 +505,7 @@ do
end
buf_state.pending_change = nil
buf_state.last_flush = uv.hrtime()
- if client.is_stopped() or not vim.api.nvim_buf_is_valid(bufnr) then
+ if client.is_stopped() or not a.nvim_buf_is_valid(bufnr) then
return
end
local changes = state.use_incremental_sync and buf_state.pending_changes
@@ -522,7 +522,7 @@ do
if debounce == 0 then
buf_state.pending_change()
else
- local timer = vim.loop.new_timer()
+ local timer = uv.new_timer()
buf_state.timer = timer
-- Must use schedule_wrap because `full_changes()` calls nvim_buf_get_lines
timer:start(debounce, 0, vim.schedule_wrap(buf_state.pending_change))
@@ -572,7 +572,7 @@ local function text_document_did_open_handler(bufnr, client)
if not vim.tbl_get(client.server_capabilities, 'textDocumentSync', 'openClose') then
return
end
- if not vim.api.nvim_buf_is_loaded(bufnr) then
+ if not a.nvim_buf_is_loaded(bufnr) then
return
end
local filetype = nvim_buf_get_option(bufnr, 'filetype')
@@ -592,7 +592,7 @@ local function text_document_did_open_handler(bufnr, client)
vim.schedule(function()
-- Protect against a race where the buffer disappears
-- between `did_open_handler` and the scheduled function firing.
- if vim.api.nvim_buf_is_valid(bufnr) then
+ if a.nvim_buf_is_valid(bufnr) then
local namespace = vim.lsp.diagnostic.get_namespace(client.id)
vim.diagnostic.show(namespace, bufnr)
end
@@ -738,7 +738,7 @@ function lsp.start(config, opts)
return client.config.root_dir == conf.root_dir and client.name == conf.name
end
config.name = config.name or (config.cmd[1] and vim.fs.basename(config.cmd[1])) or nil
- local bufnr = api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
for _, clients in ipairs({ uninitialized_clients, lsp.get_active_clients() }) do
for _, client in pairs(clients) do
if reuse_client(client, config) then
@@ -1433,7 +1433,7 @@ function lsp.buf_attach_client(bufnr, client_id)
client_id = { client_id, 'n' },
})
bufnr = resolve_bufnr(bufnr)
- if not vim.api.nvim_buf_is_loaded(bufnr) then
+ if not a.nvim_buf_is_loaded(bufnr) then
local _ = log.warn()
and log.warn(string.format('buf_attach_client called on unloaded buffer (id: %d): ', bufnr))
return false
@@ -1451,9 +1451,9 @@ function lsp.buf_attach_client(bufnr, client_id)
au BufWritePost <buffer=%d> lua vim.lsp._text_document_did_save_handler(0)
augroup END
]=]
- vim.api.nvim_exec(string.format(buf_did_save_autocommand, client_id, bufnr, bufnr), false)
+ a.nvim_exec(string.format(buf_did_save_autocommand, client_id, bufnr, bufnr), false)
-- First time, so attach and set up stuff.
- vim.api.nvim_buf_attach(bufnr, false, {
+ a.nvim_buf_attach(bufnr, false, {
on_lines = text_document_did_change_handler,
on_reload = function()
local params = { textDocument = { uri = uri } }
@@ -1723,7 +1723,7 @@ function lsp.buf_request(bufnr, method, params, handler)
not tbl_isempty(all_buffer_active_clients[resolve_bufnr(bufnr)] or {}) and not method_supported
then
vim.notify(lsp._unsupported_method(method), vim.log.levels.ERROR)
- vim.api.nvim_command('redraw')
+ nvim_command('redraw')
return {}, function() end
end
@@ -1888,8 +1888,8 @@ function lsp.omnifunc(findstart, base)
-- Then, perform standard completion request
local _ = log.info() and log.info('base ', base)
- local pos = vim.api.nvim_win_get_cursor(0)
- local line = vim.api.nvim_get_current_line()
+ local pos = a.nvim_win_get_cursor(0)
+ local line = a.nvim_get_current_line()
local line_to_cursor = line:sub(1, pos[2])
local _ = log.trace() and log.trace('omnifunc.line', pos, line)