nvim-treesitter icon indicating copy to clipboard operation
nvim-treesitter copied to clipboard

feat(c_sharp): add indent query

Open vlada-dudr opened this issue 1 year ago • 14 comments

I have been using it for some months now and seems to mostly work ok.

vlada-dudr avatar Sep 02 '23 14:09 vlada-dudr

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...

vlada-dudr avatar Sep 02 '23 16:09 vlada-dudr

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.

lucario387 avatar Sep 02 '23 16:09 lucario387

That's the part which I understood, but I have no clue how to run the thing

vlada-dudr avatar Sep 02 '23 16:09 vlada-dudr

oh, just be inside the git repo, and do a ./scripts/run_tests.sh indent/c_sharp_spec.lua and see the result

lucario387 avatar Sep 02 '23 16:09 lucario387

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.)

clason avatar Sep 02 '23 16:09 clason

Thanks @clason, that's the missing part - I expected that test machinery would grab it itself, if it needs it

vlada-dudr avatar Sep 02 '23 16:09 vlada-dudr

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?

KiLLeRRaT avatar Sep 13 '23 23:09 KiLLeRRaT

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.

vlada-dudr avatar Sep 14 '23 08:09 vlada-dudr

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, ...)

lucario387 avatar Sep 14 '23 08:09 lucario387

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.

vlada-dudr avatar Sep 14 '23 08:09 vlada-dudr

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:

lucario387 avatar Sep 14 '23 08:09 lucario387

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.

vlada-dudr avatar Sep 14 '23 08:09 vlada-dudr

You can publish the tests and let the CI/me test it as well.

lucario387 avatar Sep 14 '23 08:09 lucario387

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 :)

KiLLeRRaT avatar Sep 14 '23 18:09 KiLLeRRaT