Open charbelnicolas opened 4 weeks ago
Hello!
Just a little message to say that I worked on this issue and fixed it.
Hopefully, my pull request will be considered soon!
If not, here a solution to work with a local version of the parser.
if your editor is Neovim, you need to fallow these steps:
git clone https://github.com/tree-sitter-grammars/tree-sitter-svelte.git
grammar.js
(in the root directory of the project) :npm install tree-sitter
npm install tree-sitter-html
tree-sitter generate
Place this code at the end of your init.lua
config entry point.
Be sure to replace the URL with the absolute path of your local version of the repo.
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.svelte = {
install_info = {
url = "/root/path/of/localrepo/here",
files = {"src/parser.c", "src/scanner.c"},
},
filetype = "svelte"
}
local project_path = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h:h")
local query_files = vim.fn.globpath(project_path, "queries/svelte/**", nil, true)
for _, query_file in ipairs(query_files) do
local query_name = vim.fn.fnamemodify(query_file, ":t:r")
local query_content = table.concat(vim.fn.readfile(query_file), "\n")
vim.treesitter.set_query("svelte", query_name, query_content)
end
Final step, reinstall the svelte parser :
:TSUninstall svelte
:TSInstall svelte
Wow, thank you so much! I Appreciate it! Hopefully your PR gets merged soon too so everyone can benefit from your fix :)
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)tree-sitter 0.24.3 (bdfe32402e85673bbc693216f0a6ef72c98bb665)
Describe the bug
When using {:else if} it won't highlight it in the proper color
Steps To Reproduce/Bad Parse Tree
Use an
{#if ...}
statement with an{:else if ...}
inside as shown in the above screenschot...Expected Behavior/Parse Tree
{:else if ...}
should be highlighted in the same color as the{#if ...}
statementRepro