nvim-ts-rainbow2
nvim-ts-rainbow2 copied to clipboard
feat(v): add queries
I get an error at the root node of the test file:
ERROR [0, 0] - [42, 1]
ERROR [0, 7] - [41, 32]
simple_identifier [0, 7] - [0, 11]
simple_identifier [0, 14] - [0, 22]
...
Hey thanks for taking care if this. Looks like i was sloppy there. I'll check on it asap :+1:
Sorry about the inconvenience.
Main problem I've forgot about is that vim sets the ft for files with a .v
to verilog. For V it needs to be user set. I'd still need to improve the test but I'll submit the upstream support first then come back to this. Making this draft for now.
Main problem I've forgot about is that vim sets the ft for files with a
.v
to verilog. For V it needs to be user set.
Don't worry about that, it's outside the scope of this project. Anyone who uses V will already have adjusted the file type detection, and those who have not don't use V anyway.
Hey @HiPhish,
I updated the test to include code that actually compiles. It's still code that doesn't make a lot of sense. Sorry again about the miss in the initial PR.
Can you tell me how you run your tests? I haven't found anything in either the readme or the contribution file. Unfortunately, I have fairly little time to find out by doing my own investigation. Then I would be happy to adapt to further needs :+1:
Can you tell me how you run your tests?
I open the test file manually, then I open the Tree-sitter playground and check whether everything looks correct. It's not very efficient, but queries rarely change, so it's not a big deal. Still, it would be good to automate the process, especially for testing strategies.
Neovim 0.9 has introduced vim.inspect_pos()
, so now I can at least programmatically check the highlighting. With that I could use a testing framework to write automated tests. I have used in the past Vader, but it is flawed in that tests are all run in the same instance as the test framework itself. We would need a test framework that spawns a fresh Neovim per test so that failure or crashes in one test don't bring down all other tests. And first-class support for Lua (and maybe other languages?) of course.
I am still getting parser errors.
Thanks for you message @HiPhish. Totally fine to do it that way. And now, I know what to look at!
But I don't get the parsing errors. Could it be that it's because of a wrong filetype when you entering the .v file?
I submitted proper filetype detection the vim just about last week or so. Meanwhile it also made it into vim. Are you using nightly?
https://user-images.githubusercontent.com/34311583/235243816-208fa42c-1c26-4dd6-9e99-9d97acccbcaa.mp4
You are correct, I had the file type Verilog set, my bad. It would be a good idea to add a little modeline comment at the end of the file to set the file type explicitly when there is any possibility of ambiguity. See :h modeline
. I did the same in the test file for the query
file type (test/highlight/query/regular.scm
) to ensure that it is not interpreted as Scheme instead.
Anyway, I have now looked into it and there are a number of node types I don't see in the tree:
-
parenthesized_expression
-
type_cast_expression
-
special_argument_list
-
comptime_selector_expression
-
multi_return_type
-
fixed_array_type
-
exposed_variables_list
-
slice_expression
-
attribute_declaration
-
empty_literal_value
-
select_expression
-
map
(there ismap_type
in the tree)
Am I missing something again?
No you are right again @HiPhish. I didn't added all of the node types in the test file. I'll update it in the coming week.