From 6cbd28148aeaab79071b49d57d900ab7260596be Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Thu, 7 Nov 2024 21:00:06 +0100 Subject: [PATCH] nvim: move treesitter to separate file --- home/common/nvim/default.nix | 93 ++------------------------------- home/common/nvim/treesitter.nix | 79 ++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 90 deletions(-) create mode 100644 home/common/nvim/treesitter.nix diff --git a/home/common/nvim/default.nix b/home/common/nvim/default.nix index 5e3ef01..fde0dd9 100644 --- a/home/common/nvim/default.nix +++ b/home/common/nvim/default.nix @@ -5,6 +5,9 @@ ... }: { + imports = [ + ./treesitter.nix + ]; programs.man.generateCaches = false; @@ -39,35 +42,6 @@ shellcheck shfmt stylua - tree-sitter - tree-sitter-grammars.tree-sitter-bash - tree-sitter-grammars.tree-sitter-c - tree-sitter-grammars.tree-sitter-comment - tree-sitter-grammars.tree-sitter-css - tree-sitter-grammars.tree-sitter-cue - tree-sitter-grammars.tree-sitter-fish - tree-sitter-grammars.tree-sitter-gdscript - tree-sitter-grammars.tree-sitter-go - tree-sitter-grammars.tree-sitter-gomod - tree-sitter-grammars.tree-sitter-hcl - tree-sitter-grammars.tree-sitter-html - tree-sitter-grammars.tree-sitter-javascript - tree-sitter-grammars.tree-sitter-json - tree-sitter-grammars.tree-sitter-lua - tree-sitter-grammars.tree-sitter-markdown - tree-sitter-grammars.tree-sitter-nix - tree-sitter-grammars.tree-sitter-proto - tree-sitter-grammars.tree-sitter-rego - tree-sitter-grammars.tree-sitter-rust - tree-sitter-grammars.tree-sitter-scss - tree-sitter-grammars.tree-sitter-sql - tree-sitter-grammars.tree-sitter-svelte - tree-sitter-grammars.tree-sitter-toml - tree-sitter-grammars.tree-sitter-tsx - tree-sitter-grammars.tree-sitter-typescript - tree-sitter-grammars.tree-sitter-vim - tree-sitter-grammars.tree-sitter-yaml - tree-sitter-grammars.tree-sitter-zig vscode-langservers-extracted ]; @@ -141,67 +115,6 @@ ''; } - { - plugin = nvim-treesitter-context; - type = "lua"; - config = '' - require'treesitter-context'.setup{ - enable = false, - } - - vim.keymap.set('n', 'ut', "TSContextToggle", {noremap = true, silent = true, desc = "TS Context"}) - ''; - } - - { - plugin = nvim-treesitter.withAllGrammars; - type = "lua"; - config = '' - require'nvim-treesitter.configs'.setup { - highlight = { enable = true, }, - indent = { enable = true }, - textobjects = { - select = { - enable = true, - lookahead = true, - }, - }, - } - ''; - } - - { - plugin = pkgs.vimUtils.buildVimPlugin { - name = "nvim-tree-pairs"; # make % match in TS - src = pkgs.fetchFromGitHub { - owner = "yorickpeterse"; - repo = "nvim-tree-pairs"; - rev = "e7f7b6cc28dda6f3fa271ce63b0d371d5b7641da"; - hash = "sha256-fb4EsrWAbm8+dWAhiirCPuR44MEg+KYb9hZOIuEuT24="; - }; - }; - type = "lua"; - config = "require('tree-pairs').setup()"; - } - - { - plugin = nvim-treesitter-textobjects; - type = "lua"; - config = '' - require'nvim-treesitter.configs'.setup { - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - scope_incremental = "", - node_incremental = "", - node_decremental = "", - }, - }, - } - ''; - } - { plugin = mini-nvim; type = "lua"; diff --git a/home/common/nvim/treesitter.nix b/home/common/nvim/treesitter.nix new file mode 100644 index 0000000..4fb87ec --- /dev/null +++ b/home/common/nvim/treesitter.nix @@ -0,0 +1,79 @@ +{ + inputs, + lib, + pkgs, + ... +}: +{ + programs.neovim = { + extraPackages = with pkgs; [ + tree-sitter + ]; + + plugins = with pkgs.vimPlugins; [ + ts-comments-nvim + nvim-ts-context-commentstring + + { + plugin = nvim-treesitter-context; + type = "lua"; + config = '' + require'treesitter-context'.setup{ + enable = false, + } + vim.keymap.set('n', 'ut', "TSContextToggle", {noremap = true, silent = true, desc = "TS Context"}) + ''; + } + + { + plugin = nvim-treesitter.withAllGrammars; + type = "lua"; + config = '' + require'nvim-treesitter.configs'.setup { + highlight = { enable = true, }, + indent = { enable = true }, + rainbow = { enable = true }, + textobjects = { + select = { + enable = true, + lookahead = true, + }, + }, + } + ''; + } + + { + plugin = pkgs.vimUtils.buildVimPlugin { + name = "nvim-tree-pairs"; # make % match in TS + src = pkgs.fetchFromGitHub { + owner = "yorickpeterse"; + repo = "nvim-tree-pairs"; + rev = "e7f7b6cc28dda6f3fa271ce63b0d371d5b7641da"; + hash = "sha256-fb4EsrWAbm8+dWAhiirCPuR44MEg+KYb9hZOIuEuT24="; + }; + }; + type = "lua"; + config = "require('tree-pairs').setup()"; + } + + { + plugin = nvim-treesitter-textobjects; + type = "lua"; + config = '' + require'nvim-treesitter.configs'.setup { + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + scope_incremental = "", + node_incremental = "", + node_decremental = "", + }, + }, + } + ''; + } + ]; + }; +}