ui/breadcrumbs: allow lualine winbar component to be disabled (#371)

This commit is contained in:
raf 2024-09-13 20:54:08 +03:00 committed by GitHub
parent b9dcbec29c
commit eb037b7bff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 52 additions and 12 deletions

View file

@ -72,7 +72,8 @@ configuration formats.
- Fix "Emac" typo - Fix "Emac" typo
- Add [new-file-template.nvim] to automatically fill new file contents using templates. - Add [new-file-template.nvim] to automatically fill new file contents using
templates.
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):
@ -147,11 +148,22 @@ configuration formats.
- Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim - Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim
closure. Both of those scripts have been automatically added to your PATH upon closure. Both of those scripts have been automatically added to your PATH upon
using neovimConfig or `programs.nvf.enable`. using neovimConfig or `programs.nvf.enable`.
- `nvf-print-config` will display your `init.lua`, in full. - `nvf-print-config` will display your `init.lua`, in full.
- `nvf-print-config-path` will display the path to _a clone_ of your - `nvf-print-config-path` will display the path to _a clone_ of your
`init.lua`. This is not the path used by the Neovim wrapper, but an `init.lua`. This is not the path used by the Neovim wrapper, but an
identical clone. identical clone.
- Add `vim.ui.breadcrumbs.lualine` to allow fine-tuning breadcrumbs behaviour on
Lualine. Only `vim.ui.breadcrumbs.lualine.winbar` is supported for the time
being.
- [](#opt-vim.ui.breadcrumbs.lualine.winbar.enable) has been added to allow
controlling the default behaviour of the `nvim-navic` component on Lualine,
which used to occupy `winbar.lualine_c` as long as breadcrumbs are enabled.
- `vim.ui.breadcrumbs.alwaysRender` has been renamed to
[](#opt-vim.ui.breadcrumbs.lualine.winbar.alwaysRender) to be conform to the
new format.
[ppenguin](https://github.com/ppenguin): [ppenguin](https://github.com/ppenguin):
- Telescope: - Telescope:

View file

@ -11,7 +11,7 @@
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
cfg = config.vim.statusline.lualine; cfg = config.vim.statusline.lualine;
breadcrumbsCfg = config.vim.ui.breadcrumbs; bCfg = config.vim.ui.breadcrumbs;
in { in {
config = mkMerge [ config = mkMerge [
# TODO: move into nvim-tree file # TODO: move into nvim-tree file
@ -20,13 +20,14 @@ in {
extensions = ["nvim-tree"]; extensions = ["nvim-tree"];
}; };
}) })
(mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") {
(mkIf (bCfg.enable && bCfg.lualine.winbar.enable && bCfg.source == "nvim-navic") {
vim.statusline.lualine.setupOpts = { vim.statusline.lualine.setupOpts = {
# TODO: rewrite in new syntax # TODO: rewrite in new syntax
winbar.lualine_c = mkDefault [ winbar.lualine_c = mkDefault [
[ [
"navic" "navic"
(mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") (mkLuaInline "draw_empty = ${boolToString bCfg.lualine.winbar.alwaysRender}")
] ]
]; ];
}; };
@ -34,7 +35,6 @@ in {
(mkIf cfg.enable { (mkIf cfg.enable {
vim = { vim = {
startPlugins = ["lualine"]; startPlugins = ["lualine"];
pluginRC.lualine = entryAnywhere '' pluginRC.lualine = entryAnywhere ''
local lualine = require('lualine') local lualine = require('lualine')
lualine.setup ${toLuaObject cfg.setupOpts} lualine.setup ${toLuaObject cfg.setupOpts}

View file

@ -31,6 +31,8 @@ in {
(renameSetupOpt ["sourceBuffer" "scrolloff"] ["source_buffer" "scrolloff"]) (renameSetupOpt ["sourceBuffer" "scrolloff"] ["source_buffer" "scrolloff"])
# TODO: every option under icon is renamed to first letter capitalized # TODO: every option under icon is renamed to first letter capitalized
(renameSetupOpt ["icon"] ["icon"]) (renameSetupOpt ["icon"] ["icon"])
(mkRenamedOptionModule ["vim" "ui" "breadcrumbs" "alwaysRender"] ["vim" "ui" "breadcrumbs" "lualine" "winbar" "alwaysRender"])
]; ];
options.vim.ui.breadcrumbs = { options.vim.ui.breadcrumbs = {
@ -43,17 +45,43 @@ in {
''; '';
}; };
# maybe this should be an option to *disable* alwaysRender optionally but oh well # Options for configuring Lualine integration of nvim-navic
# too late lualine.winbar = {
enable = mkOption {
type = bool;
default = true; # for retaining previous behaviour
example = false;
description = ''
Whether to automatically configure a winbar component for
Lualine on the Winbar section.
::: {.note}
This is **set to `true` by default**, which means nvim-navic
will occupy `winbar.lualine_c` for the breadcrumbs feature
unless this option is set to `false`.
:::
'';
};
alwaysRender = mkOption { alwaysRender = mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Whether to always display the breadcrumbs component on winbar (always renders winbar)"; example = false;
description = ''
Whether to always display the breadcrumbs component
on winbar.
::: {.note}
This will pass `draw_empty` to the `nvim_navic` winbar
component, which causes the component to be drawn even
if it's empty
:::
'';
};
}; };
navbuddy = { navbuddy = {
enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic"; enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic";
mappings = { mappings = {
close = mkOption { close = mkOption {
type = str; type = str;