Comments (10)
Please report this to tree-sitter-rust. We don't control nor fix parser issues
from nvim-treesitter.
@lucario387 as mentioned in the Additional Context above,
this issue is not reproducible upstream.
I am using the latest parser for both the CLI and nvim-treesitter
layout:
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.rust = {
install_info = {
url = "https://github.com/tree-sitter/tree-sitter-rust",
revision = "e0e8b6de6e4aa354749c794f5f36a906dcccda74",
files = { "src/parser.c", "src/scanner.c" },
},
}
running tree-sitter parse ./src/lib.rs
on the rust file above produces this tree:
(source_file [0, 0] - [5, 0]
(function_item [0, 0] - [3, 1]
name: (identifier [0, 3] - [0, 7])
parameters: (parameters [0, 7] - [0, 9])
body: (block [0, 10] - [3, 1]
(expression_statement [1, 4] - [1, 23]
(macro_invocation [1, 4] - [1, 22]
macro: (identifier [1, 4] - [1, 11])
(token_tree [1, 12] - [1, 22]
(string_literal [1, 13] - [1, 17])
(identifier [1, 19] - [1, 21]))))
(expression_statement [2, 4] - [2, 19]
(macro_invocation [2, 4] - [2, 18]
macro: (identifier [2, 4] - [2, 11])
(token_tree [2, 12] - [2, 18]
(string_literal [2, 13] - [2, 17])))))))
running vim.treesitter.inspect_tree()
on the same lib.rs
produces the tree below:
(function_item ; [1:1 - 4:1]
name: (identifier) ; [1:4 - 7]
parameters: (parameters) ; [1:8 - 9]
body: (block ; [1:11 - 4:1]
(expression_statement ; [2:5 - 23]
(macro_invocation ; [2:5 - 22]
macro: (identifier) ; [2:5 - 11]
(token_tree ; [2:13 - 22]
(ERROR ; [2:13 - 22]
(unit_expression ; [2:13 - 22]
(ERROR))) ; [2:18 - 18]
(string_literal) ; [2:14 - 17]
(identifier)))) ; [2:20 - 21]
(expression_statement ; [3:5 - 19]
(macro_invocation ; [3:5 - 18]
macro: (identifier) ; [3:5 - 11]
(token_tree ; [3:13 - 18]
(ERROR ; [3:13 - 18]
(unit_expression)) ; [3:13 - 18]
(string_literal)))))) ; [3:14 - 17]
This is not a tree-sitter-rust problem, could we reopen this issue?
from nvim-treesitter.
Not here; it's a Neovim issue (if it is indeed not an upstream issue, e.g., different behaviour between lib and crate).
Also note that Neovim (nightly) uses a pre-release commit of the tree-sitter lib (in fact, the HEAD of master
). Make sure you test the same commit of the CLI.
from nvim-treesitter.
@clason should I file an issue in https://github.com/neovim/neovim/ then?
from nvim-treesitter.
First you should test on equal footing. But if it is not an upstream issue (which I still believe is the case, since the parser output is different), neovim/neovim is the right place, yes.
But you need to verify first that this cannot be reproduced with tree-sitter
HEAD and tree-sitter-rust
HEAD.
(@amaanq )
from nvim-treesitter.
since the parser output is different
I don't think that they will currently match up regardless since vim.treesitter.inspect_tree()
does not render the source_file
top level node:
from nvim-treesitter.
Don't think, test! (That issue is unrelated, and clearly not a relevant difference in this context.)
from nvim-treesitter.
Just woke up 😴
But I tried using upstream queries to see if it's our issue or not (tree-sitter/tree-sitter-rust@8023833)
But it doesn't seem to change anything
; fn main() {
; println!("ok");
; }
(function_item ; [1:1 - 3:1]
name: (identifier) ; [1:4 - 7]
parameters: (parameters) ; [1:8 - 9]
body: (block ; [1:11 - 3:1]
(expression_statement ; [2:5 - 19]
(macro_invocation ; [2:5 - 18]
macro: (identifier) ; [2:5 - 11]
(token_tree ; [2:13 - 18]
(ERROR ; [2:13 - 18]
(parenthesized_expression ; [2:13 - 18]
(string_literal))) ; [2:14 - 17]
(string_literal)))))) ; [2:14 - 17]
So it doesn't seem like our issue :). Either its the parser or neovim
from nvim-treesitter.
@lucario387 you are correct, I've submitted an issue in neovim:
neovim/neovim#27159
Neovim 0.8.x doesn't make the issue show up with latest nvim-treesitter
checked out
from nvim-treesitter.
Not really
🤔
I figured out why
from nvim-treesitter.
Related Issues (20)
- Multiple functions in locals.lua failed for go HOT 1
- Problem with typescript files HOT 1
- [latex] Some comments highlighted incorrectly in math regions HOT 1
- Spell checking doesn't work with elixir grammar HOT 4
- (python) Incorrect try/except indentation in certain cases
- Error During Compilation: No such file or directory HOT 1
- bug: `spell` not working within TSX/JSX HOT 4
- GitHub actions syntax for context variables breaks TS in `run:` sections HOT 1
- Custom syntax highlighting not being applied to markdown fenced code HOT 4
- Only code blocks are highlighted in markdown HOT 1
- Ruby indents braces (`{`) incorrectly inside a method HOT 2
- Two parsers priority indent on the same file HOT 5
- Neovim freezes when using zig treesitter. HOT 22
- error in rust highlights HOT 1
- indentation in a multi language doc HOT 5
- Attempt to call method 'range' (a nil value) HOT 1
- The Svelte project has an query error,but only once HOT 3
- Detect http uri links and path's in comments and .md for specific highlighting HOT 6
- Some nodes do not get captured within quarto (qmd) or rmarkdown (Rmd) files, even though they appear in TSPlaygroundToggle. HOT 1
- Markdown Highlight Regression HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-treesitter.