Skip to content

tree-sitter-grammars: Enable grammar testing#391520

Open
adfaure wants to merge 8 commits intoNixOS:stagingfrom
ngi-nix:tree-sitter-grammars-activate-tests
Open

tree-sitter-grammars: Enable grammar testing#391520
adfaure wants to merge 8 commits intoNixOS:stagingfrom
ngi-nix:tree-sitter-grammars-activate-tests

Conversation

@adfaure
Copy link
Contributor

@adfaure adfaure commented Mar 20, 2025

Description of changes

Context

While working on #320783 with @fricklerhandwerk. We used tree-sitter-grammars to build Python bindings, we explored ways to test these grammars. We found that the best approach is to use Tree-sitter's dedicated testing framework (documentation).

This PR introduces a check phase using tree-sitter test.

Changes

Activate Grammar Testing

  • pkgs/development/tools/parsing/tree-sitter/grammar.nix:
    Adds a test phase and an isBroken attribute.
  • pkgs/development/tools/parsing/tree-sitter/update_impl.py:
    Runs the tests during the update phase and sets the isBroken attribute if the tests fail.

Update the Emacs Script

  • pkgs/applications/editors/emacs/elisp-packages/manual-packages/tree-sitter-langs/update-defaults.py:
    Emacs has an automated mechanism for updating grammars. This script is updated to use the isBroken flag.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: emacs Text editor 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 501-1000 This PR causes many rebuilds on Linux and should normally target the staging branches. labels Mar 20, 2025
@adfaure adfaure marked this pull request as ready for review March 20, 2025 09:17
@adfaure adfaure marked this pull request as draft March 20, 2025 09:18
@adfaure adfaure marked this pull request as ready for review March 20, 2025 09:18
@jian-lin jian-lin requested review from amadaluzia, ambroisie, khaneliman and uncenter and removed request for jian-lin March 20, 2025 15:22
Copy link
Contributor

@ambroisie ambroisie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised the emacs plug-in doesn't seem to do the same as nvim-treesitter (separately locked grammars, specific to the plug-in).

Should we worry about reporting a grammar as broken "just" because some its tests aren't passing, if it builds and actually parses its inputs? I'm kind of surprised at the number of grammars which turned up broken = true here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isBroken = grammar ? isBroken && grammar.isBroken;
isBroken = grammar ? isBroken or false;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isBroken is always false indeed.

 isBroken = grammar ? isBroken;

Copy link
Contributor Author

@adfaure adfaure Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestion raises an error. I am not sure why...

nix-repl> attr = {a=true; b=false;}

nix-repl> (attr ? c) or false
error: undefined variable 'or'
       at «string»:1:1:
            1| (attr ? c) or false
             | ^

nix-repl> attr.a or false
true

Maybe instead: broken = grammar.broken or false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well rename it to broken and inherit it here IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isBroken is always false (since it is generated by the update script), the name indicates that is flagged as broken.
I don't mind changing it to broken.

The reason behind this choice is to avoid updating all the JSON files without a new and unnecessary attribute.

@amadaluzia
Copy link
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 391520


x86_64-linux

⏩ 39 packages marked as broken and skipped:
  • diffsitter
  • lua54Packages.neotest
  • lua54Packages.papis-nvim
  • lua54Packages.sqlite
  • tree-sitter-grammars.tree-sitter-cpp
  • tree-sitter-grammars.tree-sitter-dart
  • tree-sitter-grammars.tree-sitter-eex
  • tree-sitter-grammars.tree-sitter-elisp
  • tree-sitter-grammars.tree-sitter-elixir
  • tree-sitter-grammars.tree-sitter-elm
  • tree-sitter-grammars.tree-sitter-fish
  • tree-sitter-grammars.tree-sitter-gleam
  • tree-sitter-grammars.tree-sitter-glimmer
  • tree-sitter-grammars.tree-sitter-graphql
  • tree-sitter-grammars.tree-sitter-haskell
  • tree-sitter-grammars.tree-sitter-hcl
  • tree-sitter-grammars.tree-sitter-just
  • tree-sitter-grammars.tree-sitter-latex
  • tree-sitter-grammars.tree-sitter-lua
  • tree-sitter-grammars.tree-sitter-make
  • tree-sitter-grammars.tree-sitter-markdown
  • tree-sitter-grammars.tree-sitter-markdown-inline
  • tree-sitter-grammars.tree-sitter-nix
  • tree-sitter-grammars.tree-sitter-norg
  • tree-sitter-grammars.tree-sitter-perl
  • tree-sitter-grammars.tree-sitter-r
  • tree-sitter-grammars.tree-sitter-river
  • tree-sitter-grammars.tree-sitter-scss
  • tree-sitter-grammars.tree-sitter-solidity
  • tree-sitter-grammars.tree-sitter-sparql
  • tree-sitter-grammars.tree-sitter-sql
  • tree-sitter-grammars.tree-sitter-tiger
  • tree-sitter-grammars.tree-sitter-tsq
  • tree-sitter-grammars.tree-sitter-typst
  • tree-sitter-grammars.tree-sitter-vim
  • tree-sitter-grammars.tree-sitter-vue
  • tree-sitter-grammars.tree-sitter-wing
  • tree-sitter-grammars.tree-sitter-yaml
  • vimPlugins.one-nvim
