feat(plugins): Add actions-preview-nvim for LSP fixes

This commit is contained in:
Jiří Štefka 2024-09-23 03:38:02 +02:00
parent e3fd51d189
commit 1ac92922ee
Signed by: jiriks74
GPG Key ID: 1D5E30D3DB2264DE
3 changed files with 4 additions and 28 deletions

@ -35,6 +35,7 @@ with final.pkgs.lib; let
# nvim-cmp (autocompletion) and extensions
nvim-cmp # https://github.com/hrsh7th/nvim-cmp
actions-preview-nvim # LSP code actions | https://github.com/aznhe21/actions-preview.nvim
nvim-autopairs # Automatically create closing brackets | https://github.com/windwp/nvim-autopairs
cmp_luasnip # snippets autocompletion extension for nvim-cmp | https://github.com/saadparwaiz1/cmp_luasnip/
lspkind-nvim # vscode-like LSP pictograms | https://github.com/onsails/lspkind.nvim/

@ -84,39 +84,12 @@ vim.api.nvim_create_autocmd('LspAttach', {
keymap.set('n', '<M-CR>', vim.lsp.buf.code_action, { desc = '[lsp] code action' })
keymap.set('n', '<M-l>', vim.lsp.codelens.run, { desc = '[lsp] run code lens' })
keymap.set('n', 'gr', vim.lsp.buf.references, { desc = 'lsp [g]et [r]eferences' })
--[[ wk.register({
l = {
name = "[l]sp",
g = {
name = "[g]o to",
t = { "<cmd>vim.lsp.buf.type_definition<cr>", '[l]sp [g]o to [t]ype definition' },
},
p = {
name = "[p]eek",
d = { peek_definition, '[l]sp [p]eek [d]efinition' },
t = { peek_type_definition, '[l]sp [p]eek [t]ype definition' },
},
w = {
name = "[w]orkspace",
a = { "<cmd>vim.lsp.buf.add_workspace_folder<cr>", '[l]sp add [w]orksp[a]ce folder' },
r = { "<cmd>vim.lsp.buf.remove_workspace_folder<cr>", '[l]sp [w]orkspace folder [r]emove' },
l = { function() vim.print(vim.lsp.buf.list_workspace_folders()) end, '[l]sp [w]orkspace folders [l]ist' },
q = { "<cmd>vim.lsp.buf.workspace_symbol<cr>", '[l]sp [w]orkspace symbol [q]' },
},
r = { "<cmd>vim.lsp.buf.rename<cr>", '[l]sp [r]ename' },
d = { "<cmd>vim.lsp.buf.document_symbol<cr>", '[l]sp [d]ocument symbol' },
R = { "<cmd>vim.lsp.codelens.refresh<cr>", '[l]sp code lenses [R]efresh' },
f = { function() vim.lsp.buf.format { async = true } end, '[l]sp [f]ormat buffer' },
},
}, { prefix = "<leader>" }) ]]
wk.add({
{ "<leader>l", group = "[l]sp" },
{ "<leader>lR", "<cmd>vim.lsp.codelens.refresh<cr>", desc = "[l]sp code lenses [R]efresh" },
{ "<leader>ld", "<cmd>vim.lsp.buf.document_symbol<cr>", desc = "[l]sp [d]ocument symbol" },
{ "<leader>lf", function() vim.lsp.buf.format { async = true } end, desc = "[l]sp [f]ormat buffer" },
{ "<leader>lF", function() vim.lsp.buf.format { async = true } end, desc = "[l]sp [F]ormat buffer" },
{ "<leader>lg", group = "[g]o to" },
{ "<leader>lgt", "<cmd>vim.lsp.buf.type_definition<cr>", desc = "[l]sp [g]o to [t]ype definition" },
{ "<leader>lp", group = "[p]eek" },

@ -35,6 +35,8 @@ local function toggle_qf_list()
end
keymap.set('n', '<C-c>', toggle_qf_list, { desc = 'toggle quickfix list' })
keymap.set({ "v", "n" }, "gf", require("actions-preview").code_actions, { desc = '[l]sp [f]ix'})
keymap.set({ "v", "n" }, "<leader>lf", require("actions-preview").code_actions, { desc = '[l]sp [f]ix'})
local function try_fallback_notify(opts)
local success, _ = pcall(opts.try)