From 729276c4c567e3116f83996f5a34adacb2d38ebb Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 28 Feb 2023 10:13:56 +0300 Subject: [PATCH] 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 --- .../utility/binds/cheatsheet/cheatsheet.nix | 14 ++ modules/utility/binds/cheatsheet/config.nix | 18 +++ modules/utility/binds/cheatsheet/default.nix | 26 +-- modules/utility/binds/default.nix | 7 +- modules/utility/binds/which-key/config.nix | 115 ++++++++++++++ modules/utility/binds/which-key/default.nix | 122 +------------- modules/utility/binds/which-key/which-key.nix | 14 ++ modules/utility/{ => colorizer}/colorizer.nix | 10 -- modules/utility/colorizer/config.nix | 16 ++ modules/utility/colorizer/default.nix | 6 + modules/utility/default.nix | 7 +- modules/utility/gestures/default.nix | 2 +- .../config.nix} | 4 - .../utility/gestures/gesture-nvim/default.nix | 6 + .../gestures/gesture-nvim/gesture-nvim.nix | 14 ++ .../config.nix} | 4 - modules/utility/icon-picker/default.nix | 6 + modules/utility/icon-picker/icon-picker.nix | 14 ++ modules/utility/telescope/config.nix | 86 ++++++++++ modules/utility/telescope/default.nix | 94 +---------- modules/utility/telescope/telescope.nix | 14 ++ modules/utility/{venn.nix => venn/config.nix} | 4 - modules/utility/venn/default.nix | 6 + modules/utility/venn/venn.nix | 14 ++ modules/visuals/config.nix | 149 +++++++++++++++--- modules/visuals/visuals.nix | 144 ++--------------- 26 files changed, 503 insertions(+), 413 deletions(-) create mode 100644 modules/utility/binds/cheatsheet/cheatsheet.nix create mode 100644 modules/utility/binds/cheatsheet/config.nix create mode 100644 modules/utility/binds/which-key/config.nix create mode 100644 modules/utility/binds/which-key/which-key.nix rename modules/utility/{ => colorizer}/colorizer.nix (57%) create mode 100644 modules/utility/colorizer/config.nix create mode 100644 modules/utility/colorizer/default.nix rename modules/utility/gestures/{gesture-nvim.nix => gesture-nvim/config.nix} (94%) create mode 100644 modules/utility/gestures/gesture-nvim/default.nix create mode 100644 modules/utility/gestures/gesture-nvim/gesture-nvim.nix rename modules/utility/{icon-picker.nix => icon-picker/config.nix} (78%) create mode 100644 modules/utility/icon-picker/default.nix create mode 100644 modules/utility/icon-picker/icon-picker.nix create mode 100644 modules/utility/telescope/config.nix create mode 100644 modules/utility/telescope/telescope.nix rename modules/utility/{venn.nix => venn/config.nix} (93%) create mode 100644 modules/utility/venn/default.nix create mode 100644 modules/utility/venn/venn.nix diff --git a/modules/utility/binds/cheatsheet/cheatsheet.nix b/modules/utility/binds/cheatsheet/cheatsheet.nix new file mode 100644 index 00000000..aabee33c --- /dev/null +++ b/modules/utility/binds/cheatsheet/cheatsheet.nix @@ -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"; + }; +} diff --git a/modules/utility/binds/cheatsheet/config.nix b/modules/utility/binds/cheatsheet/config.nix new file mode 100644 index 00000000..3aff60eb --- /dev/null +++ b/modules/utility/binds/cheatsheet/config.nix @@ -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({}) + ''; + }; +} diff --git a/modules/utility/binds/cheatsheet/default.nix b/modules/utility/binds/cheatsheet/default.nix index 2e18691e..700af5a4 100644 --- a/modules/utility/binds/cheatsheet/default.nix +++ b/modules/utility/binds/cheatsheet/default.nix @@ -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 + ]; } diff --git a/modules/utility/binds/default.nix b/modules/utility/binds/default.nix index 7c08cc6a..229423b8 100644 --- a/modules/utility/binds/default.nix +++ b/modules/utility/binds/default.nix @@ -1,9 +1,4 @@ -{ - config, - lib, - pkgs, - ... -}: { +_: { imports = [ ./which-key ./cheatsheet diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix new file mode 100644 index 00000000..2ff37d88 --- /dev/null +++ b/modules/utility/binds/which-key/config.nix @@ -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", + [""] = "RETURN", + [""] = "TAB", + }, + + ${ + if config.vim.tabline.nvimBufferline.enable + then '' + -- Buffer + ["b"] = { name = "+Buffer" }, + ["bm"] = { name = "BufferLineMove" }, + ["bs"] = { name = "BufferLineSort" }, + ["bsi"] = { name = "BufferLineSortById" }, + + '' + else "" + } + + ${ + if config.vim.telescope.enable + then '' + ["f"] = { name = "+Telescope" }, + -- Telescope + ["fl"] = { name = "Telescope LSP" }, + ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group + ["fv"] = { name = "Telescope Git" }, + ["fvc"] = { name = "Commits" }, + '' + else "" + } + + ${ + if config.vim.lsp.trouble.enable + then '' + -- Trouble + ["lw"] = { name = "Workspace" }, + ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group + ["l"] = { name = "+Trouble" }, + '' + else "" + } + + ${ + if config.vim.lsp.nvimCodeActionMenu.enable + then '' + -- Parent Groups + ["c"] = { name = "+CodeAction" }, + '' + else "" + } + + ${ + if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable + then '' + -- Minimap + ["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 + ["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 + ["t"] = { name = "+NvimTree" }, + '' + else "" + } + + ${ + if config.vim.git.gitsigns.enable + then '' + -- Git + ["g"] = { name = "+Gitsigns" }, + '' + else "" + } + + }) + + ''; + }; +} diff --git a/modules/utility/binds/which-key/default.nix b/modules/utility/binds/which-key/default.nix index 1479105e..20c9cdf5 100644 --- a/modules/utility/binds/which-key/default.nix +++ b/modules/utility/binds/which-key/default.nix @@ -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", - [""] = "RETURN", - [""] = "TAB", - }, - - ${ - if config.vim.tabline.nvimBufferline.enable - then '' - -- Buffer - ["b"] = { name = "+Buffer" }, - ["bm"] = { name = "BufferLineMove" }, - ["bs"] = { name = "BufferLineSort" }, - ["bsi"] = { name = "BufferLineSortById" }, - - '' - else "" - } - - ${ - if config.vim.telescope.enable - then '' - ["f"] = { name = "+Telescope" }, - -- Telescope - ["fl"] = { name = "Telescope LSP" }, - ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group - ["fv"] = { name = "Telescope Git" }, - ["fvc"] = { name = "Commits" }, - '' - else "" - } - - ${ - if config.vim.lsp.trouble.enable - then '' - -- Trouble - ["lw"] = { name = "Workspace" }, - ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group - ["l"] = { name = "+Trouble" }, - '' - else "" - } - - ${ - if config.vim.lsp.nvimCodeActionMenu.enable - then '' - -- Parent Groups - ["c"] = { name = "+CodeAction" }, - '' - else "" - } - - ${ - if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable - then '' - -- Minimap - ["m"] = { name = "+Minimap" }, - '' - else "" - } - - ${ - if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable - then '' - -- Notes - ["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 - ["t"] = { name = "+NvimTree" }, - '' - else "" - } - - ${ - if config.vim.git.gitsigns.enable - then '' - -- Git - ["g"] = { name = "+Gitsigns" }, - '' - else "" - } - - }) - - ''; - }; +_: { + imports = [ + ./which-key.nix + ./config.nix + ]; } diff --git a/modules/utility/binds/which-key/which-key.nix b/modules/utility/binds/which-key/which-key.nix new file mode 100644 index 00000000..f26b38b1 --- /dev/null +++ b/modules/utility/binds/which-key/which-key.nix @@ -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"; + }; +} diff --git a/modules/utility/colorizer.nix b/modules/utility/colorizer/colorizer.nix similarity index 57% rename from modules/utility/colorizer.nix rename to modules/utility/colorizer/colorizer.nix index 940ca7ce..8d14c366 100644 --- a/modules/utility/colorizer.nix +++ b/modules/utility/colorizer/colorizer.nix @@ -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 '' - ''; - }; } diff --git a/modules/utility/colorizer/config.nix b/modules/utility/colorizer/config.nix new file mode 100644 index 00000000..7f384797 --- /dev/null +++ b/modules/utility/colorizer/config.nix @@ -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" + ]; + }; +} diff --git a/modules/utility/colorizer/default.nix b/modules/utility/colorizer/default.nix new file mode 100644 index 00000000..3b5b4914 --- /dev/null +++ b/modules/utility/colorizer/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./colorizer.nix + ./config.nix + ]; +} diff --git a/modules/utility/default.nix b/modules/utility/default.nix index 0b6a21b8..347e4d7b 100644 --- a/modules/utility/default.nix +++ b/modules/utility/default.nix @@ -3,8 +3,9 @@ _: { ./binds ./gestures ./telescope - ./colorizer.nix - ./venn.nix - ./icon-picker.nix + ./colorizer + ./icon-picker + ./telescope + ./venn ]; } diff --git a/modules/utility/gestures/default.nix b/modules/utility/gestures/default.nix index 4dfa40ac..1e6eb968 100644 --- a/modules/utility/gestures/default.nix +++ b/modules/utility/gestures/default.nix @@ -1,5 +1,5 @@ _: { imports = [ - ./gesture-nvim.nix + ./gesture-nvim ]; } diff --git a/modules/utility/gestures/gesture-nvim.nix b/modules/utility/gestures/gesture-nvim/config.nix similarity index 94% rename from modules/utility/gestures/gesture-nvim.nix rename to modules/utility/gestures/gesture-nvim/config.nix index b8aa4ceb..def0cfb6 100644 --- a/modules/utility/gestures/gesture-nvim.nix +++ b/modules/utility/gestures/gesture-nvim/config.nix @@ -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"]; diff --git a/modules/utility/gestures/gesture-nvim/default.nix b/modules/utility/gestures/gesture-nvim/default.nix new file mode 100644 index 00000000..27e7e09f --- /dev/null +++ b/modules/utility/gestures/gesture-nvim/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./gesture-nvim.nix + ./config.nix + ]; +} diff --git a/modules/utility/gestures/gesture-nvim/gesture-nvim.nix b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix new file mode 100644 index 00000000..6a7dbbf5 --- /dev/null +++ b/modules/utility/gestures/gesture-nvim/gesture-nvim.nix @@ -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"; + }; +} diff --git a/modules/utility/icon-picker.nix b/modules/utility/icon-picker/config.nix similarity index 78% rename from modules/utility/icon-picker.nix rename to modules/utility/icon-picker/config.nix index c43d2cda..e146dfd3 100644 --- a/modules/utility/icon-picker.nix +++ b/modules/utility/icon-picker/config.nix @@ -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" diff --git a/modules/utility/icon-picker/default.nix b/modules/utility/icon-picker/default.nix new file mode 100644 index 00000000..b998e087 --- /dev/null +++ b/modules/utility/icon-picker/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./icon-picker.nix + ./config.nix + ]; +} diff --git a/modules/utility/icon-picker/icon-picker.nix b/modules/utility/icon-picker/icon-picker.nix new file mode 100644 index 00000000..902b3c3f --- /dev/null +++ b/modules/utility/icon-picker/icon-picker.nix @@ -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"; + }; +} diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix new file mode 100644 index 00000000..c56d91eb --- /dev/null +++ b/modules/utility/telescope/config.nix @@ -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 = + { + "ff" = " Telescope find_files"; + "fg" = " Telescope live_grep"; + "fb" = " Telescope buffers"; + "fh" = " Telescope help_tags"; + "ft" = " Telescope"; + + "fvcw" = " Telescope git_commits"; + "fvcb" = " Telescope git_bcommits"; + "fvb" = " Telescope git_branches"; + "fvs" = " Telescope git_status"; + "fvx" = " Telescope git_stash"; + } + // ( + if config.vim.lsp.enable + then { + "flsb" = " Telescope lsp_document_symbols"; + "flsw" = " Telescope lsp_workspace_symbols"; + + "flr" = " Telescope lsp_references"; + "fli" = " Telescope lsp_implementations"; + "flD" = " Telescope lsp_definitions"; + "flt" = " Telescope lsp_type_definitions"; + "fld" = " Telescope diagnostics"; + } + else {} + ) + // ( + if config.vim.treesitter.enable + then { + "fs" = " Telescope treesitter"; + } + 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 + } + ''; + }; +} diff --git a/modules/utility/telescope/default.nix b/modules/utility/telescope/default.nix index 82452fe4..c7a3819d 100644 --- a/modules/utility/telescope/default.nix +++ b/modules/utility/telescope/default.nix @@ -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" - ]; - - vim.nnoremap = - { - "ff" = " Telescope find_files"; - "fg" = " Telescope live_grep"; - "fb" = " Telescope buffers"; - "fh" = " Telescope help_tags"; - "ft" = " Telescope"; - - "fvcw" = " Telescope git_commits"; - "fvcb" = " Telescope git_bcommits"; - "fvb" = " Telescope git_branches"; - "fvs" = " Telescope git_status"; - "fvx" = " Telescope git_stash"; - } - // ( - if config.vim.lsp.enable - then { - "flsb" = " Telescope lsp_document_symbols"; - "flsw" = " Telescope lsp_workspace_symbols"; - - "flr" = " Telescope lsp_references"; - "fli" = " Telescope lsp_implementations"; - "flD" = " Telescope lsp_definitions"; - "flt" = " Telescope lsp_type_definitions"; - "fld" = " Telescope diagnostics"; - } - else {} - ) - // ( - if config.vim.treesitter.enable - then { - "fs" = " Telescope treesitter"; - } - 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 - } - ''; - }; +_: { + imports = [ + ./telescope.nix + ./config.nix + ]; } diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix new file mode 100644 index 00000000..2b43e001 --- /dev/null +++ b/modules/utility/telescope/telescope.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.telescope; +in { + options.vim.telescope = { + enable = mkEnableOption "enable telescope"; + }; +} diff --git a/modules/utility/venn.nix b/modules/utility/venn/config.nix similarity index 93% rename from modules/utility/venn.nix rename to modules/utility/venn/config.nix index b1c9ffa1..22d47b39 100644 --- a/modules/utility/venn.nix +++ b/modules/utility/venn/config.nix @@ -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" diff --git a/modules/utility/venn/default.nix b/modules/utility/venn/default.nix new file mode 100644 index 00000000..de4dff0c --- /dev/null +++ b/modules/utility/venn/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./config.nix + ./venn.nix + ]; +} diff --git a/modules/utility/venn/venn.nix b/modules/utility/venn/venn.nix new file mode 100644 index 00000000..93f13b49 --- /dev/null +++ b/modules/utility/venn/venn.nix @@ -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"; + }; +} diff --git a/modules/visuals/config.nix b/modules/visuals/config.nix index 7231c86e..1835d46d 100644 --- a/modules/visuals/config.nix +++ b/modules/visuals/config.nix @@ -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", "fml", "CellularAutomaton make_it_rain") + '' + else "" + } + ''; }; } diff --git a/modules/visuals/visuals.nix b/modules/visuals/visuals.nix index a186378c..6b3a121e 100644 --- a/modules/visuals/visuals.nix +++ b/modules/visuals/visuals.nix @@ -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", "fml", "CellularAutomaton make_it_rain") - '' - else "" - } - ''; - }; }