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.maplocalleader = " "
local keymaps = {
require("utils").add_keymaps({
n = {
-- Navigation
["<C-d>"] = {
@ -58,7 +58,7 @@ local keymaps = {
},
},
i = { },
v = {
v = {
["<Up>"] = {
cmd = "v:count || mode(1)[0:1] == \"no\" ? \"k\" : \"gk\"",
opts = {
@ -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 = {
"nvim-tree/nvim-web-devicons"
},
opts = {
theme = "tokyonight-storm",
},
config = function()
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").load_extension("fzf")
local keymaps = {
require("utils").add_keymaps({
n = {
-- File search
["<leader>to"] = {
@ -21,16 +21,16 @@ return {
cmd = ":Telescope live_grep find_command=rg,--ignore-file,.gitignore,--exclude,*.git,--exclude,*.svn,--exclude,*.vs,--exclude,*.idea<CR>",
},
-- Git
["<leader>gc"] = {
["<leader>gc"] = {
cmd = "<cmd> Telescope git_commits <CR>",
},
["<leader>gs"] = {
["<leader>gs"] = {
cmd = "<cmd> Telescope git_status <CR>",
},
["<leader>gh"] = {
["<leader>gh"] = {
cmd = "<cmd> Telescope git_bcommits <CR>",
},
["<leader>gb"] = {
["<leader>gb"] = {
cmd = "<cmd> Telescope git_branches <CR>",
},
-- Misc
@ -38,8 +38,7 @@ return {
cmd = "<cmd> Telescope marks <CR>",
}
}
}
})
require("utils").add_keymaps(keymaps)
end,
}

View file

@ -9,7 +9,7 @@ opt.clipboard = "unnamedplus"
-- Highlight the currently selected row
opt.cursorline = true
opt.cursorlineopt = "both"
-- Indenting
opt.expandtab = true
opt.smartindent = true
@ -17,22 +17,22 @@ opt.breakindent = true
opt.shiftwidth = 4
opt.tabstop = 4
opt.softtabstop = 4
-- Disable home screen
opt.shortmess:append("sI")
-- Signcolumn
opt.signcolumn = "yes:1" -- Adds a spacing to the left which can contain gutter icons
opt.fillchars = { eob = " " } -- Remove the fill character for empty lines which defaults to: "~"
-- Search
opt.ignorecase = true
opt.smartcase = true
opt.incsearch = true
-- Disable mouse support
opt.mouse = ""
-- Numbers
opt.number = true
opt.relativenumber = true
@ -52,4 +52,7 @@ opt.swapfile = false
opt.splitright = true
opt.splitbelow = true
-- Removes the extra command line bar at the bottom, using lualine instead
opt.cmdheight = 0
return opt