aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/buf.lua
diff options
context:
space:
mode:
authorii14 <ii14@users.noreply.github.com>2022-07-10 01:57:35 +0200
committerii14 <ii14@users.noreply.github.com>2022-07-15 17:39:26 +0200
commit8a5c7e91f21b9f49c5443105e694056a65bf761e (patch)
tree47a0fd195dfd2ff6b3eeba1ef45d1f7208f6c91f /runtime/lua/vim/lsp/buf.lua
parent9370e1c5111ee90f64260398b0623da4759f8f16 (diff)
downloadrneovim-8a5c7e91f21b9f49c5443105e694056a65bf761e.tar.gz
rneovim-8a5c7e91f21b9f49c5443105e694056a65bf761e.tar.bz2
rneovim-8a5c7e91f21b9f49c5443105e694056a65bf761e.zip
refactor(lsp): make the use of local aliases more consistent
Diffstat (limited to 'runtime/lua/vim/lsp/buf.lua')
-rw-r--r--runtime/lua/vim/lsp/buf.lua36
1 files changed, 18 insertions, 18 deletions
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 981aebada1..50e77cb7ca 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -1,6 +1,6 @@
local vim = vim
+local a = vim.api
local validate = vim.validate
-local vfn = vim.fn
local util = require('vim.lsp.util')
local M = {}
@@ -201,7 +201,7 @@ end
function M.format(options)
options = options or {}
- local bufnr = options.bufnr or vim.api.nvim_get_current_buf()
+ local bufnr = options.bufnr or a.nvim_get_current_buf()
local clients = vim.lsp.get_active_clients({
id = options.id,
bufnr = bufnr,
@@ -262,7 +262,7 @@ function M.formatting(options)
vim.log.levels.WARN
)
local params = util.make_formatting_params(options)
- local bufnr = vim.api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
select_client('textDocument/formatting', function(client)
if client == nil then
return
@@ -290,7 +290,7 @@ function M.formatting_sync(options, timeout_ms)
vim.log.levels.WARN
)
local params = util.make_formatting_params(options)
- local bufnr = vim.api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
select_client('textDocument/formatting', function(client)
if client == nil then
return
@@ -327,7 +327,7 @@ function M.formatting_seq_sync(options, timeout_ms, order)
vim.log.levels.WARN
)
local clients = vim.tbl_values(vim.lsp.buf_get_clients())
- local bufnr = vim.api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
-- sort the clients according to `order`
for _, client_name in pairs(order or {}) do
@@ -348,7 +348,7 @@ function M.formatting_seq_sync(options, timeout_ms, order)
'textDocument/formatting',
params,
timeout_ms,
- vim.api.nvim_get_current_buf()
+ a.nvim_get_current_buf()
)
if result and result.result then
util.apply_text_edits(result.result, bufnr, client.offset_encoding)
@@ -394,7 +394,7 @@ end
--- this field.
function M.rename(new_name, options)
options = options or {}
- local bufnr = options.bufnr or vim.api.nvim_get_current_buf()
+ local bufnr = options.bufnr or a.nvim_get_current_buf()
local clients = vim.lsp.get_active_clients({
bufnr = bufnr,
name = options.name,
@@ -412,14 +412,14 @@ function M.rename(new_name, options)
vim.notify('[LSP] Rename, no matching language servers with rename capability.')
end
- local win = vim.api.nvim_get_current_win()
+ local win = a.nvim_get_current_win()
-- Compute early to account for cursor movements after going async
- local cword = vfn.expand('<cword>')
+ local cword = vim.fn.expand('<cword>')
---@private
local function get_text_at_range(range, offset_encoding)
- return vim.api.nvim_buf_get_text(
+ return a.nvim_buf_get_text(
bufnr,
range.start.line,
util._get_line_byte_from_position(bufnr, range.start, offset_encoding),
@@ -603,8 +603,8 @@ end
--- not provided, the user will be prompted for a path using |input()|.
function M.add_workspace_folder(workspace_folder)
workspace_folder = workspace_folder
- or npcall(vfn.input, 'Workspace Folder: ', vfn.expand('%:p:h'), 'dir')
- vim.api.nvim_command('redraw')
+ or npcall(vim.fn.input, 'Workspace Folder: ', vim.fn.expand('%:p:h'), 'dir')
+ a.nvim_command('redraw')
if not (workspace_folder and #workspace_folder > 0) then
return
end
@@ -640,8 +640,8 @@ end
--- a path using |input()|.
function M.remove_workspace_folder(workspace_folder)
workspace_folder = workspace_folder
- or npcall(vfn.input, 'Workspace Folder: ', vfn.expand('%:p:h'))
- vim.api.nvim_command('redraw')
+ or npcall(vim.fn.input, 'Workspace Folder: ', vim.fn.expand('%:p:h'))
+ a.nvim_command('redraw')
if not (workspace_folder and #workspace_folder > 0) then
return
end
@@ -669,7 +669,7 @@ end
---
---@param query (string, optional)
function M.workspace_symbol(query)
- query = query or npcall(vfn.input, 'Query: ')
+ query = query or npcall(vim.fn.input, 'Query: ')
if query == nil then
return
end
@@ -838,7 +838,7 @@ end
--- with all aggregated results
---@private
local function code_action_request(params, options)
- local bufnr = vim.api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
local method = 'textDocument/codeAction'
vim.lsp.buf_request_all(bufnr, method, params, function(results)
local ctx = { bufnr = bufnr, method = method, params = params }
@@ -875,7 +875,7 @@ function M.code_action(options)
end
local context = options.context or {}
if not context.diagnostics then
- local bufnr = vim.api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics(bufnr)
end
local params = util.make_range_params()
@@ -902,7 +902,7 @@ function M.range_code_action(context, start_pos, end_pos)
validate({ context = { context, 't', true } })
context = context or {}
if not context.diagnostics then
- local bufnr = vim.api.nvim_get_current_buf()
+ local bufnr = a.nvim_get_current_buf()
context.diagnostics = vim.lsp.diagnostic.get_line_diagnostics(bufnr)
end
local params = util.make_given_range_params(start_pos, end_pos)