❌ 503 packages failed to build:
  • gnvim
  • lua51Packages.fzf-lua
  • lua51Packages.haskell-tools-nvim
  • lua51Packages.lualine-nvim
  • lua51Packages.lz-n
  • lua51Packages.lze
  • lua51Packages.lzextras
  • lua51Packages.lzn-auto-require
  • lua51Packages.neorg
  • lua51Packages.neotest
  • lua51Packages.nlua
  • lua51Packages.nvim-nio
  • lua51Packages.papis-nvim
  • lua51Packages.pathlib-nvim
  • lua51Packages.rest-nvim
  • lua51Packages.rocks-config-nvim
  • lua51Packages.rocks-dev-nvim
  • lua51Packages.rocks-git-nvim
  • lua51Packages.rocks-nvim
  • lua51Packages.rtp-nvim
  • lua51Packages.rustaceanvim
  • lua51Packages.sqlite
  • luaPackages.fzf-lua (lua52Packages.fzf-lua)
  • luaPackages.neotest (lua52Packages.neotest)
  • luaPackages.nlua (lua52Packages.nlua)
  • luaPackages.papis-nvim (lua52Packages.papis-nvim)
  • luaPackages.sqlite (lua52Packages.sqlite)
  • lua53Packages.fzf-lua
  • lua53Packages.neotest
  • lua53Packages.nlua
  • lua53Packages.papis-nvim
  • lua53Packages.sqlite
  • lua54Packages.fzf-lua
  • lua54Packages.nlua
  • luajitPackages.fzf-lua
  • luajitPackages.haskell-tools-nvim
  • luajitPackages.lualine-nvim
  • luajitPackages.lz-n
  • luajitPackages.lze
  • luajitPackages.lzextras
  • luajitPackages.lzn-auto-require
  • luajitPackages.neorg
  • luajitPackages.neotest
  • luajitPackages.nlua
  • luajitPackages.nvim-nio
  • luajitPackages.papis-nvim
  • luajitPackages.pathlib-nvim
  • luajitPackages.rest-nvim
  • luajitPackages.rocks-config-nvim
  • luajitPackages.rocks-dev-nvim
  • luajitPackages.rocks-git-nvim
  • luajitPackages.rocks-nvim
  • luajitPackages.rtp-nvim
  • luajitPackages.rustaceanvim
  • luajitPackages.sqlite
  • lunarvim
  • neovide
  • neovim-qt
  • neovim-qt-unwrapped
  • neovim-remote
  • neovim-remote.dist
  • neovim-unwrapped
  • neovim-unwrapped.debug
  • nvimpager
  • panvimdoc
  • spacevim
  • tests.vim.test_vim_with_vim_nix
  • tests.vim.test_vim_with_vim_nix_using_plug
  • vim-startuptime
  • vimPlugins.LanguageClient-neovim
  • vimPlugins.Spacegray-vim
  • vimPlugins.VimCompletesMe
  • vimPlugins.YouCompleteMe
  • vimPlugins.avante-nvim
  • vimPlugins.barbecue-nvim
  • vimPlugins.bitbake-vim
  • vimPlugins.blink-cmp
  • vimPlugins.blink-pairs
  • vimPlugins.bufresize-nvim
  • vimPlugins.clangd_extensions-nvim
  • vimPlugins.cmp-async-path
  • vimPlugins.coc-clangd
  • vimPlugins.coc-cmake
  • vimPlugins.coc-css
  • vimPlugins.coc-diagnostic
  • vimPlugins.coc-docker
  • vimPlugins.coc-emmet
  • vimPlugins.coc-eslint
  • vimPlugins.coc-explorer
  • vimPlugins.coc-flutter
  • vimPlugins.coc-git
  • vimPlugins.coc-go
  • vimPlugins.coc-haxe
  • vimPlugins.coc-highlight
  • vimPlugins.coc-html
  • vimPlugins.coc-java
  • vimPlugins.coc-jest
  • vimPlugins.coc-json
  • vimPlugins.coc-lists
  • vimPlugins.coc-ltex
  • vimPlugins.coc-markdownlint
  • vimPlugins.coc-nginx
  • vimPlugins.coc-pairs
  • vimPlugins.coc-prettier
  • vimPlugins.coc-pyright
  • vimPlugins.coc-r-lsp
  • vimPlugins.coc-rls
  • vimPlugins.coc-rust-analyzer
  • vimPlugins.coc-sh
  • vimPlugins.coc-smartf
  • vimPlugins.coc-snippets
  • vimPlugins.coc-solargraph
  • vimPlugins.coc-spell-checker
  • vimPlugins.coc-sqlfluff
  • vimPlugins.coc-stylelint
  • vimPlugins.coc-sumneko-lua
  • vimPlugins.coc-tabnine
  • vimPlugins.coc-texlab
  • vimPlugins.coc-toml
  • vimPlugins.coc-tsserver
  • vimPlugins.coc-ultisnips
  • vimPlugins.coc-vetur
  • vimPlugins.coc-vimlsp
  • vimPlugins.coc-vimtex
  • vimPlugins.coc-wxml
  • vimPlugins.coc-yaml
  • vimPlugins.coc-yank
  • vimPlugins.codesnap-nvim
  • vimPlugins.cord-nvim
  • vimPlugins.corePlugins
  • vimPlugins.deoplete-khard
  • vimPlugins.fcitx-vim
  • vimPlugins.fzf-lua
  • vimPlugins.fzfWrapper
  • vimPlugins.gitlab-vim
  • vimPlugins.hare-vim
  • vimPlugins.haskell-tools-nvim
  • vimPlugins.hurl
  • vimPlugins.image-nvim
  • vimPlugins.jedi-vim
  • vimPlugins.lsp_lines-nvim
  • vimPlugins.lspecho-nvim
  • vimPlugins.lualine-nvim
  • vimPlugins.lz-n
  • vimPlugins.lze
  • vimPlugins.lzextras
  • vimPlugins.lzn-auto-require
  • vimPlugins.meson
  • vimPlugins.minsnip-nvim
  • vimPlugins.moveline-nvim
  • vimPlugins.neorg
  • vimPlugins.neotest
  • vimPlugins.nvim-dbee
  • vimPlugins.nvim-julia-autotest
  • vimPlugins.nvim-nio
  • vimPlugins.nvim-spectre
  • vimPlugins.nvim-treesitter-parsers.ada
  • vimPlugins.nvim-treesitter-parsers.agda
  • vimPlugins.nvim-treesitter-parsers.angular
  • vimPlugins.nvim-treesitter-parsers.apex
  • vimPlugins.nvim-treesitter-parsers.arduino
  • vimPlugins.nvim-treesitter-parsers.asm
  • vimPlugins.nvim-treesitter-parsers.astro
  • vimPlugins.nvim-treesitter-parsers.authzed
  • vimPlugins.nvim-treesitter-parsers.awk
  • vimPlugins.nvim-treesitter-parsers.bash
  • vimPlugins.nvim-treesitter-parsers.bass
  • vimPlugins.nvim-treesitter-parsers.beancount
  • vimPlugins.nvim-treesitter-parsers.bibtex
  • vimPlugins.nvim-treesitter-parsers.bicep
  • vimPlugins.nvim-treesitter-parsers.bitbake
  • vimPlugins.nvim-treesitter-parsers.blade
  • vimPlugins.nvim-treesitter-parsers.blueprint
  • vimPlugins.nvim-treesitter-parsers.bp
  • vimPlugins.nvim-treesitter-parsers.c
  • vimPlugins.nvim-treesitter-parsers.c_sharp
  • vimPlugins.nvim-treesitter-parsers.cairo
  • vimPlugins.nvim-treesitter-parsers.capnp
  • vimPlugins.nvim-treesitter-parsers.chatito
  • vimPlugins.nvim-treesitter-parsers.circom
  • vimPlugins.nvim-treesitter-parsers.clojure
  • vimPlugins.nvim-treesitter-parsers.cmake
  • vimPlugins.nvim-treesitter-parsers.comment
  • vimPlugins.nvim-treesitter-parsers.commonlisp
  • vimPlugins.nvim-treesitter-parsers.cooklang
  • vimPlugins.nvim-treesitter-parsers.corn
  • vimPlugins.nvim-treesitter-parsers.cpon
  • vimPlugins.nvim-treesitter-parsers.cpp
  • vimPlugins.nvim-treesitter-parsers.css
  • vimPlugins.nvim-treesitter-parsers.csv
  • vimPlugins.nvim-treesitter-parsers.cuda
  • vimPlugins.nvim-treesitter-parsers.cue
  • vimPlugins.nvim-treesitter-parsers.cylc
  • vimPlugins.nvim-treesitter-parsers.d
  • vimPlugins.nvim-treesitter-parsers.dart
  • vimPlugins.nvim-treesitter-parsers.desktop
  • vimPlugins.nvim-treesitter-parsers.devicetree
  • vimPlugins.nvim-treesitter-parsers.dhall
  • vimPlugins.nvim-treesitter-parsers.diff
  • vimPlugins.nvim-treesitter-parsers.disassembly
  • vimPlugins.nvim-treesitter-parsers.djot
  • vimPlugins.nvim-treesitter-parsers.dockerfile
  • vimPlugins.nvim-treesitter-parsers.dot
  • vimPlugins.nvim-treesitter-parsers.doxygen
  • vimPlugins.nvim-treesitter-parsers.dtd
  • vimPlugins.nvim-treesitter-parsers.earthfile
  • vimPlugins.nvim-treesitter-parsers.ebnf
  • vimPlugins.nvim-treesitter-parsers.editorconfig
  • vimPlugins.nvim-treesitter-parsers.eds
  • vimPlugins.nvim-treesitter-parsers.eex
  • vimPlugins.nvim-treesitter-parsers.elixir
  • vimPlugins.nvim-treesitter-parsers.elm
  • vimPlugins.nvim-treesitter-parsers.elsa
  • vimPlugins.nvim-treesitter-parsers.elvish
  • vimPlugins.nvim-treesitter-parsers.embedded_template
  • vimPlugins.nvim-treesitter-parsers.enforce
  • vimPlugins.nvim-treesitter-parsers.erlang
  • vimPlugins.nvim-treesitter-parsers.facility
  • vimPlugins.nvim-treesitter-parsers.faust
  • vimPlugins.nvim-treesitter-parsers.fennel
  • vimPlugins.nvim-treesitter-parsers.fidl
  • vimPlugins.nvim-treesitter-parsers.firrtl
  • vimPlugins.nvim-treesitter-parsers.fish
  • vimPlugins.nvim-treesitter-parsers.foam
  • vimPlugins.nvim-treesitter-parsers.forth
  • vimPlugins.nvim-treesitter-parsers.fortran
  • vimPlugins.nvim-treesitter-parsers.fsh
  • vimPlugins.nvim-treesitter-parsers.fsharp
  • vimPlugins.nvim-treesitter-parsers.func
  • vimPlugins.nvim-treesitter-parsers.fusion
  • vimPlugins.nvim-treesitter-parsers.gap
  • vimPlugins.nvim-treesitter-parsers.gaptst
  • vimPlugins.nvim-treesitter-parsers.gdscript
  • vimPlugins.nvim-treesitter-parsers.gdshader
  • vimPlugins.nvim-treesitter-parsers.git_config
  • vimPlugins.nvim-treesitter-parsers.git_rebase
  • vimPlugins.nvim-treesitter-parsers.gitattributes
  • vimPlugins.nvim-treesitter-parsers.gitcommit
  • vimPlugins.nvim-treesitter-parsers.gitignore
  • vimPlugins.nvim-treesitter-parsers.gleam
  • vimPlugins.nvim-treesitter-parsers.glimmer
  • vimPlugins.nvim-treesitter-parsers.glimmer_javascript
  • vimPlugins.nvim-treesitter-parsers.glimmer_typescript
  • vimPlugins.nvim-treesitter-parsers.glsl
  • vimPlugins.nvim-treesitter-parsers.gn
  • vimPlugins.nvim-treesitter-parsers.gnuplot
  • vimPlugins.nvim-treesitter-parsers.go
  • vimPlugins.nvim-treesitter-parsers.goctl
  • vimPlugins.nvim-treesitter-parsers.godot_resource
  • vimPlugins.nvim-treesitter-parsers.gomod
  • vimPlugins.nvim-treesitter-parsers.gosum
  • vimPlugins.nvim-treesitter-parsers.gotmpl
  • vimPlugins.nvim-treesitter-parsers.gowork
  • vimPlugins.nvim-treesitter-parsers.gpg
  • vimPlugins.nvim-treesitter-parsers.graphql
  • vimPlugins.nvim-treesitter-parsers.gren
  • vimPlugins.nvim-treesitter-parsers.groovy
  • vimPlugins.nvim-treesitter-parsers.gstlaunch
  • vimPlugins.nvim-treesitter-parsers.hack
  • vimPlugins.nvim-treesitter-parsers.hare
  • vimPlugins.nvim-treesitter-parsers.haskell
  • vimPlugins.nvim-treesitter-parsers.haskell_persistent
  • vimPlugins.nvim-treesitter-parsers.hcl
  • vimPlugins.nvim-treesitter-parsers.heex
  • vimPlugins.nvim-treesitter-parsers.helm
  • vimPlugins.nvim-treesitter-parsers.hjson
  • vimPlugins.nvim-treesitter-parsers.hlsl
  • vimPlugins.nvim-treesitter-parsers.hlsplaylist
  • vimPlugins.nvim-treesitter-parsers.hocon
  • vimPlugins.nvim-treesitter-parsers.hoon
  • vimPlugins.nvim-treesitter-parsers.html
  • vimPlugins.nvim-treesitter-parsers.htmldjango
  • vimPlugins.nvim-treesitter-parsers.http
  • vimPlugins.nvim-treesitter-parsers.hurl
  • vimPlugins.nvim-treesitter-parsers.hyprlang
  • vimPlugins.nvim-treesitter-parsers.idl
  • vimPlugins.nvim-treesitter-parsers.idris
  • vimPlugins.nvim-treesitter-parsers.ini
  • vimPlugins.nvim-treesitter-parsers.inko
  • vimPlugins.nvim-treesitter-parsers.ipkg
  • vimPlugins.nvim-treesitter-parsers.ispc
  • vimPlugins.nvim-treesitter-parsers.janet_simple
  • vimPlugins.nvim-treesitter-parsers.java
  • vimPlugins.nvim-treesitter-parsers.javascript
  • vimPlugins.nvim-treesitter-parsers.jinja
  • vimPlugins.nvim-treesitter-parsers.jinja_inline
  • vimPlugins.nvim-treesitter-parsers.jq
  • vimPlugins.nvim-treesitter-parsers.jsdoc
  • vimPlugins.nvim-treesitter-parsers.json
  • vimPlugins.nvim-treesitter-parsers.json5
  • vimPlugins.nvim-treesitter-parsers.jsonc
  • vimPlugins.nvim-treesitter-parsers.jsonnet
  • vimPlugins.nvim-treesitter-parsers.julia
  • vimPlugins.nvim-treesitter-parsers.just
  • vimPlugins.nvim-treesitter-parsers.kcl
  • vimPlugins.nvim-treesitter-parsers.kconfig
  • vimPlugins.nvim-treesitter-parsers.kdl
  • vimPlugins.nvim-treesitter-parsers.kotlin
  • vimPlugins.nvim-treesitter-parsers.koto
  • vimPlugins.nvim-treesitter-parsers.kusto
  • vimPlugins.nvim-treesitter-parsers.lalrpop
  • vimPlugins.nvim-treesitter-parsers.latex
  • vimPlugins.nvim-treesitter-parsers.ledger
  • vimPlugins.nvim-treesitter-parsers.leo
  • vimPlugins.nvim-treesitter-parsers.linkerscript
  • vimPlugins.nvim-treesitter-parsers.liquid
  • vimPlugins.nvim-treesitter-parsers.liquidsoap
  • vimPlugins.nvim-treesitter-parsers.llvm
  • vimPlugins.nvim-treesitter-parsers.lua
  • vimPlugins.nvim-treesitter-parsers.luadoc
  • vimPlugins.nvim-treesitter-parsers.luap
  • vimPlugins.nvim-treesitter-parsers.luau
  • vimPlugins.nvim-treesitter-parsers.m68k
  • vimPlugins.nvim-treesitter-parsers.make
  • vimPlugins.nvim-treesitter-parsers.markdown
  • vimPlugins.nvim-treesitter-parsers.markdown_inline
  • vimPlugins.nvim-treesitter-parsers.matlab
  • vimPlugins.nvim-treesitter-parsers.menhir
  • vimPlugins.nvim-treesitter-parsers.mermaid
  • vimPlugins.nvim-treesitter-parsers.meson
  • vimPlugins.nvim-treesitter-parsers.mlir
  • vimPlugins.nvim-treesitter-parsers.muttrc
  • vimPlugins.nvim-treesitter-parsers.nasm
  • vimPlugins.nvim-treesitter-parsers.nginx
  • vimPlugins.nvim-treesitter-parsers.nickel
  • vimPlugins.nvim-treesitter-parsers.nim
  • vimPlugins.nvim-treesitter-parsers.nim_format_string
  • vimPlugins.nvim-treesitter-parsers.ninja
  • vimPlugins.nvim-treesitter-parsers.nix
  • vimPlugins.nvim-treesitter-parsers.norg
  • vimPlugins.nvim-treesitter-parsers.nqc
  • vimPlugins.nvim-treesitter-parsers.nu
  • vimPlugins.nvim-treesitter-parsers.objc
  • vimPlugins.nvim-treesitter-parsers.objdump
  • vimPlugins.nvim-treesitter-parsers.ocaml
  • vimPlugins.nvim-treesitter-parsers.ocaml_interface
  • vimPlugins.nvim-treesitter-parsers.ocamllex
  • vimPlugins.nvim-treesitter-parsers.odin
  • vimPlugins.nvim-treesitter-parsers.pascal
  • vimPlugins.nvim-treesitter-parsers.passwd
  • vimPlugins.nvim-treesitter-parsers.pem
  • vimPlugins.nvim-treesitter-parsers.perl
  • vimPlugins.nvim-treesitter-parsers.php
  • vimPlugins.nvim-treesitter-parsers.php_only
  • vimPlugins.nvim-treesitter-parsers.phpdoc
  • vimPlugins.nvim-treesitter-parsers.pioasm
  • vimPlugins.nvim-treesitter-parsers.po
  • vimPlugins.nvim-treesitter-parsers.pod
  • vimPlugins.nvim-treesitter-parsers.poe_filter
  • vimPlugins.nvim-treesitter-parsers.pony
  • vimPlugins.nvim-treesitter-parsers.powershell
  • vimPlugins.nvim-treesitter-parsers.printf
  • vimPlugins.nvim-treesitter-parsers.prisma
  • vimPlugins.nvim-treesitter-parsers.problog
  • vimPlugins.nvim-treesitter-parsers.prolog
  • vimPlugins.nvim-treesitter-parsers.promql
  • vimPlugins.nvim-treesitter-parsers.properties
  • vimPlugins.nvim-treesitter-parsers.proto
  • vimPlugins.nvim-treesitter-parsers.prql
  • vimPlugins.nvim-treesitter-parsers.psv
  • vimPlugins.nvim-treesitter-parsers.pug
  • vimPlugins.nvim-treesitter-parsers.puppet
  • vimPlugins.nvim-treesitter-parsers.purescript
  • vimPlugins.nvim-treesitter-parsers.pymanifest
  • vimPlugins.nvim-treesitter-parsers.python
  • vimPlugins.nvim-treesitter-parsers.ql
  • vimPlugins.nvim-treesitter-parsers.qmldir
  • vimPlugins.nvim-treesitter-parsers.qmljs
  • vimPlugins.nvim-treesitter-parsers.query
  • vimPlugins.nvim-treesitter-parsers.r
  • vimPlugins.nvim-treesitter-parsers.racket
  • vimPlugins.nvim-treesitter-parsers.ralph
  • vimPlugins.nvim-treesitter-parsers.rasi
  • vimPlugins.nvim-treesitter-parsers.razor
  • vimPlugins.nvim-treesitter-parsers.rbs
  • vimPlugins.nvim-treesitter-parsers.re2c
  • vimPlugins.nvim-treesitter-parsers.readline
  • vimPlugins.nvim-treesitter-parsers.regex
  • vimPlugins.nvim-treesitter-parsers.rego
  • vimPlugins.nvim-treesitter-parsers.requirements
  • vimPlugins.nvim-treesitter-parsers.rescript
  • vimPlugins.nvim-treesitter-parsers.rnoweb
  • vimPlugins.nvim-treesitter-parsers.robot
  • vimPlugins.nvim-treesitter-parsers.robots
  • vimPlugins.nvim-treesitter-parsers.roc
  • vimPlugins.nvim-treesitter-parsers.ron
  • vimPlugins.nvim-treesitter-parsers.rst
  • vimPlugins.nvim-treesitter-parsers.ruby
  • vimPlugins.nvim-treesitter-parsers.runescript
  • vimPlugins.nvim-treesitter-parsers.rust
  • vimPlugins.nvim-treesitter-parsers.scala
  • vimPlugins.nvim-treesitter-parsers.scfg
  • vimPlugins.nvim-treesitter-parsers.scheme
  • vimPlugins.nvim-treesitter-parsers.scss
  • vimPlugins.nvim-treesitter-parsers.sflog
  • vimPlugins.nvim-treesitter-parsers.slang
  • vimPlugins.nvim-treesitter-parsers.slim
  • vimPlugins.nvim-treesitter-parsers.slint
  • vimPlugins.nvim-treesitter-parsers.smali
  • vimPlugins.nvim-treesitter-parsers.smithy
  • vimPlugins.nvim-treesitter-parsers.snakemake
  • vimPlugins.nvim-treesitter-parsers.solidity
  • vimPlugins.nvim-treesitter-parsers.soql
  • vimPlugins.nvim-treesitter-parsers.sosl
  • vimPlugins.nvim-treesitter-parsers.sourcepawn
  • vimPlugins.nvim-treesitter-parsers.sparql
  • vimPlugins.nvim-treesitter-parsers.sql
  • vimPlugins.nvim-treesitter-parsers.squirrel
  • vimPlugins.nvim-treesitter-parsers.ssh_config
  • vimPlugins.nvim-treesitter-parsers.starlark
  • vimPlugins.nvim-treesitter-parsers.strace
  • vimPlugins.nvim-treesitter-parsers.styled
  • vimPlugins.nvim-treesitter-parsers.supercollider
  • vimPlugins.nvim-treesitter-parsers.superhtml
  • vimPlugins.nvim-treesitter-parsers.surface
  • vimPlugins.nvim-treesitter-parsers.svelte
  • vimPlugins.nvim-treesitter-parsers.sway
  • vimPlugins.nvim-treesitter-parsers.swift
  • vimPlugins.nvim-treesitter-parsers.sxhkdrc
  • vimPlugins.nvim-treesitter-parsers.systemtap
  • vimPlugins.nvim-treesitter-parsers.t32
  • vimPlugins.nvim-treesitter-parsers.tablegen
  • vimPlugins.nvim-treesitter-parsers.tact
  • vimPlugins.nvim-treesitter-parsers.tcl
  • vimPlugins.nvim-treesitter-parsers.teal
  • vimPlugins.nvim-treesitter-parsers.templ
  • vimPlugins.nvim-treesitter-parsers.tera
  • vimPlugins.nvim-treesitter-parsers.terraform
  • vimPlugins.nvim-treesitter-parsers.textproto
  • vimPlugins.nvim-treesitter-parsers.thrift
  • vimPlugins.nvim-treesitter-parsers.tiger
  • vimPlugins.nvim-treesitter-parsers.tlaplus
  • vimPlugins.nvim-treesitter-parsers.tmux
  • vimPlugins.nvim-treesitter-parsers.todotxt
  • vimPlugins.nvim-treesitter-parsers.toml
  • vimPlugins.nvim-treesitter-parsers.tsv
  • vimPlugins.nvim-treesitter-parsers.tsx
  • vimPlugins.nvim-treesitter-parsers.turtle
  • vimPlugins.nvim-treesitter-parsers.twig
  • vimPlugins.nvim-treesitter-parsers.typescript
  • vimPlugins.nvim-treesitter-parsers.typespec
  • vimPlugins.nvim-treesitter-parsers.typoscript
  • vimPlugins.nvim-treesitter-parsers.typst
  • vimPlugins.nvim-treesitter-parsers.udev
  • vimPlugins.nvim-treesitter-parsers.ungrammar
  • vimPlugins.nvim-treesitter-parsers.unison
  • vimPlugins.nvim-treesitter-parsers.usd
  • vimPlugins.nvim-treesitter-parsers.uxntal
  • vimPlugins.nvim-treesitter-parsers.v
  • vimPlugins.nvim-treesitter-parsers.vala
  • vimPlugins.nvim-treesitter-parsers.vento
  • vimPlugins.nvim-treesitter-parsers.verilog
  • vimPlugins.nvim-treesitter-parsers.vhdl
  • vimPlugins.nvim-treesitter-parsers.vhs
  • vimPlugins.nvim-treesitter-parsers.vim
  • vimPlugins.nvim-treesitter-parsers.vimdoc
  • vimPlugins.nvim-treesitter-parsers.vrl
  • vimPlugins.nvim-treesitter-parsers.vue
  • vimPlugins.nvim-treesitter-parsers.wgsl
  • vimPlugins.nvim-treesitter-parsers.wgsl_bevy
  • vimPlugins.nvim-treesitter-parsers.wing
  • vimPlugins.nvim-treesitter-parsers.wit
  • vimPlugins.nvim-treesitter-parsers.xcompose
  • vimPlugins.nvim-treesitter-parsers.xml
  • vimPlugins.nvim-treesitter-parsers.xresources
  • vimPlugins.nvim-treesitter-parsers.yaml
  • vimPlugins.nvim-treesitter-parsers.yang
  • vimPlugins.nvim-treesitter-parsers.yuck
  • vimPlugins.nvim-treesitter-parsers.zathurarc
  • vimPlugins.nvim-treesitter-parsers.zig
  • vimPlugins.nvim-treesitter-parsers.ziggy
  • vimPlugins.nvim-treesitter-parsers.ziggy_schema
  • vimPlugins.papis-nvim
  • vimPlugins.phpactor
  • vimPlugins.rainbow-delimiters-nvim
  • vimPlugins.rest-nvim
  • vimPlugins.rocks-config-nvim
  • vimPlugins.rocks-nvim
  • vimPlugins.rtp-nvim
  • vimPlugins.rustaceanvim
  • vimPlugins.sg-nvim
  • vimPlugins.skim
  • vimPlugins.sniprun
  • vimPlugins.statix
  • vimPlugins.sved
  • vimPlugins.syntax-tree-surfer
  • vimPlugins.taskwarrior2
  • vimPlugins.taskwarrior3
  • vimPlugins.telescope-fzf-native-nvim
  • vimPlugins.telescope-fzy-native-nvim
  • vimPlugins.tup
  • vimPlugins.vCoolor-vim
  • vimPlugins.vim-clap
  • vimPlugins.vim-hexokinase
  • vimPlugins.vim-markdown-composer
  • vimPlugins.vim-pony
  • vimPlugins.vim-stationeers-ic10-syntax
  • vimPlugins.vim-textobj-entire
  • vimPlugins.vim2nix
  • vimPlugins.vimacs
  • vimPlugins.vimsence
  • vimPluginsUpdater
  • vimacs
✅ 87 packages built:
  • tree-sitter-grammars.tree-sitter-bash
  • tree-sitter-grammars.tree-sitter-beancount
  • tree-sitter-grammars.tree-sitter-bibtex
  • tree-sitter-grammars.tree-sitter-bitbake
  • tree-sitter-grammars.tree-sitter-bqn
  • tree-sitter-grammars.tree-sitter-c
  • tree-sitter-grammars.tree-sitter-c-sharp
  • tree-sitter-grammars.tree-sitter-clojure
  • tree-sitter-grammars.tree-sitter-cmake
  • tree-sitter-grammars.tree-sitter-comment
  • tree-sitter-grammars.tree-sitter-commonlisp
  • tree-sitter-grammars.tree-sitter-css
  • tree-sitter-grammars.tree-sitter-cuda
  • tree-sitter-grammars.tree-sitter-cue
  • tree-sitter-grammars.tree-sitter-devicetree
  • tree-sitter-grammars.tree-sitter-dockerfile
  • tree-sitter-grammars.tree-sitter-dot
  • tree-sitter-grammars.tree-sitter-earthfile
  • tree-sitter-grammars.tree-sitter-embedded-template
  • tree-sitter-grammars.tree-sitter-erlang
  • tree-sitter-grammars.tree-sitter-fennel
  • tree-sitter-grammars.tree-sitter-fortran
  • tree-sitter-grammars.tree-sitter-gdscript
  • tree-sitter-grammars.tree-sitter-glsl
  • tree-sitter-grammars.tree-sitter-go
  • tree-sitter-grammars.tree-sitter-godot-resource
  • tree-sitter-grammars.tree-sitter-gomod
  • tree-sitter-grammars.tree-sitter-gowork
  • tree-sitter-grammars.tree-sitter-heex
  • tree-sitter-grammars.tree-sitter-hjson
  • tree-sitter-grammars.tree-sitter-html
  • tree-sitter-grammars.tree-sitter-http
  • tree-sitter-grammars.tree-sitter-hyprlang
  • tree-sitter-grammars.tree-sitter-janet-simple
  • tree-sitter-grammars.tree-sitter-java
  • tree-sitter-grammars.tree-sitter-javascript
  • tree-sitter-grammars.tree-sitter-jsdoc
  • tree-sitter-grammars.tree-sitter-json
  • tree-sitter-grammars.tree-sitter-json5
  • tree-sitter-grammars.tree-sitter-jsonnet
  • tree-sitter-grammars.tree-sitter-julia
  • tree-sitter-grammars.tree-sitter-kdl
  • tree-sitter-grammars.tree-sitter-koka
  • tree-sitter-grammars.tree-sitter-kotlin
  • tree-sitter-grammars.tree-sitter-ledger
  • tree-sitter-grammars.tree-sitter-llvm
  • tree-sitter-grammars.tree-sitter-nickel
  • tree-sitter-grammars.tree-sitter-norg-meta
  • tree-sitter-grammars.tree-sitter-nu
  • tree-sitter-grammars.tree-sitter-ocaml
  • tree-sitter-grammars.tree-sitter-ocaml-interface
  • tree-sitter-grammars.tree-sitter-org-nvim
  • tree-sitter-grammars.tree-sitter-pgn
  • tree-sitter-grammars.tree-sitter-php
  • tree-sitter-grammars.tree-sitter-pioasm
  • tree-sitter-grammars.tree-sitter-prisma
  • tree-sitter-grammars.tree-sitter-proto
  • tree-sitter-grammars.tree-sitter-pug
  • tree-sitter-grammars.tree-sitter-python
  • tree-sitter-grammars.tree-sitter-ql
  • tree-sitter-grammars.tree-sitter-ql-dbscheme
  • tree-sitter-grammars.tree-sitter-query
  • tree-sitter-grammars.tree-sitter-regex
  • tree-sitter-grammars.tree-sitter-rego
  • tree-sitter-grammars.tree-sitter-rst
  • tree-sitter-grammars.tree-sitter-ruby
  • tree-sitter-grammars.tree-sitter-rust
  • tree-sitter-grammars.tree-sitter-scala
  • tree-sitter-grammars.tree-sitter-scheme
  • tree-sitter-grammars.tree-sitter-smithy
  • tree-sitter-grammars.tree-sitter-supercollider
  • tree-sitter-grammars.tree-sitter-surface
  • tree-sitter-grammars.tree-sitter-svelte
  • tree-sitter-grammars.tree-sitter-talon
  • tree-sitter-grammars.tree-sitter-templ
  • tree-sitter-grammars.tree-sitter-tera
  • tree-sitter-grammars.tree-sitter-tlaplus
  • tree-sitter-grammars.tree-sitter-toml
  • tree-sitter-grammars.tree-sitter-tsx
  • tree-sitter-grammars.tree-sitter-turtle
  • tree-sitter-grammars.tree-sitter-twig
  • tree-sitter-grammars.tree-sitter-typescript
  • tree-sitter-grammars.tree-sitter-uiua
  • tree-sitter-grammars.tree-sitter-verilog
  • tree-sitter-grammars.tree-sitter-wgsl
  • tree-sitter-grammars.tree-sitter-yang
  • tree-sitter-grammars.tree-sitter-zig

@adfaure
Copy link
Contributor Author

adfaure commented Mar 20, 2025

I'm surprised the emacs plug-in doesn't seem to do the same as nvim-treesitter (separately locked grammars, specific to the plug-in).

Should we worry about reporting a grammar as broken "just" because some its tests aren't passing, if it builds and actually parses its inputs? I'm kind of surprised at the number of grammars which turned up broken = true here.

Honestly, I can't say. That's why it is important to have feedback.

What I can say (working on this PR for almost a year now), is that the recent bump from tree-sitter 0.24 to 0.25 has increased the number of broken grammar. The lack of testing is probably at cause here.

@khaneliman
Copy link
Contributor

What I can say (working on this PR for almost a year now), is that the recent bump from tree-sitter 0.24 to 0.25 has increased the number of broken grammar. The lack of testing is probably at cause here.

Very much appreciate the effort to add some testing.

@nix-owners nix-owners bot requested a review from jian-lin March 20, 2025 16:37
Copy link
Member

@amadaluzia amadaluzia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine aside from what had already been said by ambroisie.

Comment on lines 153 to 155
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could just use a variable instead of having to run the check twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, good catch. Thank you.

@adfaure adfaure force-pushed the tree-sitter-grammars-activate-tests branch 2 times, most recently from a81917f to 1439f9f Compare March 20, 2025 22:04
@uncenter
Copy link
Member

We should keep the commit history clean- can we squash the fixups?

@adfaure
Copy link
Contributor Author

adfaure commented Mar 21, 2025

We should keep the commit history clean- can we squash the fixups?

I split everything into atomics commit for the review.

Indeed, the goal is to merge, but should I do it know?

Please be mindful of my time, git manipulations like that take time and can be error-prone.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the quotes

@teto
Copy link
Member

teto commented Jun 17, 2025

The absence of versioning in the treesitter ecosystem is maddening. Running some tests help maintainers. I wont merge this since I can't maintain my tree-sitter ecosystem for more than a week so I dont feel qualified but merging this now, at the beginning of a nixos cycle is better than closer to 25.11.

@llakala
Copy link
Contributor

llakala commented Jun 19, 2025

I don't want to block this, just want some clarity - what will be the effects of this PR on consumers?

I went through and made a list of the broken grammars after this:

dart
eex
elisp
elixir 
elm 
fish 
gleam 
glimmer
graphql 
haskell 
hcl
just 
latex 
lua 
make 
nix 
norg 
perl 
r 
river 
scss 
solidity 
sparql 
sql 
tiger 
tsq 
typst 
vim 
vue 
wing 
yaml

Is the intention to fix some of the more high profile ones in staging, or just push this out quickly to unstable, and hope that upstream issues are resolved? I worry that some of the more high-profile grammars being marked as broken based on failing tests (especially if they seem to be working fine in practice) will leave their consumers to come into this PR to yell at us for merging this.

Not against this PR, to be clear! I just want to mention this kind of thing before we get an angry mob mentioning it after-the-fact.

@fricklerhandwerk
Copy link
Contributor

I proposed to @adfaure to make the tests optional and provide a visible way how to run them regardless. Or maybe turn tests on by default but make it possible to ignore them, something like that.

@adfaure
Copy link
Contributor Author

adfaure commented Jun 19, 2025

Not against this PR, to be clear! I just want to mention this kind of thing before we get an angry mob mentioning it after-the-fact.

Hi, I agree with your concerns.

As @fricklerhandwerk stated, I will try to find a way to add tests without everything's falling apart.

I also want to mention, that when we opened this PR, tree-sitter 25 was just released. My first step tomorrow will be to update the grammars and check if there is any improvement.

@amadaluzia
Copy link
Member

amadaluzia commented Jun 19, 2025

Lists in Nix allows for any element to have a different type, correct? My idea is to use an attribute value with key untestable, which is a boolean. It skips the test if it is true. I believe this approach would be exactly what @fricklerhandwerk is proposing.

Comment on lines 71 to 82
for g in grammars:
exists = check_grammar_exists(nixpkgs, g)
if exists:
existing.append(fmt_grammar(g))
broken = check_grammar_broken(nixpkgs, g)
if not broken:
existing.append(fmt_grammar(g))
else:
sys.stderr.write("Grammar is broken: " + fmt_grammar(g) + "\n")
sys.stderr.flush()
else:
sys.stderr.write("Missing grammar: " + fmt_grammar(g) + "\n")
sys.stderr.flush()
Copy link
Member

@amadaluzia amadaluzia Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose a rewrite:

for g in grammars:
    grammar = fmt_grammar(g)
    if not check_grammar_exists(nixpkgs, g):
        print(f"Missing grammar: {grammar}", file=sys.stderr)
        continue
    
    if check_grammar_broken(nixpkgs, g):
        print(f"Broken grammar: {grammar}", file=sys.stderr)
        continue
    
    existing.append(grammar)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks.

This script is only for Emacs plugins, so I think that would add the grammars tagged as broken back into the emacs ecosystem.

Which is something that I might have forgotten to handle without your feedback.

Copy link
Member

@PerchunPak PerchunPak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the intention to fix some of the more high profile ones in staging, or just push this out quickly to unstable, and hope that upstream issues are resolved?

We can't break a build even for a single grammar, because many use nvim-treesitter.withAllGrammars. Even if we mark some grammars as broken and exclude it from withAllGrammars, we will start to see bug reports like "grammar X is not found", which basically breaks workflow for the end user as it is an extremely annoying error (you have to press enter on each cursor move)

@kimburgess
Copy link
Member

kimburgess commented Jun 20, 2025

@PerchunPak completely agree not breaking things, even temporarilly, is important (in general).

It's worth noting that nvim-treesitter uses it's own set of grammar sources though. That appears to be isolated from whats happening here, particularly for users of to that withAllGrammars option.

From what I've seen working on #408414 the current state of grammar sources is not... great. That PR is ready for review / merge (edit: needs a rebase onto recent changes that have hit master, but otherwise ready) if it provides a clearer view of these source declarations ahead of work to test and fix them. More than happy to help get these changes working on top of that refactor if that's of use.

@PerchunPak PerchunPak added the 6.topic: vim Advanced text editor label Jun 20, 2025
@PerchunPak
Copy link
Member

completely agree not breaking things, even temporarilly, is important (in general).

I just wanted to stress that breaking even a single grammar is unacceptable

That appears to be isolated from whats happening here, particularly for users of to that withAllGrammars option.

Nope, vimPlugins.nvim-treesitter-parsers has rebuilds here

@adfaure
Copy link
Contributor Author

adfaure commented Jun 20, 2025

Hi, I understand the problem.

First, I want to mention, is that this PR has been released shortly after a new major version of tree sitter (24 to 25), leading to many broken grammars.

Currently, I am trying to update grammars to see if there is any improvement (I believe there will). However, I am unable to build the updating scripts since it takes forever to build on my laptop nix-build -A tree-sitter.updater.update-all-grammars and in my nixpkgs-reviews-gha fork (https://github.com/adfaure/nixpkgs-review-gha/actions/runs/15761196726/job/44428085396).

The second changes proposed by @fricklerhandwerk (as an answer to #391520 (comment)) is instead of having a broken attribute, having a withTest attribute that enables the tests, and then gradually setting this attribute to true.

@kimburgess your help will be greatly appreciated indeed if your PR is merged before, thanks !

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 29, 2025
src,
location ? null,
generate ? false,
broken ? false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like it is brokenTests rather than the whole grammar ? might be best to add overrides for those grammars in an overrides.nix rather than automate it. Among the advantages is that we dont introduce a new setting broken, it would be doCheck = false like for every other package, and it encodes it just in overrides.nix rather than the json + nix.

@teto
Copy link
Member

teto commented Dec 7, 2025

now might be a good time to rebase/ attempt a merge if you have the time.

@teto teto added the 6.topic: tree-sitter Tree-sitter is a parser generator tool and an incremental parsing library. label Dec 7, 2025
@uncenter
Copy link
Member

now might be a good time to rebase/ attempt a merge if you have the time.

Especially now that #408414 has been merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: emacs Text editor 6.topic: tree-sitter Tree-sitter is a parser generator tool and an incremental parsing library. 6.topic: vim Advanced text editor 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 501-1000 This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.