mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 10:59:49 +01:00
feat: make most navbuddy options configurable
This commit is contained in:
parent
b9e152aa50
commit
4301ade29a
2 changed files with 174 additions and 35 deletions
|
@ -1,5 +1,139 @@
|
||||||
{lib, ...}: {
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkEnableOption mkOption types;
|
||||||
|
in {
|
||||||
options.vim.ui.breadcrumbs = {
|
options.vim.ui.breadcrumbs = {
|
||||||
enable = lib.mkEnableOption "breadcrumbs";
|
enable = lib.mkEnableOption "breadcrumbs";
|
||||||
|
|
||||||
|
navbuddy = {
|
||||||
|
enable = mkEnableOption "navbuddy LSP UI";
|
||||||
|
useDefaultMappings = mkEnableOption "default Navbuddy keybindings (disables user keybinds)";
|
||||||
|
|
||||||
|
window = {
|
||||||
|
# size = {}
|
||||||
|
# position = {}
|
||||||
|
|
||||||
|
border = mkOption {
|
||||||
|
# TODO: let this type accept a custom string
|
||||||
|
type = types.enum ["single" "rounded" "double" "solid" "none"];
|
||||||
|
default = "single";
|
||||||
|
description = "border style to use";
|
||||||
|
};
|
||||||
|
|
||||||
|
scrolloff = mkOption {
|
||||||
|
type = with types; nullOr int;
|
||||||
|
default = null;
|
||||||
|
description = "Scrolloff value within navbuddy window";
|
||||||
|
};
|
||||||
|
|
||||||
|
sections = {
|
||||||
|
# left section
|
||||||
|
left = {
|
||||||
|
#size = {}
|
||||||
|
border = mkOption {
|
||||||
|
# TODO: let this type accept a custom string
|
||||||
|
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
|
||||||
|
default = null;
|
||||||
|
description = "border style to use for the left section of Navbuddy UI";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# middle section
|
||||||
|
mid = {
|
||||||
|
#size = {}
|
||||||
|
border = mkOption {
|
||||||
|
# TODO: let this type accept a custom string
|
||||||
|
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
|
||||||
|
default = null;
|
||||||
|
description = "border style to use for the middle section of Navbuddy UI";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# right section
|
||||||
|
# there is no size option for the right section, it fills the remaining space
|
||||||
|
right = {
|
||||||
|
border = mkOption {
|
||||||
|
# TODO: let this type accept a custom string
|
||||||
|
type = with types; nullOr (enum ["single" "rounded" "double" "solid" "none"]);
|
||||||
|
default = null;
|
||||||
|
description = "border style to use for the right section of Navbuddy UI";
|
||||||
|
};
|
||||||
|
|
||||||
|
preview = mkOption {
|
||||||
|
type = types.enum ["leaf" "always" "never"];
|
||||||
|
default = "leaf";
|
||||||
|
description = "display mode of the preview on the right section";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nodeMarkers = {
|
||||||
|
enable = mkEnableOption "node markers";
|
||||||
|
icons = {
|
||||||
|
leaf = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
leafSelected = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " → ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
branch = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = " ";
|
||||||
|
description = "";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
autoAttach = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Whether to attach to LSP server manually";
|
||||||
|
};
|
||||||
|
|
||||||
|
preference = mkOption {
|
||||||
|
type = with types; nullOr (listOf str);
|
||||||
|
default = null;
|
||||||
|
description = "list of lsp server names in order of preference";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sourceBuffer = {
|
||||||
|
followNode = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "keep the current node in focus on the source buffer";
|
||||||
|
};
|
||||||
|
|
||||||
|
highlight = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "highlight the currently focused node";
|
||||||
|
};
|
||||||
|
|
||||||
|
reorient = mkOption {
|
||||||
|
type = types.enum ["smart" "top" "mid" "none"];
|
||||||
|
default = "smart";
|
||||||
|
};
|
||||||
|
|
||||||
|
scrolloff = mkOption {
|
||||||
|
type = with types; nullOr int;
|
||||||
|
default = null;
|
||||||
|
description = "scrolloff value when navbuddy is open";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
icons = {};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,12 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.ui.breadcrumbs;
|
cfg = config.vim.ui.breadcrumbs;
|
||||||
|
nb = cfg.navbuddy;
|
||||||
|
|
||||||
|
nilOrStr = v:
|
||||||
|
if v == null
|
||||||
|
then "nil"
|
||||||
|
else toString v;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
|
@ -19,41 +25,52 @@ in {
|
||||||
local navic = require("nvim-navic")
|
local navic = require("nvim-navic")
|
||||||
local actions = require("nvim-navbuddy.actions")
|
local actions = require("nvim-navbuddy.actions")
|
||||||
|
|
||||||
|
-- TODO: wrap this in an optional string with navbuddy as the enable condition
|
||||||
navbuddy.setup {
|
navbuddy.setup {
|
||||||
window = {
|
window = {
|
||||||
border = "single", -- "rounded", "double", "solid", "none"
|
border = "${nb.window.border}", -- "rounded", "double", "solid", "none"
|
||||||
-- or an array with eight chars building up the border in a clockwise fashion
|
size = "60%",
|
||||||
-- starting with the top-left corner. eg: { "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" }.
|
position = "50%",
|
||||||
size = "60%", -- Or table format example: { height = "40%", width = "100%"}
|
scrolloff = ${(nilOrStr nb.window.scrolloff)},
|
||||||
position = "50%", -- Or table format example: { row = "100%", col = "0%"}
|
|
||||||
scrolloff = nil, -- scrolloff value within navbuddy window
|
|
||||||
sections = {
|
sections = {
|
||||||
left = {
|
left = {
|
||||||
size = "20%",
|
size = "20%",
|
||||||
border = nil, -- You can set border style for each section individually as well.
|
border = ${(nilOrStr nb.window.sections.left.border)},
|
||||||
},
|
},
|
||||||
|
|
||||||
mid = {
|
mid = {
|
||||||
size = "40%",
|
size = "40%",
|
||||||
border = nil,
|
border = ${(nilOrStr nb.window.sections.mid.border)},
|
||||||
},
|
},
|
||||||
|
|
||||||
right = {
|
right = {
|
||||||
-- No size option for right most section. It fills to
|
border = ${(nilOrStr nb.window.sections.right.border)},
|
||||||
-- remaining area.
|
preview = "leaf",
|
||||||
border = nil,
|
|
||||||
preview = "leaf", -- Right section can show previews too.
|
|
||||||
-- Options: "leaf", "always" or "never"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node_markers = {
|
node_markers = {
|
||||||
enabled = true,
|
enabled = ${boolToString nb.nodeMarkers.enable},
|
||||||
icons = {
|
icons = {
|
||||||
leaf = " ",
|
leaf = "${nb.nodeMarkers.icons.leaf}",
|
||||||
leaf_selected = " → ",
|
leaf_selected = "${nb.nodeMarkers.icons.leafSelected}",
|
||||||
branch = " ",
|
branch = "${nb.nodeMarkers.icons.branch}",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
auto_attach = ${boolToString nb.lsp.autoAttach},
|
||||||
|
preference = nil, -- TODO: convert list to lua table if not null
|
||||||
|
},
|
||||||
|
|
||||||
|
source_buffer = {
|
||||||
|
follow_node = ${boolToString nb.sourceBuffer.followNode},
|
||||||
|
highlight = ${boolToString nb.sourceBuffer.highlight},
|
||||||
|
reorient = "${nb.sourceBuffer.reorient}",
|
||||||
|
scrolloff = ${nilOrStr nb.sourceBuffer.scrolloff}
|
||||||
|
},
|
||||||
|
|
||||||
|
-- TODO: make those configurable
|
||||||
icons = {
|
icons = {
|
||||||
File = " ",
|
File = " ",
|
||||||
Module = " ",
|
Module = " ",
|
||||||
|
@ -82,10 +99,9 @@ in {
|
||||||
Operator = " ",
|
Operator = " ",
|
||||||
TypeParameter = " ",
|
TypeParameter = " ",
|
||||||
},
|
},
|
||||||
use_default_mappings = true, -- If set to false, only mappings set
|
|
||||||
-- by user are set. Else default
|
-- make those configurable
|
||||||
-- mappings are used for keys
|
use_default_mappings = true,
|
||||||
-- that are not set by user
|
|
||||||
mappings = {
|
mappings = {
|
||||||
["<esc>"] = actions.close(), -- Close and cursor to original location
|
["<esc>"] = actions.close(), -- Close and cursor to original location
|
||||||
["q"] = actions.close(),
|
["q"] = actions.close(),
|
||||||
|
@ -135,19 +151,8 @@ in {
|
||||||
}),
|
}),
|
||||||
|
|
||||||
["g?"] = actions.help(), -- Open mappings help window
|
["g?"] = actions.help(), -- Open mappings help window
|
||||||
},
|
|
||||||
lsp = {
|
|
||||||
auto_attach = true, -- If set to true, you don't need to manually use attach function
|
|
||||||
preference = nil, -- list of lsp server names in order of preference
|
|
||||||
},
|
|
||||||
source_buffer = {
|
|
||||||
follow_node = true, -- Keep the current node in focus on the source buffer
|
|
||||||
highlight = true, -- Highlight the currently focused node
|
|
||||||
reorient = "smart", -- "smart", "top", "mid" or "none"
|
|
||||||
scrolloff = nil -- scrolloff value when navbuddy is open
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue