nvim: plugins: Drop nvim-lightbulb
Drop nvim-lightbulb and just add the needed functionality. This also fixes a minor bug where the code action detection was incorrectly being done under codeLensProvider instead of codeActionProvider.
This commit is contained in:
parent
b24c03af09
commit
8db1867f30
3 changed files with 49 additions and 31 deletions
|
@ -1,23 +0,0 @@
|
|||
require'nvim-lightbulb'.update_lightbulb {
|
||||
sign = {
|
||||
enabled = true,
|
||||
priority = 10,
|
||||
},
|
||||
float = {
|
||||
enabled = false,
|
||||
text = "💡",
|
||||
win_opts = {},
|
||||
},
|
||||
virtual_text = {
|
||||
enabled = false,
|
||||
text = "💡",
|
||||
},
|
||||
status_text = {
|
||||
enabled = false,
|
||||
text = "💡",
|
||||
text_unavailable = ""
|
||||
},
|
||||
autocmd = {
|
||||
enabled = false,
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
local protocol = require 'vim.lsp.protocol'
|
||||
local lightbulb = require 'nvim-lightbulb'
|
||||
local lsp_util = vim.lsp.util
|
||||
|
||||
vim.lsp.set_log_level("off")
|
||||
|
||||
|
@ -73,6 +73,32 @@ local lsp_key_mappings = {
|
|||
{ "codeLensProvider", '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
|
||||
|
@ -168,17 +194,33 @@ local on_attach = function(client, bufnr)
|
|||
end
|
||||
end
|
||||
|
||||
if client.server_capabilities.codeActionProvider then
|
||||
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI"}, {
|
||||
group = lsp_augroup_id,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- Taken from https://github.com/neovim/nvim-lspconfig/wiki/Code-Actions
|
||||
local context = { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() }
|
||||
local params = lsp_util.make_range_params()
|
||||
params.context = context
|
||||
vim.lsp.buf_request(0, '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.server_capabilities.codeLensProvider then
|
||||
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI", "InsertLeave"}, {
|
||||
group = lsp_augroup_id,
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.codelens.refresh,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({"CursorHold", "CursorHoldI"}, {
|
||||
group = lsp_augroup_id,
|
||||
buffer = bufnr,
|
||||
callback = lightbulb.update_lightbulb,
|
||||
})
|
||||
end
|
||||
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
|
|
|
@ -17,7 +17,6 @@ require "paq" {
|
|||
'tpope/vim-dispatch' ,
|
||||
'junegunn/vim-easy-align' ,
|
||||
'nvim-lua/plenary.nvim' ,
|
||||
'kosayoda/nvim-lightbulb' ,
|
||||
'mfussenegger/nvim-lint' ,
|
||||
'nvim-treesitter/nvim-treesitter' ,
|
||||
'mfussenegger/nvim-treehopper' ,
|
||||
|
|
Loading…
Reference in a new issue