plugin/lsp: add lspsaga plugin
This commit is contained in:
parent
3e991b54ea
commit
2d1b7d554f
4 changed files with 72 additions and 21 deletions
18
flake.lock
18
flake.lock
|
@ -17,6 +17,23 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"lspsaga-nvim": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1663371685,
|
||||||
|
"narHash": "sha256-mxyqpgUWBiXC6Xm/5bb6fShZtgXGY1kBsl0DxOkf2zA=",
|
||||||
|
"owner": "glepnir",
|
||||||
|
"repo": "lspsaga.nvim",
|
||||||
|
"rev": "c2ef0115fb917460daf5c76fe3ad3a9357213b54",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "glepnir",
|
||||||
|
"repo": "lspsaga.nvim",
|
||||||
|
"rev": "c2ef0115fb917460daf5c76fe3ad3a9357213b54",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1663146586,
|
"lastModified": 1663146586,
|
||||||
|
@ -36,6 +53,7 @@
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"editorconfig-nvim": "editorconfig-nvim",
|
"editorconfig-nvim": "editorconfig-nvim",
|
||||||
|
"lspsaga-nvim": "lspsaga-nvim",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"tabby-nvim": "tabby-nvim",
|
"tabby-nvim": "tabby-nvim",
|
||||||
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",
|
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
url = "github:nvim-telescope/telescope-live-grep-args.nvim?rev=32b633b062d1168a2d18ad27994e5b4ef97f0a74";
|
url = "github:nvim-telescope/telescope-live-grep-args.nvim?rev=32b633b062d1168a2d18ad27994e5b4ef97f0a74";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lspsaga-nvim = {
|
||||||
|
url = "github:glepnir/lspsaga.nvim?rev=c2ef0115fb917460daf5c76fe3ad3a9357213b54";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ { self, nixpkgs, utils, ... }:
|
outputs = inputs @ { self, nixpkgs, utils, ... }:
|
||||||
|
@ -40,6 +45,10 @@
|
||||||
name = "telescope-live-grep-args-nvim";
|
name = "telescope-live-grep-args-nvim";
|
||||||
src = inputs.telescope-live-grep-args-nvim;
|
src = inputs.telescope-live-grep-args-nvim;
|
||||||
};
|
};
|
||||||
|
lspsaga-nvim = p.vimUtils.buildVimPluginFrom2Nix {
|
||||||
|
name = "lspsaga-nvim";
|
||||||
|
src = inputs.lspsaga-nvim;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,16 +1,26 @@
|
||||||
{ nvim-lspconfig, luasnip, nvim-cmp, cmp-nvim-lsp, cmp_luasnip, ... }:
|
{ nvim-lspconfig
|
||||||
|
, lspsaga-nvim
|
||||||
{
|
, luasnip
|
||||||
luaConfig = (builtins.readFile ./lspconfig.lua)
|
, nvim-cmp
|
||||||
+ (builtins.readFile ./nvim-cmp.lua);
|
, cmp-nvim-lsp
|
||||||
|
, cmp_luasnip
|
||||||
plugins = [
|
, ...
|
||||||
nvim-lspconfig # Collection of configurations for built-in LSP client
|
}:
|
||||||
|
|
||||||
luasnip # Snippets plugin
|
|
||||||
|
|
||||||
|
let
|
||||||
|
lsp = [ nvim-lspconfig lspsaga-nvim ];
|
||||||
|
snippets = [ luasnip ];
|
||||||
|
completions = [
|
||||||
nvim-cmp # Autocompletion
|
nvim-cmp # Autocompletion
|
||||||
cmp-nvim-lsp # LSP source for nvim-cmp
|
cmp-nvim-lsp # LSP source for nvim-cmp
|
||||||
cmp_luasnip # Snippets source for nvim-cmp
|
cmp_luasnip # Snippets source for nvim-cmp
|
||||||
];
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
luaConfig = (builtins.readFile ./lspconfig.lua)
|
||||||
|
+ (builtins.readFile ./nvim-cmp.lua);
|
||||||
|
|
||||||
|
plugins = lsp
|
||||||
|
++ snippets
|
||||||
|
++ completions;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
local lsp_config = require("lspconfig")
|
local lsp_config = require("lspconfig")
|
||||||
|
local saga = require("lspsaga")
|
||||||
|
|
||||||
|
-- See: https://github.com/glepnir/lspsaga.nvim#configuration
|
||||||
|
saga.init_lsp_saga({
|
||||||
|
border_style = "rounded",
|
||||||
|
code_action_lightbulb = { enable = false },
|
||||||
|
code_action_keys = { quit = "<Esc>" },
|
||||||
|
definition_action_keys = { quit = "<Esc>" },
|
||||||
|
rename_action_quit = "<Esc>",
|
||||||
|
})
|
||||||
|
|
||||||
-- always show signcolumns
|
-- always show signcolumns
|
||||||
vim.opt.signcolumn = "yes"
|
vim.opt.signcolumn = "yes"
|
||||||
|
@ -7,10 +17,18 @@ vim.opt.signcolumn = "yes"
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
|
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
|
||||||
vim.keymap.set("n", "[c", vim.diagnostic.goto_prev, opts)
|
vim.keymap.set("n", "[c", "<Cmd>Lspsaga diagnostic_jump_prev<CR>", opts)
|
||||||
vim.keymap.set("n", "]c", vim.diagnostic.goto_next, opts)
|
vim.keymap.set("n", "]c", "<Cmd>Lspsaga diagnostic_jump_next<CR>", opts)
|
||||||
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
|
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
|
||||||
|
|
||||||
|
-- Only jump to error
|
||||||
|
vim.keymap.set("n", "[e", function()
|
||||||
|
require("lspsaga.diagnostic").goto_prev({ severity = vim.diagnostic.severity.ERROR })
|
||||||
|
end, opts)
|
||||||
|
vim.keymap.set("n", "]e", function()
|
||||||
|
require("lspsaga.diagnostic").goto_next({ severity = vim.diagnostic.severity.ERROR })
|
||||||
|
end, opts)
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
-- Use an on_attach function to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
|
@ -25,16 +43,12 @@ local on_attach = function(client, bufnr)
|
||||||
vim.keymap.set("n", "gy", vim.lsp.buf.type_definition, bufopts)
|
vim.keymap.set("n", "gy", vim.lsp.buf.type_definition, bufopts)
|
||||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
|
||||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
|
||||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
|
|
||||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
|
||||||
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
|
--vim.keymap.set("n", "<localleader>f", vim.lsp.buf.formatting, bufopts)
|
||||||
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
|
vim.keymap.set("n", "<localleader>n", "<Cmd>Lspsaga rename<CR>", bufopts)
|
||||||
vim.keymap.set("n", "<space>wl", function()
|
vim.keymap.set({ "n", "v" }, "<localleader>a", "<Cmd>Lspsaga code_action<CR>", bufopts)
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
vim.keymap.set("n", "K", "<Cmd>Lspsaga hover_doc<CR>", bufopts)
|
||||||
end, bufopts)
|
vim.keymap.set("n", "co", "<Cmd>LSoutlineToggle<CR>", bufopts)
|
||||||
vim.keymap.set("n", "<localleader>n", vim.lsp.buf.rename, bufopts)
|
|
||||||
vim.keymap.set("n", "<localleader>a", vim.lsp.buf.code_action, bufopts)
|
|
||||||
vim.keymap.set("n", "<localleader>f", vim.lsp.buf.formatting, bufopts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- nvim-cmp
|
-- nvim-cmp
|
||||||
|
|
Reference in a new issue