Skip to content

LSP adapter for csharp-ls enabling Claude Code compatibility

Notifications You must be signed in to change notification settings

Agasper/CSharpLspAdapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CSharpLspAdapter

NuGet

LSP adapter for csharp-ls that enables compatibility with Claude Code.

Why?

Claude Code's LSP client doesn't support several protocol methods that csharp-ls requires:

  • workspace/configuration — server requests workspace settings
  • client/registerCapability — dynamic capability registration
  • window/workDoneProgress/create — progress reporting

Without this adapter, csharp-ls hangs waiting for responses that never come.

Architecture

Claude Code  ←→  csharp-ls-adapter  ←→  csharp-ls
                      ↓
               Intercepts and handles:
               - workspace/configuration
               - client/registerCapability
               - window/workDoneProgress/create

Installation

Quick Setup with Claude Code

If you're already using Claude Code, simply ask it to install the adapter:

Install C# LSP support following https://github.com/Agasper/CSharpLspAdapter

Claude will read these instructions and configure everything automatically.

Prerequisites

Important: If you have the official csharp-ls plugin installed from the Claude Code store, you must completely uninstall it first:

/plugin uninstall csharp-ls
  • .NET SDK 8.0 or later
  • csharp-ls language server
# Install csharp-ls
dotnet tool install --global csharp-ls

# Install the adapter
dotnet tool install --global CSharpLspAdapter

Troubleshooting: If csharp-ls installation fails with Settings file 'DotnetToolSettings.xml' was not found, either update your .NET SDK to the latest version, or install an older csharp-ls version (related issue):

dotnet tool install --global csharp-ls --version 0.20.0

Note: Ensure .NET tools directory is in your PATH:

  • macOS/Linux: Add to ~/.bashrc or ~/.zshrc:
    export PATH="$PATH:$HOME/.dotnet/tools"
  • Windows: Add %USERPROFILE%\.dotnet\tools to your PATH environment variable

Manual Configuration

Step 1. Create the plugin structure:

# Create plugin directory
mkdir -p ~/.claude/plugins/csharp-ls-adapter/.claude-plugin

# Create plugin.json
cat > ~/.claude/plugins/csharp-ls-adapter/.claude-plugin/plugin.json << 'EOF'
{
  "name": "csharp-ls-adapter",
  "description": "C# language support via csharp-ls-adapter",
  "version": "1.0.0"
}
EOF

# Create .lsp.json
cat > ~/.claude/plugins/csharp-ls-adapter/.lsp.json << 'EOF'
{
  "csharp": {
    "command": "csharp-ls-adapter",
    "extensionToLanguage": {
      ".cs": "csharp",
      ".csx": "csharp"
    }
  }
}
EOF

Step 2. Register the plugin in a local marketplace:

# Create marketplace directory
mkdir -p ~/.claude/plugins/.claude-plugin

# Create or update marketplace.json
cat > ~/.claude/plugins/.claude-plugin/marketplace.json << 'EOF'
{
  "name": "local-plugins",
  "owner": { "name": "local" },
  "plugins": [
    {
      "name": "csharp-ls-adapter",
      "source": "./csharp-ls-adapter",
      "description": "C# language support via csharp-ls-adapter"
    }
  ]
}
EOF

Step 3. Add the marketplace to Claude Code settings (~/.claude/settings.json):

{
  "extraKnownMarketplaces": {
    "local-plugins": {
      "source": {
        "source": "directory",
        "path": "~/.claude/plugins"
      }
    }
  }
}

Step 4. Install the plugin in Claude Code:

/plugin install csharp-ls-adapter@local-plugins

Step 5. Enable LSP tools and restart Claude Code:

LSP support in Claude Code requires the ENABLE_LSP_TOOL environment variable.

macOS/Linux — Add this line to your ~/.bashrc or ~/.zshrc file:

export ENABLE_LSP_TOOL=1

Then restart your terminal or run source ~/.zshrc.

Windows — Add ENABLE_LSP_TOOL with value 1 to your user environment variables (System Properties → Environment Variables), then restart Claude Code.

Troubleshooting

Environment variables below are only needed for debugging, not for normal use.

Update your .lsp.json to include them:

{
  "csharp": {
    "command": "csharp-ls-adapter",
    "extensionToLanguage": {
      ".cs": "csharp",
      ".csx": "csharp"
    },
    "env": {
      "LSP_SOLUTION_PATH": "/path/to/your/Solution.sln",
      "LSP_ADAPTER_DEBUG": "1"
    }
  }
}
Environment Variable Description
LSP_SOLUTION_PATH Explicitly specify .sln file if auto-detection fails
LSP_ADAPTER_DEBUG Set to 1 to enable debug logging to csharp-lsp-adapter.log in system temp directory

Supported LSP Features

  • Go to Definition
  • Find References
  • Hover Documentation
  • Document Symbols
  • Workspace Symbols
  • Diagnostics
  • Code Actions
  • Signature Help
  • Completion

Building from Source

git clone https://github.com/agasper/CSharpLspAdapter.git
cd CSharpLspAdapter
dotnet pack -c Release
dotnet tool install --global --add-source ./bin/Release CSharpLspAdapter

Related Issues

License

MIT

About

LSP adapter for csharp-ls enabling Claude Code compatibility

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages