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>"] = {
@ -58,7 +58,7 @@ local keymaps = {
}, },
}, },
i = { }, i = { },
v = { v = {
["<Up>"] = { ["<Up>"] = {
cmd = "v:count || mode(1)[0:1] == \"no\" ? \"k\" : \"gk\"", cmd = "v:count || mode(1)[0:1] == \"no\" ? \"k\" : \"gk\"",
opts = { 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 = { 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"] = {
@ -21,16 +21,16 @@ return {
cmd = ":Telescope live_grep find_command=rg,--ignore-file,.gitignore,--exclude,*.git,--exclude,*.svn,--exclude,*.vs,--exclude,*.idea<CR>", cmd = ":Telescope live_grep find_command=rg,--ignore-file,.gitignore,--exclude,*.git,--exclude,*.svn,--exclude,*.vs,--exclude,*.idea<CR>",
}, },
-- Git -- Git
["<leader>gc"] = { ["<leader>gc"] = {
cmd = "<cmd> Telescope git_commits <CR>", cmd = "<cmd> Telescope git_commits <CR>",
}, },
["<leader>gs"] = { ["<leader>gs"] = {
cmd = "<cmd> Telescope git_status <CR>", cmd = "<cmd> Telescope git_status <CR>",
}, },
["<leader>gh"] = { ["<leader>gh"] = {
cmd = "<cmd> Telescope git_bcommits <CR>", cmd = "<cmd> Telescope git_bcommits <CR>",
}, },
["<leader>gb"] = { ["<leader>gb"] = {
cmd = "<cmd> Telescope git_branches <CR>", cmd = "<cmd> Telescope git_branches <CR>",
}, },
-- Misc -- Misc
@ -38,8 +38,7 @@ return {
cmd = "<cmd> Telescope marks <CR>", cmd = "<cmd> Telescope marks <CR>",
} }
} }
} })
require("utils").add_keymaps(keymaps)
end, end,
} }

View file

@ -9,7 +9,7 @@ opt.clipboard = "unnamedplus"
-- Highlight the currently selected row -- Highlight the currently selected row
opt.cursorline = true opt.cursorline = true
opt.cursorlineopt = "both" opt.cursorlineopt = "both"
-- Indenting -- Indenting
opt.expandtab = true opt.expandtab = true
opt.smartindent = true opt.smartindent = true
@ -17,22 +17,22 @@ opt.breakindent = true
opt.shiftwidth = 4 opt.shiftwidth = 4
opt.tabstop = 4 opt.tabstop = 4
opt.softtabstop = 4 opt.softtabstop = 4
-- Disable home screen -- Disable home screen
opt.shortmess:append("sI") opt.shortmess:append("sI")
-- Signcolumn -- Signcolumn
opt.signcolumn = "yes:1" -- Adds a spacing to the left which can contain gutter icons 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: "~" opt.fillchars = { eob = " " } -- Remove the fill character for empty lines which defaults to: "~"
-- Search -- Search
opt.ignorecase = true opt.ignorecase = true
opt.smartcase = true opt.smartcase = true
opt.incsearch = true opt.incsearch = true
-- Disable mouse support -- Disable mouse support
opt.mouse = "" opt.mouse = ""
-- Numbers -- Numbers
opt.number = true opt.number = true
opt.relativenumber = true opt.relativenumber = true
@ -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