Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Renamed grammar doesn't work #63

Open
rabieifk opened this issue Feb 3, 2022 · 3 comments
Open

Renamed grammar doesn't work #63

rabieifk opened this issue Feb 3, 2022 · 3 comments

Comments

@rabieifk
Copy link

rabieifk commented Feb 3, 2022

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

@theHamsta
Copy link
Member

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

@rabieifk
Copy link
Author

rabieifk commented Feb 3, 2022

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.

@aMOPel
Copy link

aMOPel commented Mar 22, 2023

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants