omnisharp-server
omnisharp-server copied to clipboard
Suggestion - Templating
Hi, great work on OmniSharpServer, its work great for me in a Vim integration.
I've been doing a little development on it myself and before I take it any further I wanted to get an opinion about the idea.
What I've implemented so far is the idea of a templating system. So at the moment from Vim I can do:
<Leader>cls
This makes a call to a new OmniSharp endpoint called FromTemplate, specifying 'class' as the template. This then uses the 'class.txt' template and injects the namespace of the nearest project and guesses the class name from the current file name.
Obviously once this was in place it was easy to hook up:
<Leader>int
This calls the same endpoint but specifying 'interface' as the template name.
I plan to take it a bit further and be able to do something like:
<Leader>prj
which will call the same endpoint but will specify a project template as the template. i.e project.classlibrary.
I've found this to be quite useful and its nicer than using something like snipmate as it injects the namespace/classname. Does it sound like a reasonable idea?
I've been thinking about the same thing recently. Currently I use ultisnips (https://github.com/SirVer/ultisnips/blob/master/UltiSnips/cs.snippets) which works great with YouCompleteMe. The only thing I find missing from this is automatic namespace / class name generation like you're suggesting, so yeah, I think this would be a great addition!
You might want to take a look at this project https://github.com/DarthFubuMVC/FubuCsProjFile as this project has C# file templating and project / solution file generation. I haven't had an in depth look at it yet, but it's quite likely that I would want to integrate it at some point as it has a lot of functionality that is currently missing from OmniSharp.
Cheers!
Thanks for the comment, the concept really works quite nicely. At the moment it allows me to do:
:e MyProject\Namespace\SubNamespace\MyClass.cs
<Leader>cls
The command in Vim takes that new buffer and writes it, then it gets the code generated by OmniSharp server and writes that, then it calls the OmniSharp command to add to the project. Quite a nice experience.
I'll take a look at that project, thanks.
Great! Don't feel like you have to use FubuCsProjFile. Not sure if it will help or not.
I'll gladly accept your pull request without it.