mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
NVIM: Use Lspsaga for breadcrumbs
- Disable statusline breadcrumbs coming from nvim-navic - Use Lspsaga for Hover, Goto References, Peek Definition - Enable Lspsaga Symbol Outline panel - util.lua: Use same icons on Breadcrumbs and Navic Code navigation - Code related shortcuts made for uniform, removed some
This commit is contained in:
@@ -28,26 +28,26 @@ local M = {
|
|||||||
Enum = " ",
|
Enum = " ",
|
||||||
EnumMember = " ",
|
EnumMember = " ",
|
||||||
Event = " ",
|
Event = " ",
|
||||||
Field = " ",
|
Field = " ",
|
||||||
File = " ",
|
File = " ",
|
||||||
Folder = " ",
|
Folder = " ",
|
||||||
Function = " ",
|
Function = " ",
|
||||||
Interface = " ",
|
Interface = " ",
|
||||||
Key = " ",
|
Key = " ",
|
||||||
Keyword = " ",
|
Keyword = " ",
|
||||||
Method = " ",
|
Method = " ",
|
||||||
Module = " ",
|
Module = " ",
|
||||||
Namespace = " ",
|
Namespace = " ",
|
||||||
Null = " ",
|
Null = " ",
|
||||||
Number = " ",
|
Number = " ",
|
||||||
Object = " ",
|
Object = " ",
|
||||||
Operator = " ",
|
Operator = " ",
|
||||||
Package = " ",
|
Package = " ",
|
||||||
Property = " ",
|
Property = " ",
|
||||||
Reference = " ",
|
Reference = " ",
|
||||||
Snippet = " ",
|
Snippet = " ",
|
||||||
String = " ",
|
String = " ",
|
||||||
Struct = " ",
|
Struct = " ",
|
||||||
TabNine = " ",
|
TabNine = " ",
|
||||||
Text = " ",
|
Text = " ",
|
||||||
TypeParameter = " ",
|
TypeParameter = " ",
|
||||||
@@ -55,6 +55,46 @@ local M = {
|
|||||||
Value = " ",
|
Value = " ",
|
||||||
Variable = " ",
|
Variable = " ",
|
||||||
},
|
},
|
||||||
|
-- Only to keep things in sync with "navbuddy"
|
||||||
|
kind_lspsaga = {
|
||||||
|
["Array"] = { " ", "Type" },
|
||||||
|
["Boolean"] = { " ", "Boolean" },
|
||||||
|
["Class"] = { " ", "Include" },
|
||||||
|
["Constant"] = { " ", "Constant" },
|
||||||
|
["Constructor"] = { " ", "@constructor" },
|
||||||
|
["Enum"] = { " ", "@number" },
|
||||||
|
["EnumMember"] = { " ", "Number" },
|
||||||
|
["Event"] = { " ", "Constant" },
|
||||||
|
["Field"] = { " ", "@field" },
|
||||||
|
["File"] = { " ", "Tag" },
|
||||||
|
["Function"] = { " ", "Function" },
|
||||||
|
["Interface"] = { " ", "Type" },
|
||||||
|
["Key"] = { " ", "Constant" },
|
||||||
|
["Method"] = { " ", "Function" },
|
||||||
|
["Module"] = { " ", "Exception" },
|
||||||
|
["Namespace"] = { " ", "Include" },
|
||||||
|
["Null"] = { " ", "Constant" },
|
||||||
|
["Number"] = { " ", "Number" },
|
||||||
|
["Object"] = { " ", "Type" },
|
||||||
|
["Operator"] = { " ", "Operator" },
|
||||||
|
["Package"] = { " ", "Label" },
|
||||||
|
["Property"] = { " ", "@property" },
|
||||||
|
["String"] = { " ", "String" },
|
||||||
|
["Struct"] = { " ", "Type" },
|
||||||
|
["TypeParameter"] = { " ", "Type" },
|
||||||
|
["Variable"] = { " ", "@variable" },
|
||||||
|
-- ccls
|
||||||
|
["TypeAlias"] = { " ", "Type" },
|
||||||
|
["Parameter"] = { " ", "@parameter" },
|
||||||
|
["StaticMethod"] = { " ", "Function" },
|
||||||
|
["Macro"] = { " ", "Macro" },
|
||||||
|
-- for completion sb microsoft!!!
|
||||||
|
["Text"] = { " ", "String" },
|
||||||
|
["Snippet"] = { " ", "@variable" },
|
||||||
|
["Folder"] = { " ", "Title" },
|
||||||
|
["Unit"] = { " ", "Number" },
|
||||||
|
["Value"] = { " ", "@variable" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,14 +52,6 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
|
|
||||||
conform.format({
|
|
||||||
lsp_fallback = true,
|
|
||||||
async = false,
|
|
||||||
timeout_ms = 1000,
|
|
||||||
})
|
|
||||||
end, { desc = "Code Format (visual selection)" })
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,29 +261,39 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Lsp Breadcrumbs for lualine
|
-- LspSaga
|
||||||
{
|
{
|
||||||
"SmiteshP/nvim-navic",
|
"nvimdev/lspsaga.nvim",
|
||||||
lazy = true,
|
dependencies = {
|
||||||
init = function()
|
"nvim-treesitter/nvim-treesitter",
|
||||||
vim.g.navic_silence = true
|
"nvim-tree/nvim-web-devicons",
|
||||||
require("config.util").on_lsp_attach(function(client, buffer)
|
},
|
||||||
if client.supports_method("textDocument/documentSymbol") then
|
config = function()
|
||||||
require("nvim-navic").attach(client, buffer)
|
require("lspsaga").setup({
|
||||||
end
|
ui = {
|
||||||
end)
|
kind = require("config.util").icons.kind_lspsaga,
|
||||||
end,
|
},
|
||||||
opts = function()
|
symbol_in_winbar = {
|
||||||
return {
|
enable = true,
|
||||||
separator = " ",
|
hide_keyword = true,
|
||||||
highlight = true,
|
},
|
||||||
depth_limit = 5,
|
lightbulb = {
|
||||||
icons = require("config.util").icons.kinds,
|
enable = false,
|
||||||
lazy_update_context = true,
|
sign = false,
|
||||||
}
|
virtual_text = false,
|
||||||
|
},
|
||||||
|
outline = { auto_preview = false },
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "K", "<cmd>Lspsaga hover_doc<cr>", { desc = "Hover Documentation" })
|
||||||
|
vim.keymap.set("n", "<leader>cR", "<cmd>Lspsaga finder<cr>", { desc = "Code: Goto References" })
|
||||||
|
vim.keymap.set("n", "<leader>co", "<cmd>Lspsaga outline<cr>", { desc = "Code: Toggle Symbol Outline" })
|
||||||
|
vim.keymap.set("n", "<leader>cd", "<cmd>Lspsaga peek_definition<cr>", { desc = "Code: Peek definition: Function" })
|
||||||
|
vim.keymap.set("n", "<leader>cD", "<cmd>Lspsaga peek_type_definition<cr>", { desc = "Code: Peek definition: Class" })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Search and jump around symbols in the buffer
|
||||||
{
|
{
|
||||||
"SmiteshP/nvim-navbuddy",
|
"SmiteshP/nvim-navbuddy",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
@@ -295,6 +305,60 @@ return {
|
|||||||
icons = require("config.util").icons.kinds,
|
icons = require("config.util").icons.kinds,
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
|
-- Default Mappings on the popup
|
||||||
|
-- ["<esc>"] = actions.close(), -- Close and cursor to original location
|
||||||
|
-- ["q"] = actions.close(),
|
||||||
|
--
|
||||||
|
-- ["j"] = actions.next_sibling(), -- down
|
||||||
|
-- ["k"] = actions.previous_sibling(), -- up
|
||||||
|
--
|
||||||
|
-- ["h"] = actions.parent(), -- Move to left panel
|
||||||
|
-- ["l"] = actions.children(), -- Move to right panel
|
||||||
|
-- ["0"] = actions.root(), -- Move to first panel
|
||||||
|
--
|
||||||
|
-- ["v"] = actions.visual_name(), -- Visual selection of name
|
||||||
|
-- ["V"] = actions.visual_scope(), -- Visual selection of scope
|
||||||
|
--
|
||||||
|
-- ["y"] = actions.yank_name(), -- Yank the name to system clipboard "+
|
||||||
|
-- ["Y"] = actions.yank_scope(), -- Yank the scope to system clipboard "+
|
||||||
|
--
|
||||||
|
-- ["i"] = actions.insert_name(), -- Insert at start of name
|
||||||
|
-- ["I"] = actions.insert_scope(), -- Insert at start of scope
|
||||||
|
--
|
||||||
|
-- ["a"] = actions.append_name(), -- Insert at end of name
|
||||||
|
-- ["A"] = actions.append_scope(), -- Insert at end of scope
|
||||||
|
--
|
||||||
|
-- ["r"] = actions.rename(), -- Rename currently focused symbol
|
||||||
|
--
|
||||||
|
-- ["d"] = actions.delete(), -- Delete scope
|
||||||
|
--
|
||||||
|
-- ["f"] = actions.fold_create(), -- Create fold of current scope
|
||||||
|
-- ["F"] = actions.fold_delete(), -- Delete fold of current scope
|
||||||
|
--
|
||||||
|
-- ["c"] = actions.comment(), -- Comment out current scope
|
||||||
|
--
|
||||||
|
-- ["<enter>"] = actions.select(), -- Goto selected symbol
|
||||||
|
-- ["o"] = actions.select(),
|
||||||
|
--
|
||||||
|
-- ["J"] = actions.move_down(), -- Move focused node down
|
||||||
|
-- ["K"] = actions.move_up(), -- Move focused node up
|
||||||
|
--
|
||||||
|
-- ["s"] = actions.toggle_preview(), -- Show preview of current node
|
||||||
|
--
|
||||||
|
-- ["<C-v>"] = actions.vsplit(), -- Open selected node in a vertical split
|
||||||
|
-- ["<C-s>"] = actions.hsplit(), -- Open selected node in a horizontal split
|
||||||
|
--
|
||||||
|
-- ["t"] = actions.telescope({ -- Fuzzy finder at current level.
|
||||||
|
-- layout_config = { -- All options that can be
|
||||||
|
-- height = 0.60, -- passed to telescope.nvim's
|
||||||
|
-- width = 0.60, -- default can be passed here.
|
||||||
|
-- prompt_position = "top",
|
||||||
|
-- preview_width = 0.50,
|
||||||
|
-- },
|
||||||
|
-- layout_strategy = "horizontal",
|
||||||
|
-- }),
|
||||||
|
--
|
||||||
|
-- ["g?"] = actions.help(), -- Open mappings help window
|
||||||
{
|
{
|
||||||
"<leader>v",
|
"<leader>v",
|
||||||
function()
|
function()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local on_attach = function(_, bufnr)
|
|||||||
nmap("<leader>cr", vim.lsp.buf.rename, "Rename Symbol")
|
nmap("<leader>cr", vim.lsp.buf.rename, "Rename Symbol")
|
||||||
nmap("<leader>ca", vim.lsp.buf.code_action, "Code Action")
|
nmap("<leader>ca", vim.lsp.buf.code_action, "Code Action")
|
||||||
-- See `:help K` for why this keymap
|
-- See `:help K` for why this keymap
|
||||||
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
-- nmap("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||||
-- nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
|
-- nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
|
||||||
|
|
||||||
-- Lesser used LSP functionality
|
-- Lesser used LSP functionality
|
||||||
@@ -153,7 +153,7 @@ return {
|
|||||||
end,
|
end,
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>co",
|
"<leader>cu",
|
||||||
function()
|
function()
|
||||||
vim.lsp.buf.code_action({
|
vim.lsp.buf.code_action({
|
||||||
apply = true,
|
apply = true,
|
||||||
@@ -166,7 +166,7 @@ return {
|
|||||||
desc = "Typescript: Organize Imports",
|
desc = "Typescript: Organize Imports",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"<leader>cO",
|
"<leader>cU",
|
||||||
function()
|
function()
|
||||||
vim.lsp.buf.code_action({
|
vim.lsp.buf.code_action({
|
||||||
apply = true,
|
apply = true,
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ return {
|
|||||||
},
|
},
|
||||||
|
|
||||||
textobjects = {
|
textobjects = {
|
||||||
|
|
||||||
select = {
|
select = {
|
||||||
enable = true,
|
enable = true,
|
||||||
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
||||||
@@ -158,11 +157,10 @@ return {
|
|||||||
enable = true,
|
enable = true,
|
||||||
border = "none",
|
border = "none",
|
||||||
floating_preview_opts = {},
|
floating_preview_opts = {},
|
||||||
peek_definition_code = {
|
-- peek_definition_code = {
|
||||||
-- TIP: Press the shortcut 2 times to enter the floating window
|
-- ["<leader>cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
|
||||||
["<leader>cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
|
-- ["<leader>cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
|
||||||
["<leader>cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
|
-- },
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -280,21 +280,23 @@ return {
|
|||||||
vim.keymap.set("n", "<leader>ls", require("telescope.builtin").search_history, { desc = "List Search History" })
|
vim.keymap.set("n", "<leader>ls", require("telescope.builtin").search_history, { desc = "List Search History" })
|
||||||
vim.keymap.set("n", "<leader>lv", require("telescope.builtin").vim_options, { desc = "List Vim Options" })
|
vim.keymap.set("n", "<leader>lv", require("telescope.builtin").vim_options, { desc = "List Vim Options" })
|
||||||
|
|
||||||
-- Git things -> Git
|
-- Git
|
||||||
vim.keymap.set("n", "<leader>glb", require("telescope.builtin").git_branches, { desc = "List Git Branches" })
|
vim.keymap.set("n", "<leader>glb", require("telescope.builtin").git_branches, { desc = "List Git Branches" })
|
||||||
vim.keymap.set("n", "<leader>glc", require("telescope.builtin").git_commits, { desc = "List Git Commits" })
|
vim.keymap.set("n", "<leader>glc", require("telescope.builtin").git_commits, { desc = "List Git Commits" })
|
||||||
|
|
||||||
-- LSP Things -> Coding
|
-- LSP Things -> Coding
|
||||||
vim.keymap.set("n", "<leader>cd", require("telescope.builtin").diagnostics, { desc = "Code: List Diagnostics" })
|
vim.keymap.set("n", "<leader>cld", require("telescope.builtin").diagnostics, { desc = "Code: List Diagnostics" })
|
||||||
vim.keymap.set("n", "<leader>ci", require("telescope.builtin").lsp_implementations, { desc = "Code: Goto Implementation of the word under cursor" })
|
|
||||||
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references, { desc = "Code: List References for word under cursor" })
|
vim.keymap.set("n", "<leader>ci", require("telescope.builtin").lsp_implementations, { desc = "Code: Goto Implementation" })
|
||||||
vim.keymap.set("n", "<leader>cgt", require("telescope.builtin").lsp_type_definitions, { desc = "Code: Goto definition of the Type under cursor" })
|
|
||||||
vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, { desc = "Goto Definition" })
|
vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, { desc = "Code: Goto Definition" })
|
||||||
vim.keymap.set("n", "<leader>cgd", require("telescope.builtin").lsp_type_definitions, { desc = "Type Definition" })
|
vim.keymap.set("n", "<leader>ct", require("telescope.builtin").lsp_type_definitions, { desc = "Code: Goto Type Definition" })
|
||||||
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references, { desc = "Goto References" })
|
|
||||||
vim.keymap.set("n", "<leader>cI", require("telescope.builtin").lsp_implementations, { desc = "Goto Implementation" })
|
|
||||||
vim.keymap.set("n", "<leader>cs", require("telescope.builtin").lsp_document_symbols, { desc = "Document Symbols" })
|
|
||||||
-- vim.keymap.set("n", "<leader>cgD", vim.lsp.buf.declaration, { desc = "Goto Declaration" })
|
-- vim.keymap.set("n", "<leader>cgD", vim.lsp.buf.declaration, { desc = "Goto Declaration" })
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references, { desc = "Code: Goto References" })
|
||||||
|
-- vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references, { desc = "Code: List References for word under cursor" })
|
||||||
|
|
||||||
|
-- vim.keymap.set("n", "<leader>cs", require("telescope.builtin").lsp_document_symbols, { desc = "Document Symbols" })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,15 +220,6 @@ return {
|
|||||||
file_status = true,
|
file_status = true,
|
||||||
path = 1,
|
path = 1,
|
||||||
},
|
},
|
||||||
-- Breadcrumbs from "nvim-navic" plugin
|
|
||||||
{
|
|
||||||
function()
|
|
||||||
return require("nvim-navic").get_location()
|
|
||||||
end,
|
|
||||||
cond = function()
|
|
||||||
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
|
|||||||
Reference in New Issue
Block a user