nvf/modules/plugins/ui/breadcrumbs/config.nix

98 lines
3.3 KiB
Nix
Raw Permalink Normal View History

2023-07-19 19:49:06 +00:00
{
config,
lib,
...
}: let
inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf;
inherit (lib.lists) optionals;
inherit (lib.nvim.dag) entryAfter;
2024-03-10 18:37:49 +00:00
inherit (lib.nvim.lua) toLuaObject;
2024-03-16 09:29:32 +00:00
inherit (lib.generators) mkLuaInline;
2023-07-19 19:49:06 +00:00
cfg = config.vim.ui.breadcrumbs;
in {
config = mkIf cfg.enable {
vim.startPlugins =
[
"nvim-lspconfig"
]
++ optionals (cfg.source == "nvim-navic") [
"nvim-navic"
]
++ optionals (config.vim.lsp.lspsaga.enable && cfg.source == "lspsaga") [
"lspsaga"
]
++ optionals cfg.navbuddy.enable [
"nvim-navbuddy"
"nui-nvim"
"nvim-navic"
];
2023-07-19 19:49:06 +00:00
2024-03-10 18:37:49 +00:00
vim.ui.breadcrumbs.navbuddy.setupOpts = {
mappings = {
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.close} = mkLuaInline "actions.close()";
${cfg.navbuddy.mappings.nextSibling} = mkLuaInline "actions.next_sibling()";
${cfg.navbuddy.mappings.previousSibling} = mkLuaInline "actions.previous_sibling()";
${cfg.navbuddy.mappings.parent} = mkLuaInline "actions.parent()";
${cfg.navbuddy.mappings.children} = mkLuaInline "actions.children()";
${cfg.navbuddy.mappings.root} = mkLuaInline "actions.root()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.visualName} = mkLuaInline "actions.visual_name()";
${cfg.navbuddy.mappings.visualScope} = mkLuaInline "actions.visual_scope()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.yankName} = mkLuaInline "actions.yank_name()";
${cfg.navbuddy.mappings.yankScope} = mkLuaInline "actions.yank_scope()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.insertName} = mkLuaInline "actions.insert_name()";
${cfg.navbuddy.mappings.insertScope} = mkLuaInline "actions.insert_scope()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.appendName} = mkLuaInline "actions.append_name()";
${cfg.navbuddy.mappings.appendScope} = mkLuaInline "actions.append_scope()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.rename} = mkLuaInline "actions.rename()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.delete} = mkLuaInline "actions.delete()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.foldCreate} = mkLuaInline "actions.fold_create()";
${cfg.navbuddy.mappings.foldDelete} = mkLuaInline "actions.fold_delete()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.comment} = mkLuaInline "actions.comment()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.select} = mkLuaInline "actions.select()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()";
${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()";
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.telescope} = mkLuaInline ''
2024-03-10 18:37:49 +00:00
actions.telescope({
layout_strategy = "horizontal",
layout_config = {
height = 0.60,
width = 0.75,
prompt_position = "top",
preview_width = 0.50
},
})'';
2024-03-16 09:29:32 +00:00
${cfg.navbuddy.mappings.help} = mkLuaInline "actions.help()";
2024-03-10 18:37:49 +00:00
};
};
2024-03-10 18:37:49 +00:00
vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] ''
2024-03-10 18:37:49 +00:00
${optionalString (cfg.source == "nvim-navic") ''
local navic = require("nvim-navic")
require("nvim-navic").setup {
highlight = true
}
''}
2024-03-10 18:37:49 +00:00
${optionalString cfg.navbuddy.enable ''
local navbuddy = require("nvim-navbuddy")
local actions = require("nvim-navbuddy.actions")
navbuddy.setup ${toLuaObject cfg.navbuddy.setupOpts}
''}
2023-07-19 19:49:06 +00:00
'';
};
}