feat: apply new module format to utility plugins

new file:   modules/utility/binds/cheatsheet/cheatsheet.nix
	new file:   modules/utility/binds/cheatsheet/config.nix
	modified:   modules/utility/binds/cheatsheet/default.nix
	modified:   modules/utility/binds/default.nix
	new file:   modules/utility/binds/which-key/config.nix
	modified:   modules/utility/binds/which-key/default.nix
	new file:   modules/utility/binds/which-key/which-key.nix
	renamed:    modules/utility/colorizer.nix -> modules/utility/colorizer/colorizer.nix
	new file:   modules/utility/colorizer/config.nix
	new file:   modules/utility/colorizer/default.nix
	modified:   modules/utility/default.nix
	modified:   modules/utility/gestures/default.nix
	renamed:    modules/utility/gestures/gesture-nvim.nix -> modules/utility/gestures/gesture-nvim/config.nix
	new file:   modules/utility/gestures/gesture-nvim/default.nix
	new file:   modules/utility/gestures/gesture-nvim/gesture-nvim.nix
	renamed:    modules/utility/icon-picker.nix -> modules/utility/icon-picker/config.nix
	new file:   modules/utility/icon-picker/default.nix
	new file:   modules/utility/icon-picker/icon-picker.nix
	new file:   modules/utility/telescope/config.nix
	modified:   modules/utility/telescope/default.nix
	new file:   modules/utility/telescope/telescope.nix
	renamed:    modules/utility/venn.nix -> modules/utility/venn/config.nix
	new file:   modules/utility/venn/default.nix
	new file:   modules/utility/venn/venn.nix
This commit is contained in:
NotAShelf 2023-02-28 10:13:56 +03:00
parent 940dfcdef9
commit 729276c4c5
No known key found for this signature in database
GPG key ID: 5B5C8895F28445F1
26 changed files with 503 additions and 413 deletions

View file

@ -0,0 +1,14 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.cheatsheet;
in {
options.vim.binds.cheatsheet = {
enable = mkEnableOption "Searchable cheatsheet for nvim using telescope";
};
}

View file

@ -0,0 +1,18 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.cheatsheet;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere ''
require('cheatsheet').setup({})
'';
};
}

View file

@ -1,22 +1,6 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.cheatsheet;
in {
options.vim.binds.cheatsheet = {
enable = mkEnableOption "Searchable cheatsheet for nvim using telescope";
};
config = mkIf (cfg.enable) {
vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere ''
require('cheatsheet').setup({})
'';
};
_: {
imports = [
./cheatsheet.nix
./config.nix
];
}

View file

@ -1,9 +1,4 @@
{
config,
lib,
pkgs,
...
}: {
_: {
imports = [
./which-key
./cheatsheet

View file

@ -0,0 +1,115 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.whichKey;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = ["which-key"];
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''
local wk = require("which-key")
wk.setup {}
wk.register({
key_labels = {
["<space>"] = "SPACE",
["<leader>"] = "SPACE",
["<cr>"] = "RETURN",
["<tab>"] = "TAB",
},
${
if config.vim.tabline.nvimBufferline.enable
then ''
-- Buffer
["<leader>b"] = { name = "+Buffer" },
["<leader>bm"] = { name = "BufferLineMove" },
["<leader>bs"] = { name = "BufferLineSort" },
["<leader>bsi"] = { name = "BufferLineSortById" },
''
else ""
}
${
if config.vim.telescope.enable
then ''
["<leader>f"] = { name = "+Telescope" },
-- Telescope
["<leader>fl"] = { name = "Telescope LSP" },
["<leader>fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group
["<leader>fv"] = { name = "Telescope Git" },
["<leader>fvc"] = { name = "Commits" },
''
else ""
}
${
if config.vim.lsp.trouble.enable
then ''
-- Trouble
["<leader>lw"] = { name = "Workspace" },
["<leader>x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group
["<leader>l"] = { name = "+Trouble" },
''
else ""
}
${
if config.vim.lsp.nvimCodeActionMenu.enable
then ''
-- Parent Groups
["<leader>c"] = { name = "+CodeAction" },
''
else ""
}
${
if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable
then ''
-- Minimap
["<leader>m"] = { name = "+Minimap" }, -- TODO: remap both minimap plugins' keys to be the same
''
else ""
}
${
if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable
then ''
-- Notes
["<leader>o"] = { name = "+Notes" },
-- TODO: options for other note taking plugins and their individual binds
-- TODO: move all note-taker binds under leader + o
''
else ""
}
${
if config.vim.filetree.nvimTreeLua.enable
then ''
-- NvimTree
["<leader>t"] = { name = "+NvimTree" },
''
else ""
}
${
if config.vim.git.gitsigns.enable
then ''
-- Git
["<leader>g"] = { name = "+Gitsigns" },
''
else ""
}
})
'';
};
}

View file

@ -1,118 +1,6 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.whichKey;
in {
options.vim.binds.whichKey = {
enable = mkEnableOption "which-key menu";
};
config = mkIf (cfg.enable) {
vim.startPlugins = ["which-key"];
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''
require("which-key").setup {}
local wk = require("which-key")
wk.register({
key_labels = {
["<space>"] = "SPACE",
["<leader>"] = "SPACE",
["<cr>"] = "RETURN",
["<tab>"] = "TAB",
},
${
if config.vim.tabline.nvimBufferline.enable
then ''
-- Buffer
["<leader>b"] = { name = "+Buffer" },
["<leader>bm"] = { name = "BufferLineMove" },
["<leader>bs"] = { name = "BufferLineSort" },
["<leader>bsi"] = { name = "BufferLineSortById" },
''
else ""
}
${
if config.vim.telescope.enable
then ''
["<leader>f"] = { name = "+Telescope" },
-- Telescope
["<leader>fl"] = { name = "Telescope LSP" },
["<leader>fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group
["<leader>fv"] = { name = "Telescope Git" },
["<leader>fvc"] = { name = "Commits" },
''
else ""
}
${
if config.vim.lsp.trouble.enable
then ''
-- Trouble
["<leader>lw"] = { name = "Workspace" },
["<leader>x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group
["<leader>l"] = { name = "+Trouble" },
''
else ""
}
${
if config.vim.lsp.nvimCodeActionMenu.enable
then ''
-- Parent Groups
["<leader>c"] = { name = "+CodeAction" },
''
else ""
}
${
if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable
then ''
-- Minimap
["<leader>m"] = { name = "+Minimap" },
''
else ""
}
${
if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable
then ''
-- Notes
["<leader>o"] = { name = "+Notes" },
-- TODO: options for other note taking plugins and their individual binds
-- TODO: move all note-taker binds under leader + o
''
else ""
}
${
if config.vim.filetree.nvimTreeLua.enable
then ''
-- NvimTree
["<leader>t"] = { name = "+NvimTree" },
''
else ""
}
${
if config.vim.git.gitsigns.enable
then ''
-- Git
["<leader>g"] = { name = "+Gitsigns" },
''
else ""
}
})
'';
};
_: {
imports = [
./which-key.nix
./config.nix
];
}

View file

@ -0,0 +1,14 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.binds.whichKey;
in {
options.vim.binds.whichKey = {
enable = mkEnableOption "which-key menu";
};
}

View file

@ -11,14 +11,4 @@ in {
options.vim.utility.colorizer = {
enable = mkEnableOption "ccc color picker for neovim";
};
config = mkIf (cfg.enable) {
vim.startPlugins = [
"colorizer"
];
vim.configRC.ccc =
nvim.dag.entryAnywhere ''
'';
};
}

View file

@ -0,0 +1,16 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.utility.colorizer;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"colorizer"
];
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./colorizer.nix
./config.nix
];
}

View file

@ -3,8 +3,9 @@ _: {
./binds
./gestures
./telescope
./colorizer.nix
./venn.nix
./icon-picker.nix
./colorizer
./icon-picker
./telescope
./venn
];
}

View file

@ -1,5 +1,5 @@
_: {
imports = [
./gesture-nvim.nix
./gesture-nvim
];
}

View file

@ -8,10 +8,6 @@ with lib;
with builtins; let
cfg = config.vim.gestures.gesture-nvim;
in {
options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "Enable GitHub Copilot";
};
config = mkIf cfg.enable {
vim.startPlugins = ["gesture-nvim"];

View file

@ -0,0 +1,6 @@
_: {
imports = [
./gesture-nvim.nix
./config.nix
];
}

View file

@ -0,0 +1,14 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.gestures.gesture-nvim;
in {
options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "Enable gesture-nvim plugin";
};
}

View file

@ -8,10 +8,6 @@ with lib;
with builtins; let
cfg = config.vim.utility.icon-picker;
in {
options.vim.utility.icon-picker = {
enable = mkEnableOption "Nerdfonts icon picker for nvim";
};
config = mkIf (cfg.enable) {
vim.startPlugins = [
"icon-picker-nvim"

View file

@ -0,0 +1,6 @@
_: {
imports = [
./icon-picker.nix
./config.nix
];
}

View file

@ -0,0 +1,14 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.utility.icon-picker;
in {
options.vim.utility.icon-picker = {
enable = mkEnableOption "Nerdfonts icon picker for nvim";
};
}

View file

@ -0,0 +1,86 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.telescope;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"telescope"
];
vim.nnoremap =
{
"<leader>ff" = "<cmd> Telescope find_files<CR>";
"<leader>fg" = "<cmd> Telescope live_grep<CR>";
"<leader>fb" = "<cmd> Telescope buffers<CR>";
"<leader>fh" = "<cmd> Telescope help_tags<CR>";
"<leader>ft" = "<cmd> Telescope<CR>";
"<leader>fvcw" = "<cmd> Telescope git_commits<CR>";
"<leader>fvcb" = "<cmd> Telescope git_bcommits<CR>";
"<leader>fvb" = "<cmd> Telescope git_branches<CR>";
"<leader>fvs" = "<cmd> Telescope git_status<CR>";
"<leader>fvx" = "<cmd> Telescope git_stash<CR>";
}
// (
if config.vim.lsp.enable
then {
"<leader>flsb" = "<cmd> Telescope lsp_document_symbols<CR>";
"<leader>flsw" = "<cmd> Telescope lsp_workspace_symbols<CR>";
"<leader>flr" = "<cmd> Telescope lsp_references<CR>";
"<leader>fli" = "<cmd> Telescope lsp_implementations<CR>";
"<leader>flD" = "<cmd> Telescope lsp_definitions<CR>";
"<leader>flt" = "<cmd> Telescope lsp_type_definitions<CR>";
"<leader>fld" = "<cmd> Telescope diagnostics<CR>";
}
else {}
)
// (
if config.vim.treesitter.enable
then {
"<leader>fs" = "<cmd> Telescope treesitter<CR>";
}
else {}
);
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
local telescope = require('telescope')
telescope.setup {
defaults = {
vimgrep_arguments = {
"${pkgs.ripgrep}/bin/rg",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case"
},
pickers = {
find_command = {
"${pkgs.fd}/bin/fd",
},
},
}
}
${
if config.vim.ui.noice.enable
then "telescope.load_extension('noice')"
else null
}
${
if config.vim.notify.nvim-notify.enable
then "telescope.load_extension('notify')"
else null
}
'';
};
}

View file

@ -1,90 +1,6 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.telescope;
in {
options.vim.telescope = {
enable = mkEnableOption "enable telescope";
};
config = mkIf (cfg.enable) {
vim.startPlugins = [
"telescope"
_: {
imports = [
./telescope.nix
./config.nix
];
vim.nnoremap =
{
"<leader>ff" = "<cmd> Telescope find_files<CR>";
"<leader>fg" = "<cmd> Telescope live_grep<CR>";
"<leader>fb" = "<cmd> Telescope buffers<CR>";
"<leader>fh" = "<cmd> Telescope help_tags<CR>";
"<leader>ft" = "<cmd> Telescope<CR>";
"<leader>fvcw" = "<cmd> Telescope git_commits<CR>";
"<leader>fvcb" = "<cmd> Telescope git_bcommits<CR>";
"<leader>fvb" = "<cmd> Telescope git_branches<CR>";
"<leader>fvs" = "<cmd> Telescope git_status<CR>";
"<leader>fvx" = "<cmd> Telescope git_stash<CR>";
}
// (
if config.vim.lsp.enable
then {
"<leader>flsb" = "<cmd> Telescope lsp_document_symbols<CR>";
"<leader>flsw" = "<cmd> Telescope lsp_workspace_symbols<CR>";
"<leader>flr" = "<cmd> Telescope lsp_references<CR>";
"<leader>fli" = "<cmd> Telescope lsp_implementations<CR>";
"<leader>flD" = "<cmd> Telescope lsp_definitions<CR>";
"<leader>flt" = "<cmd> Telescope lsp_type_definitions<CR>";
"<leader>fld" = "<cmd> Telescope diagnostics<CR>";
}
else {}
)
// (
if config.vim.treesitter.enable
then {
"<leader>fs" = "<cmd> Telescope treesitter<CR>";
}
else {}
);
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
local telescope = require('telescope')
telescope.setup {
defaults = {
vimgrep_arguments = {
"${pkgs.ripgrep}/bin/rg",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case"
},
pickers = {
find_command = {
"${pkgs.fd}/bin/fd",
},
},
}
}
${
if config.vim.ui.noice.enable
then "telescope.load_extension('noice')"
else null
}
${
if config.vim.notify.nvim-notify.enable
then "telescope.load_extension('notify')"
else null
}
'';
};
}

View file

@ -0,0 +1,14 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.telescope;
in {
options.vim.telescope = {
enable = mkEnableOption "enable telescope";
};
}

View file

@ -8,10 +8,6 @@ with lib;
with builtins; let
cfg = config.vim.utility.venn-nvim;
in {
options.vim.utility.venn-nvim = {
enable = mkEnableOption "draw ASCII diagrams in Neovim";
};
config = mkIf (cfg.enable) {
vim.startPlugins = [
"venn-nvim"

View file

@ -0,0 +1,6 @@
_: {
imports = [
./config.nix
./venn.nix
];
}

View file

@ -0,0 +1,14 @@
{
pkgs,
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.utility.venn-nvim;
in {
options.vim.utility.venn-nvim = {
enable = mkEnableOption "draw ASCII diagrams in Neovim";
};
}

View file

@ -4,30 +4,137 @@
lib,
...
}:
with lib; {
config = {
vim.visuals = {
enable = mkDefault false;
with lib; let
cfg = config.vim.visuals;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
(
if cfg.nvimWebDevicons.enable
then "nvim-web-devicons"
else null
)
(
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
)
];
nvimWebDevicons.enable = mkDefault false;
lspkind.enable = mkDefault false;
vim.luaConfigRC.visuals = nvim.dag.entryAnywhere ''
${
if cfg.lspkind.enable
then "require'lspkind'.init()"
else ""
}
${
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
scrollBar = {
enable = mkDefault false;
};
cursorWordline = {
enable = mkDefault false;
lineTimeout = mkDefault 500;
};
${
if cfg.indentBlankline.eolChar == ""
then ""
else ''vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })''
}
indentBlankline = {
enable = mkDefault false;
listChar = mkDefault "";
fillChar = mkDefault "";
eolChar = mkDefault "";
showCurrContext = mkDefault true;
};
};
${
if cfg.indentBlankline.fillChar == ""
then ""
else ''vim.opt.listchars:append({ space = "${cfg.indentBlankline.fillChar}"})''
}
require("indent_blankline").setup {
char = "${cfg.indentBlankline.listChar}",
show_current_context = ${boolToString cfg.indentBlankline.showCurrContext},
show_end_of_line = true,
}
''
else ""
}
${
if cfg.cursorWordline.enable
then "vim.g.cursorline_timeout = ${toString cfg.cursorWordline.lineTimeout}"
else ""
}
${
if cfg.scrollBar.enable
then "require('scrollbar').setup{
excluded_filetypes = {
'prompt',
'TelescopePrompt',
'noice',
'NvimTree',
'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
-- 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>")
''
else ""
}
'';
};
}

View file

@ -12,26 +12,31 @@ in {
enable = mkOption {
type = types.bool;
description = "visual enhancements";
default = false;
};
nvimWebDevicons.enable = mkOption {
type = types.bool;
description = "enable dev icons. required for certain plugins [nvim-web-devicons]";
default = false;
};
lspkind.enable = mkOption {
type = types.bool;
description = "enable vscode-like pictograms for lsp [lspkind]";
default = false;
};
scrollBar.enable = mkOption {
type = types.bool;
description = "enable scrollbar [scrollbar.nvim]";
default = false;
};
smoothScroll.enable = mkOption {
type = types.bool;
description = "enable smooth scrolling [cinnamon-nvim]";
default = false;
};
cellularAutomaton.enable = mkOption {
@ -44,6 +49,7 @@ in {
enable = mkOption {
type = types.bool;
description = "enable word and delayed line highlight [nvim-cursorline]";
default = false;
};
lineTimeout = mkOption {
@ -56,160 +62,32 @@ in {
enable = mkOption {
type = types.bool;
description = "enable indentation guides [indent-blankline]";
default = false;
};
listChar = mkOption {
type = types.str;
description = "Character for indentation line";
default = "";
};
fillChar = mkOption {
type = types.str;
description = "Character to fill indents";
default = "";
};
eolChar = mkOption {
type = types.str;
description = "Character at end of line";
default = "";
};
showCurrContext = mkOption {
type = types.bool;
description = "Highlight current context from treesitter";
default = true;
};
};
};
config =
mkIf cfg.enable
{
vim.startPlugins = [
(
if cfg.nvimWebDevicons.enable
then "nvim-web-devicons"
else null
)
(
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
)
];
vim.luaConfigRC.visuals = nvim.dag.entryAnywhere ''
${
if cfg.lspkind.enable
then "require'lspkind'.init()"
else ""
}
${
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
${
if cfg.indentBlankline.eolChar == ""
then ""
else ''vim.opt.listchars:append({ eol = "${cfg.indentBlankline.eolChar}" })''
}
${
if cfg.indentBlankline.fillChar == ""
then ""
else ''vim.opt.listchars:append({ space = "${cfg.indentBlankline.fillChar}"})''
}
require("indent_blankline").setup {
char = "${cfg.indentBlankline.listChar}",
show_current_context = ${boolToString cfg.indentBlankline.showCurrContext},
show_end_of_line = true,
}
''
else ""
}
${
if cfg.cursorWordline.enable
then "vim.g.cursorline_timeout = ${toString cfg.cursorWordline.lineTimeout}"
else ""
}
${
if cfg.scrollBar.enable
then "require('scrollbar').setup{
excluded_filetypes = {
'prompt',
'TelescopePrompt',
'noice',
'NvimTree',
'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
-- 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>")
''
else ""
}
'';
};
}