[nvim] adopt lspsaga for lsp ux
This commit is contained in:
parent
a748e12748
commit
230786b94d
|
@ -0,0 +1,100 @@
|
|||
return {
|
||||
"glepnir/lspsaga.nvim",
|
||||
event = "LspAttach",
|
||||
config = function()
|
||||
require("lspsaga").setup({
|
||||
lightbulb = {
|
||||
virtual_text = false,
|
||||
},
|
||||
hover = {
|
||||
open_browser = "!firefox",
|
||||
},
|
||||
symbol_in_winbar = {
|
||||
enable = false,
|
||||
},
|
||||
diagnostic = {
|
||||
show_code_action = false,
|
||||
},
|
||||
})
|
||||
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
-- LSP finder - Find the symbol's definition
|
||||
-- If there is no definition, it will instead be hidden
|
||||
-- When you use an action in finder like "open vsplit",
|
||||
-- you can use <C-t> to jump back
|
||||
keymap("n", "gh", "<cmd>Lspsaga lsp_finder<CR>")
|
||||
|
||||
-- Code action
|
||||
keymap({ "n", "v" }, "<leader>ca", "<cmd>Lspsaga code_action<CR>")
|
||||
|
||||
-- Rename all occurrences of the hovered word for the entire file
|
||||
keymap("n", "gr", "<cmd>Lspsaga rename<CR>")
|
||||
|
||||
-- Peek definition
|
||||
-- You can edit the file containing the definition in the floating window
|
||||
-- It also supports open/vsplit/etc operations, do refer to "definition_action_keys"
|
||||
-- It also supports tagstack
|
||||
-- Use <C-t> to jump back
|
||||
keymap("n", "gp", "<cmd>Lspsaga peek_definition<CR>")
|
||||
|
||||
-- Go to definition
|
||||
keymap("n", "gd", "<cmd>Lspsaga goto_definition<CR>")
|
||||
|
||||
-- Peek type definition
|
||||
-- You can edit the file containing the type definition in the floating window
|
||||
-- It also supports open/vsplit/etc operations, do refer to "definition_action_keys"
|
||||
-- It also supports tagstack
|
||||
-- Use <C-t> to jump back
|
||||
keymap("n", "gt", "<cmd>Lspsaga peek_type_definition<CR>")
|
||||
|
||||
-- Show line diagnostics
|
||||
-- You can pass argument ++unfocus to
|
||||
-- unfocus the show_line_diagnostics floating window
|
||||
keymap("n", "<leader>sl", "<cmd>Lspsaga show_line_diagnostics<CR>")
|
||||
|
||||
-- Show buffer diagnostics
|
||||
keymap("n", "<leader>sb", "<cmd>Lspsaga show_buf_diagnostics<CR>")
|
||||
|
||||
-- Show workspace diagnostics
|
||||
keymap("n", "<leader>sw", "<cmd>Lspsaga show_workspace_diagnostics<CR>")
|
||||
|
||||
-- Show cursor diagnostics
|
||||
keymap("n", "<leader>sc", "<cmd>Lspsaga show_cursor_diagnostics<CR>")
|
||||
|
||||
-- Diagnostic jump
|
||||
-- You can use <C-o> to jump back to your previous location
|
||||
keymap("n", "<leader>ep", "<cmd>Lspsaga diagnostic_jump_prev<CR>")
|
||||
keymap("n", "<leader>en", "<cmd>Lspsaga diagnostic_jump_next<CR>")
|
||||
|
||||
-- Diagnostic jump with filters such as only jumping to an error
|
||||
keymap("n", "<leader>Ep", function()
|
||||
require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR })
|
||||
end)
|
||||
keymap("n", "<leader>En", function()
|
||||
require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR })
|
||||
end)
|
||||
|
||||
-- Toggle outline
|
||||
keymap("n", "<leader>o", "<cmd>Lspsaga outline<CR>")
|
||||
|
||||
-- Hover Doc
|
||||
-- If there is no hover doc,
|
||||
-- there will be a notification stating that
|
||||
-- there is no information available.
|
||||
-- To disable it just use ":Lspsaga hover_doc ++quiet"
|
||||
-- Pressing the key twice will enter the hover window
|
||||
keymap("n", "K", "<cmd>Lspsaga hover_doc<CR>")
|
||||
|
||||
-- Call hierarchy
|
||||
keymap("n", "<Leader>ci", "<cmd>Lspsaga incoming_calls<CR>")
|
||||
keymap("n", "<Leader>co", "<cmd>Lspsaga outgoing_calls<CR>")
|
||||
|
||||
-- Floating terminal
|
||||
keymap({ "n", "t" }, "<A-d>", "<cmd>Lspsaga term_toggle<CR>")
|
||||
end,
|
||||
dependencies = {
|
||||
{ "nvim-tree/nvim-web-devicons" },
|
||||
{ "nvim-treesitter/nvim-treesitter" },
|
||||
},
|
||||
}
|
|
@ -39,25 +39,11 @@ return {
|
|||
local handlers = {}
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
vim.keymap.set("n", "<space>e", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||
vim.keymap.set("n", "<space>en", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
||||
vim.keymap.set("n", "<space>ep", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
||||
vim.keymap.set("n", "<space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
||||
|
||||
local on_attach = function(_, bufnr)
|
||||
-- Mappings.
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
|
||||
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts)
|
||||
-- See `:help vim.lsp.*` for more methods
|
||||
vim.keymap.set("n", "<space>f", vim.lsp.buf.format, bufopts)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
return {
|
||||
"hoob3rt/lualine.nvim",
|
||||
dependencies = {
|
||||
"kyazdani42/nvim-web-devicons",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
opts = {
|
||||
options = {
|
||||
|
|
Loading…
Reference in New Issue