neovim-flake/modules/ui/breadcrumbs/config.nix

98 lines
3.3 KiB
Nix
Raw Normal View History

2023-07-19 21:49:06 +02:00
{
config,
lib,
...
}: let
inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf;
inherit (lib.lists) optionals;
inherit (lib.nvim.dag) entryAfter;
2024-03-10 19:37:49 +01:00
inherit (lib.nvim.lua) toLuaObject;
2023-07-19 21:49:06 +02:00
cfg = config.vim.ui.breadcrumbs;
2024-03-10 19:37:49 +01:00
mkRawLua = code: {__raw = code;};
2023-07-19 21:49:06 +02:00
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 21:49:06 +02:00
2024-03-10 19:37:49 +01:00
vim.ui.breadcrumbs.navbuddy.setupOpts = {
mappings = {
${cfg.navbuddy.mappings.close} = mkRawLua "actions.close()";
${cfg.navbuddy.mappings.nextSibling} = mkRawLua "actions.next_sibling()";
${cfg.navbuddy.mappings.previousSibling} = mkRawLua "actions.previous_sibling()";
${cfg.navbuddy.mappings.parent} = mkRawLua "actions.parent()";
${cfg.navbuddy.mappings.children} = mkRawLua "actions.children()";
${cfg.navbuddy.mappings.root} = mkRawLua "actions.root()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.visualName} = mkRawLua "actions.visual_name()";
${cfg.navbuddy.mappings.visualScope} = mkRawLua "actions.visual_scope()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.yankName} = mkRawLua "actions.yank_name()";
${cfg.navbuddy.mappings.yankScope} = mkRawLua "actions.yank_scope()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.insertName} = mkRawLua "actions.insert_name()";
${cfg.navbuddy.mappings.insertScope} = mkRawLua "actions.insert_scope()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.appendName} = mkRawLua "actions.append_name()";
${cfg.navbuddy.mappings.appendScope} = mkRawLua "actions.append_scope()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.rename} = mkRawLua "actions.rename()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.delete} = mkRawLua "actions.delete()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.foldCreate} = mkRawLua "actions.fold_create()";
${cfg.navbuddy.mappings.foldDelete} = mkRawLua "actions.fold_delete()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.comment} = mkRawLua "actions.comment()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.select} = mkRawLua "actions.select()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.moveDown} = mkRawLua "actions.move_down()";
${cfg.navbuddy.mappings.moveUp} = mkRawLua "actions.move_up()";
2024-03-10 19:37:49 +01:00
${cfg.navbuddy.mappings.telescope} = mkRawLua ''
actions.telescope({
layout_strategy = "horizontal",
layout_config = {
height = 0.60,
width = 0.75,
prompt_position = "top",
preview_width = 0.50
},
})'';
${cfg.navbuddy.mappings.help} = mkRawLua "actions.help()";
};
};
2024-03-10 19:37:49 +01:00
vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] ''
2024-03-10 19:37:49 +01:00
${optionalString (cfg.source == "nvim-navic") ''
local navic = require("nvim-navic")
require("nvim-navic").setup {
highlight = true
}
''}
2024-03-10 19:37:49 +01: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 21:49:06 +02:00
'';
};
}