mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-22 05:19:48 +01:00
feat: make navbuddy icons and keybinds configurable
This commit is contained in:
parent
f5719426cb
commit
ef122b1b4d
3 changed files with 371 additions and 61 deletions
|
@ -7,6 +7,13 @@
|
||||||
in {
|
in {
|
||||||
options.vim.ui.breadcrumbs = {
|
options.vim.ui.breadcrumbs = {
|
||||||
enable = lib.mkEnableOption "breadcrumbs";
|
enable = lib.mkEnableOption "breadcrumbs";
|
||||||
|
source = mkOption {
|
||||||
|
type = types.enum ["nvim-navic" "lspsaga"];
|
||||||
|
default = "nvim-navic";
|
||||||
|
description = ''
|
||||||
|
The source to be used for breadcrumbs component
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
# maybe this should be an option to *disable* alwaysRender optionally but oh well
|
# maybe this should be an option to *disable* alwaysRender optionally but oh well
|
||||||
# too late
|
# too late
|
||||||
|
@ -20,6 +27,152 @@ in {
|
||||||
enable = mkEnableOption "navbuddy LSP UI";
|
enable = mkEnableOption "navbuddy LSP UI";
|
||||||
useDefaultMappings = mkEnableOption "default Navbuddy keybindings (disables user keybinds)";
|
useDefaultMappings = mkEnableOption "default Navbuddy keybindings (disables user keybinds)";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
close = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "<esc>";
|
||||||
|
description = "keybinding to close Navbuddy UI";
|
||||||
|
};
|
||||||
|
|
||||||
|
nextSibling = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "j";
|
||||||
|
description = "keybinding to navigate to the next sibling node";
|
||||||
|
};
|
||||||
|
|
||||||
|
previousSibling = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "k";
|
||||||
|
description = "keybinding to navigate to the previous sibling node";
|
||||||
|
};
|
||||||
|
|
||||||
|
parent = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "h";
|
||||||
|
description = "keybinding to navigate to the parent node";
|
||||||
|
};
|
||||||
|
|
||||||
|
children = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "h";
|
||||||
|
description = "keybinding to navigate to the child node";
|
||||||
|
};
|
||||||
|
|
||||||
|
root = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "0";
|
||||||
|
description = "keybinding to navigate to the root node";
|
||||||
|
};
|
||||||
|
|
||||||
|
visualName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "v";
|
||||||
|
description = "visual selection of name";
|
||||||
|
};
|
||||||
|
|
||||||
|
visualScope = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "V";
|
||||||
|
description = "visual selection of scope";
|
||||||
|
};
|
||||||
|
|
||||||
|
yankName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "y";
|
||||||
|
description = "yank the name to system clipboard";
|
||||||
|
};
|
||||||
|
|
||||||
|
yankScope = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "Y";
|
||||||
|
description = "yank the scope to system clipboard";
|
||||||
|
};
|
||||||
|
|
||||||
|
insertName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "i";
|
||||||
|
description = "insert at start of name";
|
||||||
|
};
|
||||||
|
|
||||||
|
insertScope = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "I";
|
||||||
|
description = "insert at start of scope";
|
||||||
|
};
|
||||||
|
|
||||||
|
appendName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "a";
|
||||||
|
description = "insert at end of name";
|
||||||
|
};
|
||||||
|
|
||||||
|
appendScope = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "A";
|
||||||
|
description = "insert at end of scope";
|
||||||
|
};
|
||||||
|
|
||||||
|
rename = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "r";
|
||||||
|
description = "rename the node";
|
||||||
|
};
|
||||||
|
|
||||||
|
delete = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "d";
|
||||||
|
description = "delete the node";
|
||||||
|
};
|
||||||
|
|
||||||
|
foldCreate = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "f";
|
||||||
|
description = "create a new fold";
|
||||||
|
};
|
||||||
|
|
||||||
|
foldDelete = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "F";
|
||||||
|
description = "delete the current fold";
|
||||||
|
};
|
||||||
|
|
||||||
|
comment = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "c";
|
||||||
|
description = "comment the node";
|
||||||
|
};
|
||||||
|
|
||||||
|
select = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "<enter>";
|
||||||
|
description = "goto selected symbol";
|
||||||
|
};
|
||||||
|
|
||||||
|
moveDown = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "J";
|
||||||
|
description = "move focused node down";
|
||||||
|
};
|
||||||
|
|
||||||
|
moveUp = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "K";
|
||||||
|
description = "move focused node up";
|
||||||
|
};
|
||||||
|
|
||||||
|
telescope = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "t";
|
||||||
|
description = "fuzzy finder at current level";
|
||||||
|
};
|
||||||
|
|
||||||
|
help = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "g?";
|
||||||
|
description = "open mapping help window";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
window = {
|
window = {
|
||||||
# size = {}
|
# size = {}
|
||||||
# position = {}
|
# position = {}
|
||||||
|
@ -141,7 +294,159 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
icons = {};
|
# there probably is a better way to do this
|
||||||
|
# alas, I am not a nix wizard
|
||||||
|
icons = {
|
||||||
|
file = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
module = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
class = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
property = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
field = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
enum = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
function = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
variable = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
constant = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
string = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
number = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
boolean = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "◩ ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
array = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
object = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
method = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
key = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
null = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
enumMember = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
struct = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
event = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
operator = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
typeParameter = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,16 @@ with builtins; let
|
||||||
else toString v;
|
else toString v;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins =
|
||||||
|
[
|
||||||
|
"nvim-lspconfig"
|
||||||
|
]
|
||||||
|
++ lib.optionals (config.vim.lsp.lspsaga.enable && cfg.source == "lspsaga") [
|
||||||
|
"lspsaga"
|
||||||
|
]
|
||||||
|
++ lib.optionals (cfg.navbuddy.enable || cfg.source == "nvim-navic") [
|
||||||
"nvim-navbuddy"
|
"nvim-navbuddy"
|
||||||
"nvim-navic"
|
"nvim-navic"
|
||||||
"nvim-lspconfig"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.breadcrumbs = nvim.dag.entryAfter ["lspconfig"] ''
|
vim.luaConfigRC.breadcrumbs = nvim.dag.entryAfter ["lspconfig"] ''
|
||||||
|
@ -72,85 +78,83 @@ in {
|
||||||
|
|
||||||
-- TODO: make those configurable
|
-- TODO: make those configurable
|
||||||
icons = {
|
icons = {
|
||||||
File = " ",
|
File = "${cfg.navbuddy.icons.file}",
|
||||||
Module = " ",
|
Module = "${cfg.navbuddy.icons.module}",
|
||||||
Namespace = " ",
|
Namespace = "${cfg.navbuddy.icons.namespace}",
|
||||||
Package = " ",
|
Package = "${cfg.navbuddy.icons.package}",
|
||||||
Class = " ",
|
Class = "${cfg.navbuddy.icons.class}",
|
||||||
Method = " ",
|
Method = "${cfg.navbuddy.icons.method}",
|
||||||
Property = " ",
|
Property = "${cfg.navbuddy.icons.property}",
|
||||||
Field = " ",
|
Field = "${cfg.navbuddy.icons.field}",
|
||||||
Constructor = " ",
|
Constructor = "${cfg.navbuddy.icons.constructor}",
|
||||||
Enum = "",
|
Enum = "${cfg.navbuddy.icons.enum}",
|
||||||
Interface = "",
|
Interface = "${cfg.navbuddy.icons.interface}",
|
||||||
Function = " ",
|
Function = "${cfg.navbuddy.icons.function}",
|
||||||
Variable = " ",
|
Variable = "${cfg.navbuddy.icons.variable}",
|
||||||
Constant = " ",
|
Constant = "${cfg.navbuddy.icons.constant}",
|
||||||
String = " ",
|
String = "${cfg.navbuddy.icons.string}",
|
||||||
Number = " ",
|
Number = "${cfg.navbuddy.icons.number}",
|
||||||
Boolean = "◩ ",
|
Boolean = "${cfg.navbuddy.icons.boolean}",
|
||||||
Array = " ",
|
Array = "${cfg.navbuddy.icons.array}",
|
||||||
Object = " ",
|
Object = "${cfg.navbuddy.icons.object}",
|
||||||
Key = " ",
|
Key = "${cfg.navbuddy.icons.key}",
|
||||||
Null = " ",
|
Null = "${cfg.navbuddy.icons.null}",
|
||||||
EnumMember = " ",
|
EnumMember = "${cfg.navbuddy.icons.enumMember}",
|
||||||
Struct = " ",
|
Struct = "${cfg.navbuddy.icons.struct}",
|
||||||
Event = " ",
|
Event = "${cfg.navbuddy.icons.event}",
|
||||||
Operator = " ",
|
Operator = "${cfg.navbuddy.icons.operator}",
|
||||||
TypeParameter = " ",
|
TypeParameter = "${cfg.navbuddy.icons.typeParameter}"
|
||||||
},
|
},
|
||||||
|
|
||||||
-- make those configurable
|
-- make those configurable
|
||||||
use_default_mappings = true,
|
use_default_mappings = ${cfg.navbuddy.useDefaultMappings},
|
||||||
mappings = {
|
mappings = {
|
||||||
["<esc>"] = actions.close(), -- Close and cursor to original location
|
["${cfg.navbuddy.mappings.close}"] = actions.close(), -- Close and cursor to original location
|
||||||
["q"] = actions.close(),
|
|
||||||
|
|
||||||
["j"] = actions.next_sibling(), -- down
|
["${cfg.navbuddy.mappings.nextSibling}"] = actions.next_sibling(), -- down
|
||||||
["k"] = actions.previous_sibling(), -- up
|
["${cfg.navbuddy.mappings.previousSibling}"] = actions.previous_sibling(), -- up
|
||||||
|
|
||||||
["h"] = actions.parent(), -- Move to left panel
|
["${cfg.navbuddy.mappings.close}"] = actions.parent(), -- Move to left panel
|
||||||
["l"] = actions.children(), -- Move to right panel
|
["${cfg.navbuddy.mappings.children}"] = actions.children(), -- Move to right panel
|
||||||
["0"] = actions.root(), -- Move to first panel
|
["${cfg.navbuddy.mappings.root}"] = actions.root(), -- Move to first panel
|
||||||
|
|
||||||
["v"] = actions.visual_name(), -- Visual selection of name
|
["${cfg.navbuddy.mappings.visualName}"] = actions.visual_name(), -- Visual selection of name
|
||||||
["V"] = actions.visual_scope(), -- Visual selection of scope
|
["${cfg.navbuddy.mappings.visualScope}"] = actions.visual_scope(), -- Visual selection of scope
|
||||||
|
|
||||||
["y"] = actions.yank_name(), -- Yank the name to system clipboard "+
|
["${cfg.navbuddy.mappings.yankName}"] = actions.yank_name(), -- Yank the name to system clipboard "+
|
||||||
["Y"] = actions.yank_scope(), -- Yank the scope to system clipboard "+
|
["${cfg.navbuddy.mappings.yankScope}"] = actions.yank_scope(), -- Yank the scope to system clipboard "+
|
||||||
|
|
||||||
["i"] = actions.insert_name(), -- Insert at start of name
|
["${cfg.navbuddy.mappings.insertName}"] = actions.insert_name(), -- Insert at start of name
|
||||||
["I"] = actions.insert_scope(), -- Insert at start of scope
|
["${cfg.navbuddy.mappings.insertScope}"] = actions.insert_scope(), -- Insert at start of scope
|
||||||
|
|
||||||
["a"] = actions.append_name(), -- Insert at end of name
|
["${cfg.navbuddy.mappings.appendName}"] = actions.append_name(), -- Insert at end of name
|
||||||
["A"] = actions.append_scope(), -- Insert at end of scope
|
["${cfg.navbuddy.mappings.appendScope}"] = actions.append_scope(), -- Insert at end of scope
|
||||||
|
|
||||||
["r"] = actions.rename(), -- Rename currently focused symbol
|
["${cfg.navbuddy.mappings.rename}"] = actions.rename(), -- Rename currently focused symbol
|
||||||
|
|
||||||
["d"] = actions.delete(), -- Delete scope
|
["${cfg.navbuddy.mappings.delete}"] = actions.delete(), -- Delete scope
|
||||||
|
|
||||||
["f"] = actions.fold_create(), -- Create fold of current scope
|
["${cfg.navbuddy.mappings.foldCreate}"] = actions.fold_create(), -- Create fold of current scope
|
||||||
["F"] = actions.fold_delete(), -- Delete fold of current scope
|
["${cfg.navbuddy.mappings.foldDelete}"] = actions.fold_delete(), -- Delete fold of current scope
|
||||||
|
|
||||||
["c"] = actions.comment(), -- Comment out current scope
|
["${cfg.navbuddy.mappings.comment}"] = actions.comment(), -- Comment out current scope
|
||||||
|
|
||||||
["<enter>"] = actions.select(), -- Goto selected symbol
|
["${cfg.navbuddy.mappings.select}"] = actions.select(), -- Goto selected symbol
|
||||||
["o"] = actions.select(),
|
|
||||||
|
|
||||||
["J"] = actions.move_down(), -- Move focused node down
|
["${cfg.navbuddy.mappings.moveDown}"] = actions.move_down(), -- Move focused node down
|
||||||
["K"] = actions.move_up(), -- Move focused node up
|
["${cfg.navbuddy.mappings.moveUp}"] = actions.move_up(), -- Move focused node up
|
||||||
|
|
||||||
["t"] = actions.telescope({ -- Fuzzy finder at current level.
|
["${cfg.navbuddy.mappings.telescope}"] = actions.telescope({ -- Fuzzy finder at current level.
|
||||||
layout_config = { -- All options that can be
|
layout_config = { -- All options that can be
|
||||||
height = 0.60, -- passed to telescope.nvim's
|
height = 0.60, -- passed to telescope.nvim's
|
||||||
width = 0.60, -- default can be passed here.
|
width = 0.75, -- default can be passed here.
|
||||||
prompt_position = "top",
|
prompt_position = "top",
|
||||||
preview_width = 0.50
|
preview_width = 0.50
|
||||||
},
|
},
|
||||||
layout_strategy = "horizontal"
|
layout_strategy = "horizontal"
|
||||||
}),
|
}),
|
||||||
|
|
||||||
["g?"] = actions.help(), -- Open mappings help window
|
["${cfg.navbuddy.mappings.help}"] = actions.help(), -- Open mappings help window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -54,7 +54,8 @@ in {
|
||||||
'alpha',
|
'alpha',
|
||||||
'code-action-menu-menu',
|
'code-action-menu-menu',
|
||||||
'code-action-menu-warning-message',
|
'code-action-menu-warning-message',
|
||||||
'notify'
|
'notify',
|
||||||
|
'Navbuddy'
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue