mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
## Description Prior to this, when using the navic Extra, the symbol breadcrumbs shown in lualine section_c had a background color different from the background of lualine_c, causing it to standout and not blend in with some colorschemes. There were ways around this problem, but hose involved overriding a lot of highlights. See https://github.com/LazyVim/LazyVim/issues/328 This change uses the new (as of April 2023) lualine component built in to SmiteshP/nvim-navic, which has a `color_correction` option to fix the problem described above. This built-in component replaces the manual method of calling `require("nvim-navic").is_available()` and `require("nvim-navic").get_location()`. *711e9f117a
*bf587250f8
With `color_correction` set to "static" or "dynamic", navic uses the lualine section's background color when building the breadcrumbs text. *bf587250f8/doc/navic.txt (L83-L88)
I chose to set color_correction to "dynamic" to provide the best user experience as that will update the background any time the lualine section's background changes (e.g. when switching modes). ## Related Issue(s) * Fixes #328 ## Screenshots Before this fix, the breadcrumb's background did not match lualine section_c's:  After this fix, the breadcrumb's background does match:  ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
37 lines
956 B
Lua
37 lines
956 B
Lua
return {
|
|
-- lsp symbol navigation for lualine. This shows where
|
|
-- in the code structure you are - within functions, classes,
|
|
-- etc - in the statusline.
|
|
{
|
|
"SmiteshP/nvim-navic",
|
|
lazy = true,
|
|
init = function()
|
|
vim.g.navic_silence = true
|
|
LazyVim.lsp.on_attach(function(client, buffer)
|
|
if client.supports_method("textDocument/documentSymbol") then
|
|
require("nvim-navic").attach(client, buffer)
|
|
end
|
|
end)
|
|
end,
|
|
opts = function()
|
|
return {
|
|
separator = " ",
|
|
highlight = true,
|
|
depth_limit = 5,
|
|
icons = LazyVim.config.icons.kinds,
|
|
lazy_update_context = true,
|
|
}
|
|
end,
|
|
},
|
|
|
|
-- lualine integration
|
|
{
|
|
"nvim-lualine/lualine.nvim",
|
|
optional = true,
|
|
opts = function(_, opts)
|
|
if not vim.g.trouble_lualine then
|
|
table.insert(opts.sections.lualine_c, { "navic", color_correction = "dynamic" })
|
|
end
|
|
end,
|
|
},
|
|
}
|