oleg-shilo / cs-script.vscode

VSCode extension for CS-Script
MIT License
37 stars 7 forks source link

Features Request : Autocompletion & Format document #7

Closed RexProg closed 6 years ago

RexProg commented 6 years ago

hi oleg-shilo the features i really miss in VSCode is Autocompletion & Format document OmniSharp doesn't work for me

oleg-shilo commented 6 years ago

The latest release has delivered the extension own Intellisense equivalent.

Release 1.4.0

It is very similar to the experience delivered by OmniSharp as it is based on Roslyn and relies on.

Though Format document will be delivered in the very next release.

If you want to use CS-Script Intellisense you will need to open C# file alone with no workspace being loaded via open folder. You just need to wait a few seconds before VSCode loads all extensions and initializes Roslyn at startup.

Note that when VSCode has workspace loaded it completely takes control over the Intellisesnse. That is why CS-Script offers Intellisense only for stand alone C# files.

OmniSharp doesn't work for me.

It is strange as what CS-Script extension does for fallback intellisense is simply loads a C# workspace (folder with C# project) generated on fly. After that CS-Script is not involved in intellisense support at all.

Can you send me the content of your CSSCRIPT-OMNISHARP folder so I can investigate?

image

Just create a new script and then And load it as work space (Ctrl+F7):

image

RexProg commented 6 years ago

Excellent ;D

oleg-shilo commented 6 years ago

Done. The latest release v1.5.1 contains all traditional Intellisense features including formatting.

Falthazar commented 6 years ago

Can you add an option to turn this off? I use "C# FixFormat" to format, since it has some extra options I like. Having them both active messes up formatting of C# files. Also, it seems like the CSS formatter is removing indentation on blank lines?

oleg-shilo commented 6 years ago

Moved to 'Make document formatting configurable' #11


Done in Release v1.5.5

Falthazar commented 6 years ago

Even with "cs-script.enable_code_formatting": false, it still seems to be causing an issue with C# Fix format. If I run "format document" it won't do anything. If I disable CS-Script it'll work, but I'm not sure if it's a bug on your end or fix format.

EDIT: Never mind, I think I found the issue: CS-Script implements "vscode.DocumentFormattingEditProvider " C# Fix format does not, it only implements "vscode.DocumentRangeFormattingEditProvider" and "vscode.OnTypeFormattingEditProvider"

I tried just doing format selection, and that would work correctly. I know nothing about VS code extensions, but I'm guessing that that even if the formatting in CS-Script is disabled it still overwrites C# fix format since it isn't explicitly providing the full document formatter.

I'll open the issue with that extension, sorry!

oleg-shilo commented 6 years ago

Yeah, implementing formatting via DocumentFormattingEditProvider is a much better option.
Any extension can implement a provider for a given functionality (autocompletion, formatting, renaming). And if the extension decides not to handle the request at run time it simply returns null and other providers with process the request.

That's why CS-Script formatting is only engaged if no workspace loaded and cs-script.enable_code_formatting set to true. This way it does not interfere with any other cases when VSCode already does proper formatting (e.g. C# workspace).

I will still need to do an urgent release today to address some formatting artifacts but of a completely different nature.