habamax / vim-godot

Use vim and godot engine to make games

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature-request: c# support

cprn opened this issue · comments

commented

Hi there!

I was hoping you could add C# support as well. Completion is taken care of by LSP (e.g. omnisharp and csharp-ls work great) so the only changes needed for great out-of-the-box experience is the commands (that currently don't work in *.cs files) and folding that could be handled by something like this:

au FileType cs set foldmethod=marker
au FileType cs set foldmarker={,}
au FileType cs set foldtext=substitute(getline(v:foldstart),'{.*','{...}',)
au FileType cs set foldlevelstart=2

I was thinking about making a separate plugin for C# users but it doesn't make much sense since I find myself experimenting with GD script examples all the time even though my project is written in C#.

I can't see how any of those fold settings are godot-specific.

And users who already have a C# ftplugin would be disrupted by installing a godot plugin -- they'd have to figure out how to turn it off. They might already be using foldmethod=indent or not want folding enabled by default. (Also vim's built-in cs filetype provides some folding for #regions which requires foldmethod=syntax.)

Making a separate C# plugin for brace folding would make a lot of sense. It would be unrelated to godot. Any users (Unity, Godot, etc) who want brace-driven folding could install it.

commented

The main issue is those very useful commands don't work in cs buffers. Folding is a secondary thing I don't care much about.

As a side note, I solely mentioned folding because I had foldmethod=syntax in my $VIMRC and it didn't seem to do anything for cs files (but it might be due to my specific rc or some plugins so just ignore that part).

It's late at night and I'm answering on a mobile so I apologize for any mistakes.

Oh, I see, it's the run commands like :GodotRunCurrent that you're after. Maybe defining them could be pulled out into a command so users can invoke it from any ftplugin to setup godot commands. They're potentially useful for C#, C++, python, nim, and whatever other languages Godot supports, but not something all users would want by default.

To confirm they work properly in a C# project, do all four work correctly if you add this to your vimrc:

command! GodotRunCurrent call godot#run_current()
command! GodotRunLast call godot#run_last()
command! -nargs=? -complete=customlist,godot#scene_complete GodotRun call godot#run(<q-args>)
command! GodotRunFZF call godot#fzf_run_scene()