Replace lspsaga with my fork of lspsaga which contains more options for the winbar which makes it easier to integrate it with lualine, which I've also done here. Additionally, set cmdheight=0, and refactor some calls to add_keymaps.

This commit is contained in:
Martin Larsson 2024-01-22 00:07:35 +01:00
parent fc96fc96fc
commit b9ffc6647e
6 changed files with 119 additions and 21 deletions

View file

@ -3,7 +3,7 @@ local g = vim.g
g.mapleader = " " g.mapleader = " "
g.maplocalleader = " " g.maplocalleader = " "
local keymaps = { require("utils").add_keymaps({
n = { n = {
-- Navigation -- Navigation
["<C-d>"] = { ["<C-d>"] = {
@ -98,6 +98,4 @@ local keymaps = {
}, },
}, },
}, },
} })
require("utils").add_keymaps(keymaps)

View file

@ -0,0 +1,9 @@
local M = {}
function M.get_breadcrumbs()
local breadcrumbs = require("lspsaga.symbol.winbar").get_bar()
-- Return breadcrumbs if the string exists and is not empty, otherwise, get the filename and return it
return breadcrumbs and breadcrumbs ~= "" and breadcrumbs or vim.fn.expand("%:t")
end
return M

View file

@ -0,0 +1,65 @@
return {
"LarssonMartin1998/lspsaga.nvim",
branch = "improved_winbar",
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons",
},
config = function()
require("lspsaga").setup({
symbol_in_winbar = {
enable = false,
separator = " ",
hide_keyword = true,
ignore_patterns = nil,
show_file = true,
folder_level = 3,
color_mode = true,
dely = 300,
show_nodes = true,
max_nodes = 3,
},
implement = {
enable = false,
},
})
require("utils").add_keymaps({
n = {
["<F2>"] = {
cmd = ":Lspsaga diagnostic_jump_next<CR>"
},
["<S-F2>"] = {
cmd = ":Lspsaga diagnostic_jump_prev<CR>"
},
["K"] = {
cmd = ":Lspsaga hover_doc<CR>"
},
["<leader>lo"] = {
cmd = ":Lspsaga outline<CR>"
},
["<leader>lr"] = {
cmd = ":Lspsaga rename<CR>"
},
["<leader>h"] = {
cmd = ":Lspsaga term_toggle<CR>"
},
["<leader>lf"] = {
cmd = ":Lspsaga finder<CR>"
},
["<leader>lpt"] = {
cmd = ":Lspsaga peek_type_definition<CR>"
},
["<leader>lph"] = {
cmd = ":Lspsaga peek_definition<CR>"
},
["<leader>ca"] = {
cmd = ":Lspsaga code_action<CR>"
},
["<leader>lc"] = {
cmd = ":Lspsaga incoming_calls<CR>"
},
}
})
end,
}

View file

@ -3,7 +3,31 @@ return {
dependencies = { dependencies = {
"nvim-tree/nvim-web-devicons" "nvim-tree/nvim-web-devicons"
}, },
opts = { config = function()
theme = "tokyonight-storm", require("lualine").setup {
}, options = {
theme = "tokyonight",
section_separators = {"", ""},
component_separators = {"", ""},
icons_enabled = true,
},
sections = {
lualine_a = {"mode"},
lualine_b = {"branch"},
lualine_c = { "require(\"lualine_extension_lspsaga\").get_breadcrumbs()" },
lualine_x = {"encoding", "fileformat", "filetype"},
lualine_y = {"progress"},
lualine_z = {"location"}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = {"location"},
lualine_y = {},
lualine_z = {}
},
tabline = {},
}
end
} }

View file

@ -8,7 +8,7 @@ return {
require("telescope").setup({ }) require("telescope").setup({ })
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")
local keymaps = { require("utils").add_keymaps({
n = { n = {
-- File search -- File search
["<leader>to"] = { ["<leader>to"] = {
@ -38,8 +38,7 @@ return {
cmd = "<cmd> Telescope marks <CR>", cmd = "<cmd> Telescope marks <CR>",
} }
} }
} })
require("utils").add_keymaps(keymaps)
end, end,
} }

View file

@ -52,4 +52,7 @@ opt.swapfile = false
opt.splitright = true opt.splitright = true
opt.splitbelow = true opt.splitbelow = true
-- Removes the extra command line bar at the bottom, using lualine instead
opt.cmdheight = 0
return opt return opt