nvim-treesitter
nvim-treesitter copied to clipboard
feat(c_sharp): add indent query
I have been using it for some months now and seems to mostly work ok.
Can you point, how to run the tests? I could probably add some of them to make it easier to debug. I was looking into CONTRIBUTING
but didn't see any pointer. And the script in scrips/run_test.sh
expects presence of some non existing files...
Can you point, how to run the tests
For this PR, you'll need to add example c_sharp files to tests/indent/c_sharp/
, create that dir if it doesn't exist.
For running those file, you also need to create a tests/indent/c_sharp_spec.lua
. You can use other *_spec.lua
files in tests/indent
as a reference point.
That's the part which I understood, but I have no clue how to run the thing
oh, just be inside the git repo, and do a ./scripts/run_tests.sh indent/c_sharp_spec.lua
and see the result
No, you also need to have plenary installed and in your standard runtimepath.
(I've said it before; I'll say it again: the test infrastructure is a pain point and needs to be streamlined.)
Thanks @clason, that's the missing part - I expected that test machinery would grab it itself, if it needs it
I've been using this and my if
blocks do some funny stuff.
Pipes added to make tabs visible.
Orig:
if (name == "john")
{
| name = "sam";
}
Format using 3==
. Adds a tab infront of {
which it shouldn't.
if (name == "john")
| {
| name = "sam";
}
Same story with my try
blocks, except it adds a tab infront of {
and }
Orig:
try
{
| name = "harry";
}
Becomes:
try
| {
| name = "harry";
| }
Any ideas?
Hm, that's wierd. It works for me. Don't you have so syntax error before this snippet?
I have to figure out how to create some reasonable tests. I will take me some time though.
I have to figure out how to create some reasonable tests
In most cases, just a normal C# file will suffice. Don't bloat it up. I think for this around 100-200 lines may be enough. Double that if you want to test for multiple cases (braces on newline/eol, else
after }
, else
in newline, ...)
Yeah, I want to do mostly some tricky cases. I was struggling to make the testing machine work - i'd expect the whole_file
thing takes file, tries to reindent it and passes if nothing changed. Sadly I was unable to break it - it always passed.
i'd expect the
whole_file
thing takes file, tries to reindent it and passes if nothing changed
That is what it does, and what it expects to be
Sadly I was unable to break it - it always passed.
Which should mean you've done a great job :tada:
Which should mean you've done a great job 🎉
I wish you are right :-D Well, first thing I did was to test the test - put something really off to see what i get back... And got success. So I went ahead and tried to break tests for other languages - always passed, so either it is broken, or my setup is wonky.
You can publish the tests and let the CI/me test it as well.
Hm, that's wierd. It works for me. Don't you have so syntax error before this snippet?
I have to figure out how to create some reasonable tests. I will take me some time though.
No syntax errors here :)