diff --git a/modules/tidal/config.nix b/modules/tidal/config.nix new file mode 100644 index 0000000..7c748e5 --- /dev/null +++ b/modules/tidal/config.nix @@ -0,0 +1,23 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.tidal; +in { + config = mkIf (cfg.enable) { + vim.startPlugins = [ + # From tidalcycles flake + pkgs.vimPlugins.vim-tidal + ]; + + vim.globals = { + "tidal_target" = "terminal"; + "tidal_flash_duration" = 150; + "tidal_sc_enable" = cfg.openSC; + }; + }; +} diff --git a/modules/tidal/default.nix b/modules/tidal/default.nix index 4b07c0d..9ef675f 100644 --- a/modules/tidal/default.nix +++ b/modules/tidal/default.nix @@ -6,5 +6,6 @@ }: { imports = [ ./tidal.nix + ./config.nix ]; } diff --git a/modules/tidal/tidal.nix b/modules/tidal/tidal.nix index 6b6c27e..5db5bbb 100644 --- a/modules/tidal/tidal.nix +++ b/modules/tidal/tidal.nix @@ -23,17 +23,4 @@ in { default = true; }; }; - - config = mkIf (cfg.enable) { - vim.startPlugins = [ - # From tidalcycles flake - pkgs.vimPlugins.vim-tidal - ]; - - vim.globals = { - "tidal_target" = "terminal"; - "tidal_flash_duration" = 150; - "tidal_sc_enable" = cfg.openSC; - }; - }; } diff --git a/modules/treesitter/config.nix b/modules/treesitter/config.nix new file mode 100644 index 0000000..b7c2638 --- /dev/null +++ b/modules/treesitter/config.nix @@ -0,0 +1,65 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.treesitter; +in { + config = mkIf cfg.enable ( + let + writeIf = cond: msg: + if cond + then msg + else ""; + in { + vim.startPlugins = [ + "nvim-treesitter" + ( + if cfg.autotagHtml + then "nvim-ts-autotag" + else null + ) + ]; + + # For some reason treesitter highlighting does not work on start if this is set before syntax on + vim.configRC.treesitter = writeIf cfg.fold (nvim.dag.entryBefore ["basic"] '' + " Tree-sitter based folding + set foldmethod=expr + set foldexpr=nvim_treesitter#foldexpr() + set nofoldenable + ''); + + vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere '' + -- Treesitter config + require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + disable = {}, + }, + + auto_install = false, + ensure_installed = {}, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + + ${writeIf cfg.autotagHtml '' + autotag = { + enable = true, + }, + ''} + } + ''; + } + ); +} diff --git a/modules/treesitter/treesitter.nix b/modules/treesitter/treesitter.nix index d6acd2d..c206336 100644 --- a/modules/treesitter/treesitter.nix +++ b/modules/treesitter/treesitter.nix @@ -55,59 +55,4 @@ in { ''; }; }; - - config = mkIf cfg.enable ( - let - writeIf = cond: msg: - if cond - then msg - else ""; - in { - vim.startPlugins = [ - "nvim-treesitter" - ( - if cfg.autotagHtml - then "nvim-ts-autotag" - else null - ) - ]; - - # For some reason treesitter highlighting does not work on start if this is set before syntax on - vim.configRC.treesitter = writeIf cfg.fold (nvim.dag.entryBefore ["basic"] '' - " Tree-sitter based folding - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() - set nofoldenable - ''); - - vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere '' - -- Treesitter config - require'nvim-treesitter.configs'.setup { - highlight = { - enable = true, - disable = {}, - }, - - auto_install = false, - ensure_installed = {}, - - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, - - ${writeIf cfg.autotagHtml '' - autotag = { - enable = true, - }, - ''} - } - ''; - } - ); }