From 05adc8a22150a716f1dbd8fb08d79671032a106e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 9 Jul 2023 17:22:41 -0600 Subject: [PATCH] add custom treesitter grammars --- flake.nix | 2 +- modules/common/neovim/config/syntax.nix | 5 ++- modules/common/neovim/lua/settings.lua | 2 +- overlays/tree-sitter-bash.nix | 16 --------- overlays/tree-sitter.nix | 47 +++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 19 deletions(-) delete mode 100644 overlays/tree-sitter-bash.nix create mode 100644 overlays/tree-sitter.nix diff --git a/flake.nix b/flake.nix index 8cf02a2..e2c04fb 100644 --- a/flake.nix +++ b/flake.nix @@ -144,7 +144,7 @@ (import ./overlays/neovim-plugins.nix inputs) (import ./overlays/calibre-web.nix) (import ./overlays/disko.nix inputs) - (import ./overlays/tree-sitter-bash.nix) + (import ./overlays/tree-sitter.nix inputs) ]; # System types to support. diff --git a/modules/common/neovim/config/syntax.nix b/modules/common/neovim/config/syntax.nix index 04c8964..4072373 100644 --- a/modules/common/neovim/config/syntax.nix +++ b/modules/common/neovim/config/syntax.nix @@ -6,12 +6,15 @@ tree-sitter-bash tree-sitter-fish tree-sitter-hcl + tree-sitter-ini tree-sitter-json tree-sitter-lua tree-sitter-markdown tree-sitter-markdown-inline tree-sitter-nix + tree-sitter-puppet tree-sitter-python + tree-sitter-rasi tree-sitter-toml tree-sitter-yaml ])) @@ -19,7 +22,6 @@ pkgs.vimPlugins.playground # Tree-sitter experimenting pkgs.vimPlugins.nginx-vim pkgs.vimPlugins.vim-helm - pkgs.vimPlugins.vim-puppet (pkgs.vimUtils.buildVimPluginFrom2Nix { pname = "nmasur"; version = "0.1"; @@ -30,6 +32,7 @@ setup."nvim-treesitter.configs" = { highlight = { enable = true; }; indent = { enable = true; }; + matchup = { enable = true; }; # Uses vim-matchup textobjects = { select = { diff --git a/modules/common/neovim/lua/settings.lua b/modules/common/neovim/lua/settings.lua index fb6a244..dd5e34d 100644 --- a/modules/common/neovim/lua/settings.lua +++ b/modules/common/neovim/lua/settings.lua @@ -6,7 +6,7 @@ vim.filetype.add({ pattern = { [".*%.tfvars"] = "terraform", [".*%.tf"] = "terraform", - [".*%.rasi"] = "css", + [".*%.rasi"] = "rasi", }, }) diff --git a/overlays/tree-sitter-bash.nix b/overlays/tree-sitter-bash.nix deleted file mode 100644 index 911b063..0000000 --- a/overlays/tree-sitter-bash.nix +++ /dev/null @@ -1,16 +0,0 @@ -# Fix: bash highlighting doesn't work as of this commit: -# https://github.com/NixOS/nixpkgs/commit/49cce41b7c5f6b88570a482355d9655ca19c1029 - -_final: prev: { - tree-sitter-grammars = prev.tree-sitter-grammars // { - tree-sitter-bash = prev.tree-sitter-grammars.tree-sitter-bash.overrideAttrs - (old: { - src = prev.fetchFromGitHub { - owner = "tree-sitter"; - repo = "tree-sitter-bash"; - rev = "493646764e7ad61ce63ce3b8c59ebeb37f71b841"; - sha256 = "sha256-gl5F3IeZa2VqyH/qFj8ey2pRbGq4X8DL5wiyvRrH56U="; - }; - }); - }; -} diff --git a/overlays/tree-sitter.nix b/overlays/tree-sitter.nix new file mode 100644 index 0000000..3c9d810 --- /dev/null +++ b/overlays/tree-sitter.nix @@ -0,0 +1,47 @@ +# Fix: bash highlighting doesn't work as of this commit: +# https://github.com/NixOS/nixpkgs/commit/49cce41b7c5f6b88570a482355d9655ca19c1029 + +inputs: _final: prev: { + tree-sitter-grammars = prev.tree-sitter-grammars // { + tree-sitter-bash = prev.tree-sitter-grammars.tree-sitter-bash.overrideAttrs + (old: { + src = prev.fetchFromGitHub { + owner = "tree-sitter"; + repo = "tree-sitter-bash"; + rev = "493646764e7ad61ce63ce3b8c59ebeb37f71b841"; + sha256 = "sha256-gl5F3IeZa2VqyH/qFj8ey2pRbGq4X8DL5wiyvRrH56U="; + }; + }); + tree-sitter-ini = prev.tree-sitter.buildGrammar { + language = "ini"; + version = "1.0.0"; + src = prev.fetchFromGitHub { + owner = "justinmk"; + repo = "tree-sitter-ini"; + rev = "1a0ce072ebf3afac7d5603d9a95bb7c9a6709b44"; + sha256 = "sha256-pPtKokpTgjoNzPW4dRkOnyzBBJFeJj3+CW3LbHSKsmU="; + }; + }; + tree-sitter-puppet = prev.tree-sitter.buildGrammar { + language = "puppet"; + version = "1.0.0"; + src = prev.fetchFromGitHub { + owner = "amaanq"; + repo = "tree-sitter-puppet"; + rev = "v1.0.0"; + sha256 = "sha256-vk5VJZ9zW2bBuc+DM+fwFyhM1htZGeLlmkjMAH66jBA="; + }; + }; + tree-sitter-rasi = prev.tree-sitter.buildGrammar { + language = "rasi"; + version = "0.1.1"; + src = prev.fetchFromGitHub { + owner = "Fymyte"; + repo = "tree-sitter-rasi"; + rev = "371dac6bcce0df5566c1cfebde69d90ecbeefd2d"; + sha256 = "sha256-2nYZoLcrxxxiOJEySwHUm93lzMg8mU+V7LIP63ntFdA="; + }; + }; + }; + +}