🐛 fix(nvim): lsp attach for action preview and lightbulb

This commit is contained in:
Sergio Laín 2023-10-31 00:01:03 +01:00
parent 091f25a184
commit a40af380e6
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
5 changed files with 48 additions and 44 deletions

View file

@ -117,7 +117,6 @@
"rest.nvim": { "branch": "main", "commit": "b8d6c0a8762fd374e0204768a94241135ca3e311" },
"rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" },
"satellite.nvim": { "branch": "main", "commit": "7911fa8137c77258ba509ba875ea52c6d59737e8" },
"scope.nvim": { "branch": "main", "commit": "cd27af77ad61a7199af5c28d27013fb956eb0e3e" },
"semshi": { "branch": "master", "commit": "50f9d74ee160e539c5662cbde5c3b0ccd4e27fb3" },
"smart-splits.nvim": { "branch": "master", "commit": "c8a9173d70cbbd1f6e4a414e49e31df2b32a1362" },
"sniprun": { "branch": "master", "commit": "0ad935699a5e24ca3a0aa621c7425ac7029775b3" },

View file

@ -48,7 +48,6 @@
"plugins.extras.lang.markdown",
"plugins.extras.lang.typescript",
"plugins.extras.lang.web",
"plugins.extras.lsp.actions-preview",
"plugins.extras.lsp.compiler",
"plugins.extras.lsp.lightbulb",
"plugins.extras.lsp.lsp",

View file

@ -1,28 +0,0 @@
return {
{
"aznhe21/actions-preview.nvim",
event = "BufRead",
opts = {
telescope = {
sorting_strategy = "ascending",
layout_strategy = "vertical",
layout_config = {
width = 0.8,
height = 0.9,
prompt_position = "top",
preview_cutoff = 20,
preview_height = function(_, _, max_lines)
return max_lines - 15
end,
},
},
},
},
{
"neovim/nvim-lspconfig",
init = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
keys[#keys + 1] = { "<leader>ca", require("actions-preview").code_actions, desc = "Code Action Preview" }
end,
},
}

View file

@ -1,19 +1,12 @@
return {
"kosayoda/nvim-lightbulb",
event = "BufReadPre",
event = "LspAttach",
opts = {
sign = {
enabled = false,
priority = 10,
},
float = {
enabled = true,
text = "💡",
win_opts = {},
},
virtual_text = {
enabled = false,
text = "💡",
autocmd = { enabled = true },
sign = { enabled = true, text = "" },
action_kinds = { "quickfix", "refactor" },
ignore = {
actions_without_kind = true,
},
},
}

View file

@ -1,3 +1,21 @@
local function toggle_diag_virtext()
local virtual_text = { -- Default virtual_text opts from Lazy.Nvim
spacing = 4,
source = "if_many",
prefix = "",
}
local config = vim.diagnostic.config()
if type(config.virtual_text) == "table" then
config.virtual_text = false
vim.diagnostic.config(config)
vim.notify("Disable diagnostics virtualtext", 5, { title = "Diagnostics" })
else
config.virtual_text = virtual_text
vim.diagnostic.config(config)
vim.notify("Enabled diagnostics virtualtext", 5, { title = "Diagnostics" })
end
end
return {
{
"neovim/nvim-lspconfig",
@ -7,8 +25,12 @@ return {
keys[#keys + 1] = { "gr", "<CMD>Glance references<CR>", desc = "References" }
keys[#keys + 1] = { "gy", "<CMD>Glance type_definitions<CR>", desc = "Goto t[y]pe definitions" }
keys[#keys + 1] = { "gI", "<CMD>Glance implementations<CR>", desc = "Goto implementations" }
keys[#keys + 1] = { "<leader>ca", require("actions-preview").code_actions, desc = "Code Action Preview" }
keys[#keys + 1] = { "<leader>cl", false }
keys[#keys + 1] = { "<leader>cli", "<cmd>LspInfo<cr>", desc = "LspInfo" }
keys[#keys + 1] = { "<leader>uv", toggle_diag_virtext, desc = "Toggle Diagnostic VirtualText" }
keys[#keys + 1] = {
"<leader>cll",
@ -132,6 +154,25 @@ return {
},
},
},
{
"aznhe21/actions-preview.nvim",
event = "LspAttach",
opts = {
telescope = {
sorting_strategy = "ascending",
layout_strategy = "vertical",
layout_config = {
width = 0.8,
height = 0.9,
prompt_position = "top",
preview_cutoff = 20,
preview_height = function(_, _, max_lines)
return max_lines - 15
end,
},
},
},
},
{
"dnlhc/glance.nvim",
cmd = { "Glance" },
@ -154,7 +195,7 @@ return {
},
{
"hinell/lsp-timeout.nvim",
event = "BufRead",
event = "LspAttach",
enabled = false,
dependencies = { "neovim/nvim-lspconfig" },
init = function()