-
Is it possible to add custom grammars for I see |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Hello !
grammarPackages = with config.programs.nixvim.plugins.treesitter.package.builtGrammars; [
bash
c
html
javascript
latex
lua
nix
norg
python
rust
vimdoc
]; This being said, I think that the approach you suggests makes sense. |
Beta Was this translation helpful? Give feedback.
-
My feeling is that everything is fine on the native treesitter side ( |
Beta Was this translation helpful? Give feedback.
-
Here is the config that ended up working for me: # Automatically set the filetype of "*.nu" files to "nu".
filetype.extension.nu = "nu";
# Tell nvim-treesitter to use the "nu" parser for filetype "nu".
extraConfigLua = ''
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.nu = {
filetype = "nu",
}
'';
plugins.treesitter = {
enable = true;
languageRegister.nu = "nu";
grammarPackages = [
(
pkgs.tree-sitter.buildGrammar {
language = "nu";
version = "0.0.0+786689b";
src = pkgs.fetchFromGitHub {
owner = "nushell";
repo = "tree-sitter-nu";
rev = "786689b0562b9799ce53e824cb45a1a2a04dc673";
hash = "sha256-ENyK0l2KhhNfyuXCz0faLwVHMJjJxlRCqitJkJ8fD+w=";
};
}
)
];
}; I say that it "works" because Things might be worth to upstream:
|
Beta Was this translation helpful? Give feedback.
-
Ok, with the parser working I did some digging and I can see that Here is the fully working solution I have: # treesitter.nix
{pkgs, ...}: let
tree-sitter-nu = pkgs.callPackage ./grammars/nushell.nix {inherit (pkgs.tree-sitter) buildGrammar;};
in {
plugins.treesitter = {
enable = true;
languageRegister.nu = "nu";
grammarPackages =
pkgs.vimPlugins.nvim-treesitter.passthru.allGrammars
++ [tree-sitter-nu];
};
extraFiles = {
"queries/nu/highlights.scm" = builtins.readFile "${tree-sitter-nu}/queries/highlights.scm";
"queries/nu/injections.scm" = builtins.readFile "${tree-sitter-nu}/queries/injections.scm";
};
filetype.extension.nu = "nu";
extraConfigLua = ''
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.nu = {
filetype = "nu",
}
'';
} # nushell.nix
{
fetchFromGitHub,
buildGrammar,
}:
buildGrammar {
language = "nu";
version = "0.0.0+786689b";
src = fetchFromGitHub {
owner = "nushell";
repo = "tree-sitter-nu";
rev = "786689b0562b9799ce53e824cb45a1a2a04dc673";
hash = "sha256-ENyK0l2KhhNfyuXCz0faLwVHMJjJxlRCqitJkJ8fD+w=";
};
} Thanks a lot for your help @GaetanLepage. The all-white text has been extremely fatiguing! |
Beta Was this translation helpful? Give feedback.
Ok, with the parser working I did some digging and I can see that
extraFiles
can be used to add files toruntimepath
. I can grab those.scm
files from the derivation and add them usingextraFiles
, which will enable those features (highlights, folds, etc...).Here is the fully working solution I have: