playground
playground copied to clipboard
Renamed grammar doesn't work
TSPlayground
doesn't show anything for my jdummy
language which is a JSON duplicate.
I created this dummy language by copying the JSON grammar and changing its name to jdummy
in its grammar.js
as shown below.
I can see the pars tree after running: tree-sitter parser example.jdummy
,
but I don't see anything in the Playgound.
Am I missing anything?
module.exports = grammar({
name: 'jdummy',
extras: $ => [
/\s/
],
...
1- mkdir tree-sitter-jdummy
2- copied the grammar.js
of JSON and changed its name to jdummy
3- cd tree-sitter-jdummy
4- update my config file in ~/.config/nvim/init.vim
lua <<EOF
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.jdummy= {
install_info = {
url = "~/src/tree-sitter-jdummy", -- local path or git repo
files = {"src/parser.c"},
branch = 'main'
},
filetype = "jdummy", -- if filetype does not agrees with parser name
}
EOF
5- tree-sitter generate
6- tree-sitter test
7- nvim ~/.config/nvim/init.vim
=> :TSInstall jdummy
8- nvim example.jdummy
=> :TSPlayground
There's a bug in this plugin. You have to create a highlights.scm (even an empty one) to get updates from the highlighting parsers
Still doesn't work.
From the original JSON folder, I copied the queries
folder which contains highlights.scm
, and did all the steps again,
but still see the same problem.
Probably due to a different issue, but I also noticed a bug, where the playground would not show an AST.
The issue was, that there was this in the grammar.js
:
// ...
alias($.some_rule, "")
// ...
This aliasing to the empty string somehow broke the playground window, while tree-sitter parse
would work perfectly fine.