-
Notifications
You must be signed in to change notification settings - Fork 0
neovim CSharp
lamt edited this page May 22, 2023
·
13 revisions
Category | Name |
---|---|
Language Server | omnisharp |
Debugger | netcoredbg |
Linter | omnisharp(roslyn-analyzers) |
Formatter | omnisharp(dotnet-format) |
dotnet new console -o hello-cs
cd hello-cs
# Optional
# You can keep the version of asdf.
asdf local dotnet <your version>
dotnet build
# Optional
# Run
dotnet run
vi Program.cs
-
F9
: Set Breakpoint -
F5
: Start Debug - Input
net<your version>/hello-cs.dll
- Stop at Breakpoint
-
F10
: Step over - Exit Debug
.vscode/launch.json is possible to make it by opening the project root directory in VSCode.
nvim-dap load .vscode/launch.json by default. And other debug adapters can do the same (need to set up the appropriate .vscode/launch.json).
mkdir .vscode
vi .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net<your version>/hello-cs.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
}
]
}
vi Program.cs
-
F9
: Set Breakpoint -
leader d c
: Show configurations - Input
coreclr: .NET Core Launch (console)
- Stop at Breakpoint
-
F10
: Step over - Exit Debug
(F6
: Run with the last configuration)
Unlike VSCode, Linter and Formatter will not work without this setting.
vi omnisharp.json
{
"RoslynExtensionsOptions": {
"enableAnalyzersSupport": true
},
"FormattingOptions": {
"enableEditorConfigSupport": true
}
}
vi Bad.cs
public class Bad
{
public int GetNum()
{
return 1;
}
}
Show the troule window (leader x x
).
See: omnisharp-roslyn -- Configuration.
See also: roslyn-analyzers.
See also: Microsoft -- Overview of .NET source code analysis.
vi .editorconfig
[*.cs]
indent_size = 2
indent_style = space
vi Bad.cs
:w
or space f
.
# Option
# Also runnable on the command line
dotnet format
See: Microsoft -- editorconfig.
See also: Roslyn team's editorconfig.
See: StyleCopAnalyzers.