diff options
author | ii14 <ii14@users.noreply.github.com> | 2022-07-10 01:57:35 +0200 |
---|---|---|
committer | ii14 <ii14@users.noreply.github.com> | 2022-07-15 17:39:26 +0200 |
commit | 8a5c7e91f21b9f49c5443105e694056a65bf761e (patch) | |
tree | 47a0fd195dfd2ff6b3eeba1ef45d1f7208f6c91f /runtime/lua/vim/lsp/handlers.lua | |
parent | 9370e1c5111ee90f64260398b0623da4759f8f16 (diff) | |
download | rneovim-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/handlers.lua')
-rw-r--r-- | runtime/lua/vim/lsp/handlers.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index 8a64e64396..3c43676850 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -2,7 +2,7 @@ local log = require('vim.lsp.log') local protocol = require('vim.lsp.protocol') local util = require('vim.lsp.util') local vim = vim -local api = vim.api +local a = vim.api local M = {} @@ -13,7 +13,7 @@ local M = {} ---@param ... (table of strings) Will be concatenated before being written local function err_message(...) vim.notify(table.concat(vim.tbl_flatten({ ... })), vim.log.levels.ERROR) - api.nvim_command('redraw') + a.nvim_command('redraw') end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand @@ -61,7 +61,7 @@ local function progress_handler(_, result, ctx, _) client.messages.progress[token].done = true end - vim.api.nvim_command('doautocmd <nomodeline> User LspProgressUpdate') + a.nvim_command('doautocmd <nomodeline> User LspProgressUpdate') end --see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress @@ -195,14 +195,14 @@ M['textDocument/references'] = function(_, result, ctx, config) items = util.locations_to_items(result, client.offset_encoding), context = ctx, }) - api.nvim_command('lopen') + a.nvim_command('lopen') else vim.fn.setqflist({}, ' ', { title = 'References', items = util.locations_to_items(result, client.offset_encoding), context = ctx, }) - api.nvim_command('botright copen') + a.nvim_command('botright copen') end end end @@ -230,14 +230,14 @@ local function response_to_list(map_result, entity, title_fn) items = map_result(result, ctx.bufnr), context = ctx, }) - api.nvim_command('lopen') + a.nvim_command('lopen') else vim.fn.setqflist({}, ' ', { title = title_fn(ctx), items = map_result(result, ctx.bufnr), context = ctx, }) - api.nvim_command('botright copen') + a.nvim_command('botright copen') end end end @@ -290,8 +290,8 @@ M['textDocument/completion'] = function(_, result, _, _) if vim.tbl_isempty(result or {}) then return end - local row, col = unpack(api.nvim_win_get_cursor(0)) - local line = assert(api.nvim_buf_get_lines(0, row - 1, row, false)[1]) + local row, col = unpack(a.nvim_win_get_cursor(0)) + local line = assert(a.nvim_buf_get_lines(0, row - 1, row, false)[1]) local line_to_cursor = line:sub(col + 1) local textMatch = vim.fn.match(line_to_cursor, '\\k*$') local prefix = line_to_cursor:sub(textMatch + 1) @@ -358,7 +358,7 @@ local function location_handler(_, result, ctx, config) title = 'LSP locations', items = util.locations_to_items(result, client.offset_encoding), }) - api.nvim_command('botright copen') + a.nvim_command('botright copen') end else util.jump_to_location(result, client.offset_encoding, config.reuse_win) @@ -402,7 +402,7 @@ function M.signature_help(_, result, ctx, config) local client = vim.lsp.get_client_by_id(ctx.client_id) local triggers = vim.tbl_get(client.server_capabilities, 'signatureHelpProvider', 'triggerCharacters') - local ft = api.nvim_buf_get_option(ctx.bufnr, 'filetype') + local ft = a.nvim_buf_get_option(ctx.bufnr, 'filetype') local lines, hl = util.convert_signature_help_to_markdown_lines(result, ft, triggers) lines = util.trim_empty_lines(lines) if vim.tbl_isempty(lines) then @@ -413,7 +413,7 @@ function M.signature_help(_, result, ctx, config) end local fbuf, fwin = util.open_floating_preview(lines, 'markdown', config) if hl then - api.nvim_buf_add_highlight(fbuf, -1, 'LspSignatureActiveParameter', 0, unpack(hl)) + a.nvim_buf_add_highlight(fbuf, -1, 'LspSignatureActiveParameter', 0, unpack(hl)) end return fbuf, fwin end @@ -459,7 +459,7 @@ local make_call_hierarchy_handler = function(direction) end end vim.fn.setqflist({}, ' ', { title = 'LSP call hierarchy', items = items }) - api.nvim_command('botright copen') + a.nvim_command('botright copen') end end @@ -505,7 +505,7 @@ M['window/showMessage'] = function(_, result, ctx, _) err_message('LSP[', client_name, '] ', message) else local message_type_name = protocol.MessageType[message_type] - api.nvim_out_write(string.format('LSP[%s][%s] %s\n', client_name, message_type_name, message)) + a.nvim_out_write(string.format('LSP[%s][%s] %s\n', client_name, message_type_name, message)) end return result end |