mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-02 17:15:55 +00:00
modules: start breaking down core modules; simplify tree structure
This commit is contained in:
parent
4703ed7731
commit
370913e827
242 changed files with 178 additions and 124 deletions
156
modules/plugins/visuals/config.nix
Normal file
156
modules/plugins/visuals/config.nix
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge nvim optionalString boolToString mkBinding;
|
||||
|
||||
cfg = config.vim.visuals;
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.indentBlankline.enable {
|
||||
vim.startPlugins = ["indent-blankline"];
|
||||
vim.luaConfigRC.indent-blankline = nvim.dag.entryAnywhere ''
|
||||
-- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
|
||||
-- vim.wo.colorcolumn = "99999"
|
||||
vim.opt.list = true
|
||||
|
||||
${optionalString (cfg.indentBlankline.eolChar != null) ''
|
||||
vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })
|
||||
''}
|
||||
${optionalString (cfg.indentBlankline.fillChar != null) ''
|
||||
vim.opt.listchars:append({ space = "${cfg.indentBlankline.fillChar}" })
|
||||
''}
|
||||
|
||||
require("ibl").setup {
|
||||
enabled = true,
|
||||
debounce = ${toString cfg.indentBlankline.debounce},
|
||||
indent = { char = "${cfg.indentBlankline.indent.char}" },
|
||||
|
||||
viewport_buffer = {
|
||||
min = ${toString cfg.indentBlankline.viewportBuffer.min},
|
||||
max = ${toString cfg.indentBlankline.viewportBuffer.max},
|
||||
},
|
||||
|
||||
scope = {
|
||||
enabled = ${boolToString cfg.indentBlankline.scope.enabled},
|
||||
show_end = ${boolToString cfg.indentBlankline.scope.showEndOfLine}
|
||||
},
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.cursorline.enable {
|
||||
vim.startPlugins = ["nvim-cursorline"];
|
||||
vim.luaConfigRC.cursorline = nvim.dag.entryAnywhere ''
|
||||
require('nvim-cursorline').setup {
|
||||
cursorline = {
|
||||
timeout = ${toString cfg.cursorline.lineTimeout},
|
||||
number = ${boolToString (!cfg.cursorline.lineNumbersOnly)},
|
||||
}
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.nvimWebDevicons.enable {
|
||||
vim.startPlugins = ["nvim-web-devicons"];
|
||||
})
|
||||
|
||||
(mkIf cfg.scrollBar.enable {
|
||||
vim.startPlugins = ["scrollbar-nvim"];
|
||||
vim.luaConfigRC.scrollBar = nvim.dag.entryAnywhere ''
|
||||
require('scrollbar').setup{
|
||||
excluded_filetypes = {
|
||||
'prompt',
|
||||
'TelescopePrompt',
|
||||
'noice',
|
||||
'NvimTree',
|
||||
'alpha',
|
||||
'code-action-menu-menu',
|
||||
'code-action-menu-warning-message',
|
||||
'notify',
|
||||
'Navbuddy'
|
||||
},
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.smoothScroll.enable {
|
||||
vim.startPlugins = ["cinnamon-nvim"];
|
||||
vim.luaConfigRC.smoothScroll = nvim.dag.entryAnywhere ''
|
||||
require('cinnamon').setup()
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.cellularAutomaton.enable {
|
||||
vim.startPlugins = ["cellular-automaton"];
|
||||
|
||||
vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain";
|
||||
|
||||
vim.luaConfigRC.cellularAUtomaton = nvim.dag.entryAnywhere ''
|
||||
local config = {
|
||||
fps = 50,
|
||||
name = 'slide',
|
||||
}
|
||||
|
||||
-- init function is invoked only once at the start
|
||||
-- config.init = function (grid)
|
||||
--
|
||||
-- end
|
||||
|
||||
-- update function
|
||||
config.update = function (grid)
|
||||
for i = 1, #grid do
|
||||
local prev = grid[i][#(grid[i])]
|
||||
for j = 1, #(grid[i]) do
|
||||
grid[i][j], prev = prev, grid[i][j]
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
require("cellular-automaton").register_animation(config)
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.fidget-nvim.enable {
|
||||
vim.startPlugins = ["fidget-nvim"];
|
||||
vim.luaConfigRC.fidget-nvim = nvim.dag.entryAnywhere ''
|
||||
require"fidget".setup{
|
||||
align = {
|
||||
bottom = ${boolToString cfg.fidget-nvim.align.bottom},
|
||||
right = ${boolToString cfg.fidget-nvim.align.right},
|
||||
},
|
||||
window = {
|
||||
blend = 0,
|
||||
},
|
||||
}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.highlight-undo.enable {
|
||||
vim.startPlugins = ["highlight-undo"];
|
||||
vim.luaConfigRC.fidget-nvim = nvim.dag.entryAnywhere ''
|
||||
require('highlight-undo').setup({
|
||||
duration = ${toString cfg.highlight-undo.duration},
|
||||
highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount},
|
||||
undo = {
|
||||
hlgroup = ${cfg.highlight-undo.undo.hlGroup},
|
||||
mode = 'n',
|
||||
lhs = 'u',
|
||||
map = 'undo',
|
||||
opts = {}
|
||||
},
|
||||
|
||||
redo = {
|
||||
hlgroup = ${cfg.highlight-undo.redo.hlGroup},
|
||||
mode = 'n',
|
||||
lhs = '<C-r>',
|
||||
map = 'redo',
|
||||
opts = {}
|
||||
},
|
||||
})
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/visuals/default.nix
Normal file
6
modules/plugins/visuals/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./config.nix
|
||||
./visuals.nix
|
||||
];
|
||||
}
|
||||
172
modules/plugins/visuals/visuals.nix
Normal file
172
modules/plugins/visuals/visuals.nix
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkMappingOption mkOption types literalExpression mkRenamedOptionModule mkRemovedOptionModule;
|
||||
|
||||
cfg = config.vim.visuals;
|
||||
in {
|
||||
imports = [
|
||||
(mkRenamedOptionModule ["vim" "visuals" "indentBlankline" "showCurrContext"] ["vim" "visuals" "indentBlankline" "scope" "enabled"])
|
||||
(mkRenamedOptionModule ["vim" "visuals" "indentBlankline" "showEndOfLine"] ["vim" "visuals" "indentBlankline" "scope" "showEndOfLine"])
|
||||
(mkRemovedOptionModule ["vim" "visuals" "indentBlankline" "useTreesitter"] "`vim.visuals.indentBlankline.useTreesitter` has been removed upstream and can safely be removed from your configuration.")
|
||||
];
|
||||
|
||||
options.vim.visuals = {
|
||||
enable = mkEnableOption "Visual enhancements.";
|
||||
|
||||
nvimWebDevicons.enable = mkEnableOption "dev icons. Required for certain plugins [nvim-web-devicons].";
|
||||
|
||||
scrollBar.enable = mkEnableOption "scrollbar [scrollbar.nvim]";
|
||||
|
||||
smoothScroll.enable = mkEnableOption "smooth scrolling [cinnamon-nvim]";
|
||||
|
||||
cellularAutomaton = {
|
||||
enable = mkEnableOption "cellular automaton [cellular-automaton]";
|
||||
|
||||
mappings = {
|
||||
makeItRain = mkMappingOption "Make it rain [cellular-automaton]" "<leader>fml";
|
||||
};
|
||||
};
|
||||
|
||||
fidget-nvim = {
|
||||
enable = mkEnableOption "nvim LSP UI element [fidget-nvim]";
|
||||
|
||||
align = {
|
||||
bottom = mkOption {
|
||||
type = types.bool;
|
||||
description = "Align to bottom";
|
||||
default = true;
|
||||
};
|
||||
|
||||
right = mkOption {
|
||||
type = types.bool;
|
||||
description = "Align to right";
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cursorline = {
|
||||
enable = mkEnableOption "line hightlighting on the cursor [nvim-cursorline]";
|
||||
|
||||
lineTimeout = mkOption {
|
||||
type = types.int;
|
||||
description = "Time in milliseconds for cursorline to appear";
|
||||
default = 0;
|
||||
};
|
||||
|
||||
lineNumbersOnly = mkOption {
|
||||
type = types.bool;
|
||||
description = "Hightlight only in the presence of line numbers";
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
indentBlankline = {
|
||||
enable = mkEnableOption "indentation guides [indent-blankline]";
|
||||
debounce = mkOption {
|
||||
type = types.int;
|
||||
description = "Debounce time in milliseconds";
|
||||
default = 200;
|
||||
};
|
||||
|
||||
viewportBuffer = {
|
||||
min = mkOption {
|
||||
type = types.int;
|
||||
description = "Number of lines above and below of what is currently
|
||||
visible in the window";
|
||||
default = 30;
|
||||
};
|
||||
|
||||
max = mkOption {
|
||||
type = types.int;
|
||||
description = "Number of lines above and below of what is currently
|
||||
visible in the window";
|
||||
default = 500;
|
||||
};
|
||||
};
|
||||
|
||||
indent = {
|
||||
char = mkOption {
|
||||
type = types.str;
|
||||
description = "Character for indentation line";
|
||||
default = "│";
|
||||
};
|
||||
};
|
||||
|
||||
listChar = mkOption {
|
||||
type = types.str;
|
||||
description = "Character for indentation line";
|
||||
default = "│";
|
||||
};
|
||||
|
||||
fillChar = mkOption {
|
||||
description = "Character to fill indents";
|
||||
type = with types; nullOr types.str;
|
||||
default = "⋅";
|
||||
};
|
||||
|
||||
eolChar = mkOption {
|
||||
description = "Character at end of line";
|
||||
type = with types; nullOr types.str;
|
||||
default = "↴";
|
||||
};
|
||||
|
||||
scope = {
|
||||
enabled = mkOption {
|
||||
description = "Highlight current scope from treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.treesitter.enable;
|
||||
defaultText = literalExpression "config.vim.treesitter.enable";
|
||||
};
|
||||
|
||||
showEndOfLine = mkOption {
|
||||
description = ''
|
||||
Displays the end of line character set by [](#opt-vim.visuals.indentBlankline.eolChar) instead of the
|
||||
indent guide on line returns.
|
||||
'';
|
||||
type = types.bool;
|
||||
default = cfg.indentBlankline.eolChar != null;
|
||||
defaultText = literalExpression "config.vim.visuals.indentBlankline.eolChar != null";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
highlight-undo = {
|
||||
enable = mkEnableOption "highlight undo [highlight-undo]";
|
||||
|
||||
highlightForCount = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Enable support for highlighting when a <count> is provided before the key
|
||||
If set to false it will only highlight when the mapping is not prefixed with a <count>
|
||||
'';
|
||||
};
|
||||
|
||||
duration = mkOption {
|
||||
type = types.int;
|
||||
description = "Duration of highlight";
|
||||
default = 500;
|
||||
};
|
||||
|
||||
undo = {
|
||||
hlGroup = mkOption {
|
||||
type = types.str;
|
||||
description = "Highlight group for undo";
|
||||
default = "HighlightUndo";
|
||||
};
|
||||
};
|
||||
|
||||
redo = {
|
||||
hlGroup = mkOption {
|
||||
type = types.str;
|
||||
description = "Highlight group for redo";
|
||||
default = "HighlightUndo";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue