Comments (8)
Thanks for the detailed report. I think this is a duplicate of #4179, basically the same root cause causing the issue. What do you think?
from nvim-treesitter.
Thanks for the detailed report. I think this is a duplicate of #4179, basically the same root cause causing the issue. What do you think?
Thank you for the reply. The issue seems to be different as the @_comment
and @injection.content
captures point to the same node, so even if the #set!
directive only applies to the first capture the result should still be the same.
I've tried to modify the query to use only one capture like so:
; extends
((comment) @injection.content
(#contains? @injection.content "@swagger")
(#set! injection.language "yaml")
(#offset! @injection.content 2 3 0 0))
but I still get the same result where only the first line of yaml being highlighted.
from nvim-treesitter.
Testing the code below inside a yaml file
@swagger
test: [foo, 2]
another: one
and yaml parser doesn't return anything
Pressing :Inspect
under any character doesn't return anything, meaning the parser is very restrictive on what's right and wrong
from nvim-treesitter.
Testing the code below inside a yaml file
@swagger test: [foo, 2] another: oneand yaml parser doesn't return anything
Pressing
:Inspect
under any character doesn't return anything, meaning the parser is very restrictive on what's right and wrong
You're right, that's why I tried to "extract out" the valid yaml from the jsdoc comment with the #offset!
directive. I expected the offset of 2 3 0 0
to skip the first two lines containing
/**
* @swagger
as well as the *
characters at the start of each line.
What's confusing is that the yaml parser seems to only recognize the first line of yaml as seen here:
My understanding of how the #offset!
directive works could be wrong though.
from nvim-treesitter.
My understanding of how the #offset! directive works could be wrong though.
It's wrong, indeed.
#offset!
only moves the start and end position
So with a code of
/**
* @swagger
* test: ["foo", 2]
* another: one
*/
and an offset of 2 3 0 0
You will have a yaml tree of
test: ["foo", 2]
* another: one
*/
from nvim-treesitter.
and an offset of
2 3 0 0
You will have a yaml tree oftest: ["foo", 2] * another: one */
I see! In hindsight I don't know why I expected the column offset to be applied to every line...
Do you happen to know of a way to apply an offset to every line of the capture?
Or is it possible to programmatically perform injections to a custom set of ranges through the lua API?
from nvim-treesitter.
Nope, I don't know any reasonable way for that
If anything, it's best to bring the problem to upstream to ask.
Edit: Upstream here being Neovim
from nvim-treesitter.
Nope, I don't know any reasonable way for that
If anything, it's best to bring the problem to upstream to ask.
Edit: Upstream here being Neovim
I see, thank you!
from nvim-treesitter.
Related Issues (20)
- Help file tags are disappearing on MacOS neovim with treesitter HOT 3
- SIGSEV error during parsing html HOT 2
- `:TOhtml` does not preserve semantic highlighting HOT 1
- ECMAScript: remove several `@variable.builtins`
- Suggested modification to current roadmap
- vimwiki parser issue HOT 11
- Unable to enable indent only for specific languages HOT 3
- Impossible pattern in highlighter.win for tex files HOT 1
- Doxygen syntax - embedded parameters like `\p len` aren't highlighted HOT 2
- HTML file causes neovim segv HOT 6
- Links and images are underlined with dashes in markdown HOT 22
- latest update to vimdoc error HOT 7
- MyST directives with colon fence notation HOT 2
- [Rust] Ability to fold scopes explicitely defined by curly braces
- Highlighs in .dart goes crazy sometimes HOT 2
- undefined symbol: static_assert for cpp HOT 1
- installed parsers can fail randomly with "uv_dlopen: no error" HOT 23
- Segmentation fault on startup (bc. nvim_treesitter not found in runtime path?) HOT 4
- Uclosed parentheses cause incorrect indentation level in python HOT 2
- Error while installing any parser HOT 3
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.