nvim: lsp: Drop code action indicator
This commit is contained in:
parent
768ffe028f
commit
28c060e0fe
1 changed files with 0 additions and 55 deletions
|
@ -1,5 +1,4 @@
|
|||
local lsp_configs = require 'lsp-configs'
|
||||
local lsp_util = vim.lsp.util
|
||||
local protocol = require 'vim.lsp.protocol'
|
||||
|
||||
vim.lsp.set_log_level("OFF")
|
||||
|
@ -78,32 +77,6 @@ local lsp_key_mappings = {
|
|||
{ "textDocument/codeLens", 'n', '<LocalLeader>L', '<cmd>lua vim.lsp.codelens.clear()<CR>' },
|
||||
}
|
||||
|
||||
local CODE_ACTION_AVAILABLE = "CodeActionAvailable"
|
||||
local CODE_ACTION_GROUP = "code-action-group"
|
||||
|
||||
if vim.tbl_isempty(vim.fn.sign_getdefined(CODE_ACTION_AVAILABLE)) then
|
||||
vim.fn.sign_define(CODE_ACTION_AVAILABLE, { text = "💡", texthl = "DiagnosticSignInfo" })
|
||||
end
|
||||
|
||||
local code_action_update_sign = function(old_line, new_line, bufnr)
|
||||
bufnr = bufnr or "%"
|
||||
|
||||
if old_line then
|
||||
vim.fn.sign_unplace(
|
||||
CODE_ACTION_GROUP, { id = old_line, buffer = bufnr }
|
||||
)
|
||||
vim.b.code_action_line = nil
|
||||
end
|
||||
|
||||
if new_line and (vim.b.code_action_line ~= new_line) then
|
||||
vim.fn.sign_place(
|
||||
new_line, CODE_ACTION_GROUP, CODE_ACTION_AVAILABLE, bufnr,
|
||||
{ lnum = new_line, priority = 10 }
|
||||
)
|
||||
vim.b.code_action_line = new_line
|
||||
end
|
||||
end
|
||||
|
||||
local cargo_reload_workspace = function()
|
||||
vim.lsp.buf_request(0, 'rust-analyzer/reloadWorkspace', nil, function(err)
|
||||
if err then
|
||||
|
@ -193,34 +166,6 @@ local on_attach = function(client_id, client, bufnr)
|
|||
end
|
||||
end
|
||||
|
||||
if client.supports_method('textDocument/codeAction') then
|
||||
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI"}, {
|
||||
group = lsp_augroup_id,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- Adapted from https://github.com/neovim/nvim-lspconfig/wiki/Code-Actions
|
||||
-- Copied from deprecated vim.lsp.diagnostic.get_line_diagnostics()
|
||||
local diag_opts = {} --- @type vim.diagnostic.GetOpts
|
||||
diag_opts.namespace = vim.lsp.diagnostic.get_namespace(client_id)
|
||||
diag_opts.lnum = vim.api.nvim_win_get_cursor(0)[1] - 1
|
||||
|
||||
local lsp_diagnostics = vim.lsp.diagnostic.from(vim.diagnostic.get(bufnr, diag_opts))
|
||||
local context = { diagnostics = lsp_diagnostics }
|
||||
local params = lsp_util.make_range_params(0, client.offset_encoding)
|
||||
params.context = context
|
||||
|
||||
vim.lsp.buf_request(bufnr, 'textDocument/codeAction', params, function(err, result, ctx, config)
|
||||
if result and not vim.tbl_isempty(result) then
|
||||
local line = params.range.start.line
|
||||
code_action_update_sign(vim.b.code_action_line, line + 1, bufnr)
|
||||
else
|
||||
code_action_update_sign(vim.b.code_action_line, nil, bufnr)
|
||||
end
|
||||
end)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
if client.supports_method('textDocument/codeLens') then
|
||||
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI", "InsertLeave"}, {
|
||||
group = lsp_augroup_id,
|
||||
|
|
Loading…
Reference in a new issue