mirror of
https://github.com/iofq/nvim-treesitter-main.git
synced 2026-01-23 01:15:17 -06:00
Compare commits
2 commits
c8b4d718be
...
2fdf59a63d
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fdf59a63d | |||
| 976859670c |
5 changed files with 428 additions and 6 deletions
6
.github/workflows/main.yaml
vendored
6
.github/workflows/main.yaml
vendored
|
|
@ -9,6 +9,12 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/flakehub-cache-action@main
|
||||
- uses: cachix/cachix-action@master
|
||||
if: github.ref == 'refs/heads/master'
|
||||
with:
|
||||
name: nvim-treesitter-main
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
|
||||
- run: nix flake check
|
||||
- run: nix run nixpkgs#nixfmt **/*.nix
|
||||
|
||||
|
|
|
|||
18
README.md
18
README.md
|
|
@ -69,6 +69,24 @@ overlays = [
|
|||
|
||||
If you need the unpatched `nvim-treesitter` plugin without any parsers/queries bundled, even after you overlay it, you can use the `nvim-treesitter-unwrapped` output of this overlay.
|
||||
|
||||
## Cache
|
||||
|
||||
Add our `cachix` repo to avoid needing to build grammars locally.
|
||||
|
||||
```nix
|
||||
nix = {
|
||||
settings = {
|
||||
substituters = [
|
||||
"https://nvim-treesitter-main.cachix.org"
|
||||
];
|
||||
trusted-public-keys = [
|
||||
"nvim-treesitter-main.cachix.org-1:cbwE6blfW5+BkXXyeAXoVSu1gliqPLHo2m98E4hWfZQ="
|
||||
];
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
## Updating
|
||||
|
||||
To update the list of parsers in `generated.nix`:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,15 @@
|
|||
local function table_to_nix(t)
|
||||
local entries = {}
|
||||
for _, s in ipairs(t) do
|
||||
table.insert(entries, string.format('"%s"', s))
|
||||
end
|
||||
return string.format("[ %s ]", table.concat(entries, " "))
|
||||
end
|
||||
|
||||
local function fmt_grammar(grammar)
|
||||
local lines = {
|
||||
string.format('%s = buildGrammar {', grammar.language),
|
||||
string.format('passthru.name = "%s";', grammar.language),
|
||||
string.format('language = "%s";', grammar.language),
|
||||
string.format('version = "%s";', grammar.version),
|
||||
string.format('src = %s;', grammar.src),
|
||||
|
|
@ -8,6 +17,10 @@ local function fmt_grammar(grammar)
|
|||
}
|
||||
if grammar.generate then table.insert(lines, string.format('generate = %s;', grammar.generate)) end
|
||||
if grammar.location then table.insert(lines, string.format('location = "%s";', grammar.location)) end
|
||||
if grammar.requires then table.insert(
|
||||
lines,
|
||||
string.format('requires = %s;', table_to_nix(grammar.requires))
|
||||
) end
|
||||
|
||||
table.insert(lines, "};")
|
||||
return table.concat(lines, "\n")
|
||||
|
|
@ -42,7 +55,9 @@ local function generate_grammars(g)
|
|||
if p.install_info.location then
|
||||
grammar.location = p.install_info.location
|
||||
end
|
||||
|
||||
if p.requires then
|
||||
grammar.requires = p.requires
|
||||
end
|
||||
table.insert(output, fmt_grammar(grammar))
|
||||
end
|
||||
end
|
||||
|
|
|
|||
371
generated.nix
371
generated.nix
File diff suppressed because it is too large
Load diff
22
overlay.nix
22
overlay.nix
|
|
@ -48,19 +48,31 @@ let
|
|||
f:
|
||||
let
|
||||
grammars = (f (tree-sitter.builtGrammars // builtGrammars));
|
||||
grammarNames = lib.concatStringsSep " " (
|
||||
map (g: builtins.elemAt (builtins.split "-" g.name) 0) grammars
|
||||
);
|
||||
|
||||
# Grammars that are required by a provided grammar
|
||||
required = lib.unique (lib.concatLists (map (g: g.requires or [ ]) grammars));
|
||||
|
||||
# Append grammars from required that exist in builtGrammars (they actually have a parser)
|
||||
# Need to split these out as some "requires" elements from parsers.lua are just queries
|
||||
# from nvim-treesitter/runtime/queries
|
||||
finalGrammars =
|
||||
grammars
|
||||
++ map (name: builtGrammars.${name}) (
|
||||
builtins.filter (name: builtins.hasAttr name builtGrammars) required
|
||||
);
|
||||
|
||||
runtimeQueries = lib.concatStringsSep " " ((map (g: g.passthru.name) grammars) ++ required);
|
||||
|
||||
bundle = pkgs.symlinkJoin {
|
||||
name = "nvim-treesitter-bundle";
|
||||
paths = map grammarToPlugin grammars;
|
||||
paths = map grammarToPlugin finalGrammars;
|
||||
};
|
||||
in
|
||||
final.vimPlugins.nvim-treesitter-unwrapped.overrideAttrs (old: {
|
||||
postInstall = old.postInstall + ''
|
||||
# ensure runtime queries get linked to RTP (:TSInstall does this too)
|
||||
mkdir -p $out/queries
|
||||
for grammar in ${grammarNames}; do
|
||||
for grammar in ${runtimeQueries}; do
|
||||
ln -sfT $src/runtime/queries/$grammar $out/queries/$grammar
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue