feat: rewrite visuals using lib.mkMerge

This commit is contained in:
NotAShelf 2023-04-18 01:36:14 +03:00
parent 2627d0484a
commit 2df414b577
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
4 changed files with 93 additions and 132 deletions

View file

@ -84,7 +84,7 @@ inputs: let
vim.autopairs.enable = true; vim.autopairs.enable = true;
vim.autocomplete = { vim.autocomplete = {
enable = true; enable = false;
type = "nvim-cmp"; type = "nvim-cmp";
}; };

View file

@ -11,7 +11,8 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {
vim.treesitter.enable = true; vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
}) })
(mkIf cfg.glow.enable { (mkIf cfg.glow.enable {

View file

@ -23,7 +23,8 @@ in {
type = types.bool; type = types.bool;
default = config.vim.languages.enableTreesitter; default = config.vim.languages.enableTreesitter;
}; };
package = nvim.types.mkGrammarOption pkgs "markdown"; mdPackage = nvim.types.mkGrammarOption pkgs "markdown";
mdInlinePackage = nvim.types.mkGrammarOption pkgs "markdown-inline";
}; };
}; };
} }

View file

@ -6,94 +6,52 @@
with lib; let with lib; let
cfg = config.vim.visuals; cfg = config.vim.visuals;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable (mkMerge [
vim.startPlugins = [ (mkIf cfg.lspkind.enable {
( vim.startPlugins = ["lspkind"];
if cfg.nvimWebDevicons.enable vim.luaConfigRC.lspkind = nvim.dag.entryAnywhere ''
then "nvim-web-devicons" -- lspkind
else null require'lspkind'.init()
) '';
( })
if cfg.lspkind.enable
then "lspkind"
else null
)
(
if cfg.cursorWordline.enable
then "nvim-cursorline"
else null
)
(
if cfg.indentBlankline.enable
then "indent-blankline"
else null
)
(
if cfg.scrollBar.enable
then "scrollbar-nvim"
else null
)
(
if cfg.smoothScroll.enable
then "cinnamon-nvim"
else null
)
(
if cfg.cellularAutomaton.enable
then "cellular-automaton"
else null
)
(
if cfg.fidget-nvim.enable
then "fidget-nvim"
else null
)
];
vim.luaConfigRC.visuals = nvim.dag.entryAnywhere '' (mkIf cfg.indentBlankline.enable {
${ vim.startPlugins = ["indent-blankline"];
if cfg.lspkind.enable vim.luaConfigRC.indent-blankline = nvim.dag.entryAnywhere ''
then "require'lspkind'.init()" -- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
else "" vim.wo.colorcolumn = "99999"
} vim.opt.list = true
${
if cfg.indentBlankline.enable
then ''
-- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
vim.wo.colorcolumn = "99999"
vim.opt.list = true
${optionalString (cfg.indentBlankline.eolChar != "") ''
vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })
''}
${optionalString (cfg.indentBlankline.fillChar != "") ''
vim.opt.listchars:append({ eol = "${cfg.indentBlankline.fillChar}" })
''}
${ require("indent_blankline").setup {
if cfg.indentBlankline.eolChar == "" char = "${cfg.indentBlankline.listChar}",
then "" show_current_context = ${boolToString cfg.indentBlankline.showCurrContext},
else ''vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })'' show_end_of_line = true,
} }
'';
})
${ (mkIf cfg.cursorWordline.enable {
if cfg.indentBlankline.fillChar == "" vim.startPlugins = ["nvim-cursorline"];
then "" vim.luaConfigRC.cursorline = nvim.dag.entryAnywhere ''
else ''vim.opt.listchars:append({ space = "${cfg.indentBlankline.fillChar}"})'' vim.g.cursorline_timeout = ${toString cfg.cursorWordline.lineTimeout}
} '';
})
require("indent_blankline").setup { (mkIf cfg.nvimWebDevicons.enable {
char = "${cfg.indentBlankline.listChar}", vim.startPlugins = ["nvim-web-devicons"];
show_current_context = ${boolToString cfg.indentBlankline.showCurrContext}, })
show_end_of_line = true,
}
''
else ""
}
${ (mkIf cfg.scrollBar.enable {
if cfg.cursorWordline.enable vim.startPlugins = ["scrollbar-nvim"];
then "vim.g.cursorline_timeout = ${toString cfg.cursorWordline.lineTimeout}" vim.luaConfigRC.scrollBar = nvim.dag.entryAnywhere ''
else "" require('scrollbar').setup{
}
${
if cfg.scrollBar.enable
then "require('scrollbar').setup{
excluded_filetypes = { excluded_filetypes = {
'prompt', 'prompt',
'TelescopePrompt', 'TelescopePrompt',
@ -101,56 +59,57 @@ in {
'NvimTree', 'NvimTree',
'alpha' 'alpha'
}, },
}"
else ""
}
${
if cfg.smoothScroll.enable
then "require('cinnamon').setup()"
else ""
}
${
if cfg.cellularAutomaton.enable
then ''
local config = {
fps = 50,
name = 'slide',
} }
'';
})
-- init function is invoked only once at the start (mkIf cfg.smoothScroll.enable {
-- config.init = function (grid) vim.startPlugins = ["cinnamon-nvim"];
-- vim.luaConfigRC.smoothScroll = nvim.dag.entryAnywhere ''
-- end require('cinnamon').setup()
'';
})
-- update function (mkIf cfg.cellularAutomaton.enable {
config.update = function (grid) vim.startPlugins = ["cellular-automaton"];
for i = 1, #grid do vim.luaConfigRC.cellularAUtomaton = nvim.dag.entryAnywhere ''
local prev = grid[i][#(grid[i])] local config = {
for j = 1, #(grid[i]) do fps = 50,
grid[i][j], prev = prev, grid[i][j] name = 'slide',
end
end
return true
end
require("cellular-automaton").register_animation(config)
vim.keymap.set("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>")
''
else ""
}
${
if cfg.fidget-nvim.enable
then ''
require"fidget".setup{
align = {
bottom = ${boolToString cfg.fidget-nvim.align.bottom},
right = ${boolToString cfg.fidget-nvim.align.right},
} }
-- 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)
vim.keymap.set("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>")
'';
})
(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},
} }
'' }
else "" '';
} })
''; ]);
};
} }