Skip to content

rcd/nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neovim Configuration for C# Development

A modular Neovim configuration optimized for C# development using roslyn.nvim, with support for Blazor/Razor files.

Structure

~/.config/nvim/
├── init.lua
├── lua/
│   ├── config/
│   │   ├── options.lua    # Editor settings
│   │   ├── keymaps.lua    # Space as leader + keybindings
│   │   └── lazy.lua       # Plugin manager bootstrap
│   └── plugins/
│       ├── colorscheme.lua  # Tokyonight theme
│       ├── treesitter.lua   # C# + Razor syntax
│       ├── mason.lua        # Tool installer
│       ├── lsp.lua          # roslyn.nvim + rzls.nvim
│       ├── cmp.lua          # Autocompletion
│       ├── fzf.lua          # Fuzzy finding
│       ├── dap.lua          # .NET debugging
│       └── neotest.lua      # Unit testing

Features

  • LSP: Full C# language server via roslyn.nvim with inlay hints
  • Razor Support: Blazor/Razor development via rzls.nvim
  • Debugging: .NET debugging with netcoredbg
  • Unit Testing: Test runner with neotest-dotnet
  • Autocompletion: nvim-cmp with LSP integration
  • Syntax Highlighting: Treesitter for C#, Razor, and more
  • Fuzzy Finding: fzf-lua for file/text searching
  • Theme: Tokyonight colorscheme

Installation

  1. Start Neovim (lazy.nvim will auto-install plugins):

    nvim
  2. Install Mason tools:

    :MasonInstall roslyn rzls
  3. Verify installation:

    :checkhealth

Prerequisites

  • Neovim >= 0.10.0
  • .NET SDK (9.0+)
  • Git, ripgrep, fzf (for fuzzy finding)
  • Node.js and npm (for some LSP features)

Key Keybindings

General

Key Action
<Space> Leader key
<leader>w Save file
<leader>q Quit
<leader>x Save and quit
<Esc> Clear search highlights

Window Navigation

Key Action
<C-h> Move to left window
<C-j> Move to bottom window
<C-k> Move to top window
<C-l> Move to right window
<S-h> Previous buffer
<S-l> Next buffer

FZF (Fuzzy Finding)

Key Action
<leader>ff Find files
<leader>fg Live grep
<leader>fb Find buffers
<leader>fh Help tags
<leader>fo Recent files
<leader>fc Commands
<leader>fk Keymaps

LSP (Language Server)

Key Action
gd Go to definition
gD Go to declaration
gr Show references
gi Go to implementation
K Hover documentation
<leader>ca Code action
<leader>rn Rename symbol
<leader>d Show diagnostics
[d Previous diagnostic
]d Next diagnostic

Debugging (DAP)

Key Action
<F5> Continue / Start debugging
<F9> Toggle breakpoint
<F10> Step over
<F11> Step into
<F8> Step out
<leader>dr Open REPL
<leader>dl Run last
<leader>dt Debug nearest test

Testing (Neotest)

Key Action
<leader>tr Run nearest test
<leader>tf Run test file
<leader>ta Run all tests in solution
<leader>ts Toggle test summary
<leader>to Show test output
<leader>dt Debug nearest test

Completion (in Insert mode)

Key Action
<C-Space> Trigger completion
<CR> Confirm selection
<Tab> Next item / Expand snippet
<S-Tab> Previous item
<C-b> Scroll docs up
<C-f> Scroll docs down
<C-e> Abort completion

Usage Examples

Creating a C# Project

cd ~/projects
dotnet new console -n MyApp
cd MyApp
dotnet build
nvim

Debugging

  1. Build your project: dotnet build
  2. Open a C# file in Neovim
  3. Set a breakpoint with F9
  4. Start debugging with F5
  5. You'll be prompted for the path to the DLL (usually in bin/Debug/net9.0/)

Running Tests

  1. Open a test file
  2. Position cursor on a test method
  3. Run with <leader>tr or debug with <leader>dt

Configuration Customization

All plugin configurations are modular and can be customized by editing files in lua/plugins/.

Changing Editor Settings

Edit lua/config/options.lua to modify:

  • Tab size (default: 4 spaces)
  • Line numbers
  • Search settings
  • And more

Adding Custom Keybindings

Edit lua/config/keymaps.lua to add your own keybindings.

Installing Additional Plugins

Create a new file in lua/plugins/ with your plugin configuration:

return {
  "author/plugin-name",
  config = function()
    -- Plugin setup here
  end,
}

Troubleshooting

LSP Not Working

  1. Check if roslyn is installed: :Mason
  2. Check LSP status: :LspInfo
  3. Check health: :checkhealth

Debugging Issues

  • Ensure netcoredbg is installed: :Mason
  • Verify .NET SDK is installed: dotnet --version
  • Check DAP configuration: :lua print(vim.inspect(require('dap').configurations.cs))

Mason Registry Issues

If roslyn or rzls fail to install, ensure the custom registry is configured in lua/plugins/mason.lua:

registries = {
  "github:mason-org/mason-registry",
  "github:Crashdummyy/mason-registry",
}

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages