From 3348300ab76a60bc056d93f9f834cddf06922b92 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 6 May 2024 18:14:52 -0400 Subject: [PATCH] refactor(nvim): move treesitter stuff to its own file --- common/home/neovim/default.nix | 83 +-------------- common/home/neovim/plugins/treesitter.vim | 21 ---- common/home/neovim/treesitter.nix | 119 ++++++++++++++++++++++ 3 files changed, 123 insertions(+), 100 deletions(-) delete mode 100644 common/home/neovim/plugins/treesitter.vim create mode 100644 common/home/neovim/treesitter.nix diff --git a/common/home/neovim/default.nix b/common/home/neovim/default.nix index a74de3b..af6971b 100644 --- a/common/home/neovim/default.nix +++ b/common/home/neovim/default.nix @@ -35,6 +35,10 @@ in { } ]; + imports = [ + ./treesitter.nix + ]; + home = optionalAttrs neovimIde { packages = with pkgs; [ gradle @@ -301,85 +305,6 @@ in { */ ''require('easytables').setup();''; } - ] - # Treesitter - ++ [ - vimPlugins.nvim-treesitter-context - vimPlugins.nvim-treesitter-textobjects - { - type = "viml"; - config = fileContents ./plugins/treesitter.vim; - plugin = vimPlugins.nvim-treesitter.withPlugins (p: [ - p.awk - p.bash - p.c - p.c_sharp - p.cairo - p.cmake - p.comment - p.cpp - p.css - p.csv - p.cuda - p.diff - p.dockerfile - p.dot - p.git_config - p.git_rebase - p.gitattributes - p.gitcommit - p.gitignore - p.go - p.gomod - p.gosum - p.groovy - p.haskell - p.haskell_persistent - p.hyprlang - p.html - p.ini - p.java - p.javascript - p.jq - p.jsdoc - p.json - p.json5 - p.jsonc - p.jsonnet - p.kotlin - p.latex - p.lua - p.luadoc - p.make - p.markdown - p.meson - p.ninja - p.nix - p.passwd - p.perl - p.php - p.phpdoc - p.properties - p.python - p.rasi - p.regex - p.requirements - p.ruby - p.rust - p.scss - p.sql - p.ssh_config - p.toml - p.todotxt - p.typescript - p.udev - p.vim - p.vimdoc - p.vue - p.xml - p.yaml - ]); - } ]; }; }; diff --git a/common/home/neovim/plugins/treesitter.vim b/common/home/neovim/plugins/treesitter.vim deleted file mode 100644 index fbabedb..0000000 --- a/common/home/neovim/plugins/treesitter.vim +++ /dev/null @@ -1,21 +0,0 @@ -lua << EOF - -require('nvim-treesitter.configs').setup({ - highlight = { enable = true }, - indent = { enable = true }, -}) - -require('treesitter-context').setup({ - enable = true, - max_lines = 3, - min_window_height = 20, -}) - -vim.filetype.add({ - pattern = { [".*/hypr/.*%.conf"] = "hyprlang" }, -}) - -EOF - -" Add line under context -hi TreesitterContextBottom gui=underline guisp=Grey diff --git a/common/home/neovim/treesitter.nix b/common/home/neovim/treesitter.nix new file mode 100644 index 0000000..18a0c04 --- /dev/null +++ b/common/home/neovim/treesitter.nix @@ -0,0 +1,119 @@ +{pkgs, ...}: let + inherit (pkgs) vimPlugins; +in { + programs = { + neovim = { + plugins = [ + { + plugin = vimPlugins.nvim-treesitter-context; + type = "lua"; + config = + /* + lua + */ + '' + require('treesitter-context').setup({ + enable = true, + max_lines = 3, + min_window_height = 20, + }); + + vim.cmd( + 'hi TreesitterContextBottom gui=underline guisp=Grey' + ); + ''; + } + + vimPlugins.nvim-treesitter-textobjects + + { + type = "lua"; + config = + /* + lua + */ + '' + require('nvim-treesitter.configs').setup({ + highlight = { enable = true }, + indent = { enable = true }, + }); + + vim.filetype.add({ + pattern = { [".*/hypr/.*%.conf"] = "hyprlang" }, + }); + ''; + plugin = vimPlugins.nvim-treesitter.withPlugins (p: [ + p.awk + p.bash + p.c + p.c_sharp + p.cairo + p.cmake + p.comment + p.cpp + p.css + p.csv + p.cuda + p.diff + p.dockerfile + p.dot + p.git_config + p.git_rebase + p.gitattributes + p.gitcommit + p.gitignore + p.go + p.gomod + p.gosum + p.groovy + p.haskell + p.haskell_persistent + p.hyprlang + p.html + p.ini + p.java + p.javascript + p.jq + p.jsdoc + p.json + p.json5 + p.jsonc + p.jsonnet + p.kotlin + p.latex + p.lua + p.luadoc + p.make + p.markdown + p.meson + p.ninja + p.nix + p.passwd + p.perl + p.php + p.phpdoc + p.properties + p.python + p.rasi + p.regex + p.requirements + p.ruby + p.rust + p.scss + p.sql + p.ssh_config + p.toml + p.todotxt + p.typescript + p.udev + p.vim + p.vimdoc + p.vue + p.xml + p.yaml + ]); + } + ]; + }; + }; +}