Get the FREE Ultimate OpenClaw Setup Guide →

lsp-config

npx machina-cli add skill blvp/cc-lspctl/lsp-config --openclaw
Files (1)
SKILL.md
4.7 KB

LSP Configuration Skill

Provides guidance for configuring Language Server Protocol (LSP) servers in Claude Code using the lspctl plugin.

Overview

The lspctl plugin enables Mason-like LSP management for Claude Code:

  1. Define servers in a Lua config file (compatible with Neovim)
  2. Generate a marketplace with individual LSP plugins
  3. Install binaries and plugins as needed

Quick Start

1. Create Config File

Create ~/.claude/lsp-config.lua (user-level) or .claude/lsp-config.lua (project-level):

return {
  ensure_installed = {
    "lua_ls",      -- Lua
    "pylsp",       -- Python (with ruff/isort)
    "pyright",     -- Python (type checking)
    "ts_ls",       -- TypeScript/JavaScript
    "rust_analyzer", -- Rust
    "gopls",       -- Go
  },
  servers = {
    pylsp = {
      settings = {
        pylsp = {
          plugins = {
            ruff = { enabled = true, lineLength = 80 },
            isort = { enabled = true, profile = "black" }
          }
        }
      }
    },
    rust_analyzer = {
      settings = {
        ["rust-analyzer"] = {
          checkOnSave = { command = "clippy" }
        }
      }
    }
  }
}

2. Generate Marketplace

/lspctl:sync

This creates a marketplace at ~/.claude/generated-lsp-marketplace/ (or project-level).

3. Install Plugins

/plugin install lsp-python-pylsp@generated-lsp
/plugin install lsp-rust@generated-lsp

Or install all:

/lspctl:install-all

Available Commands

CommandDescription
/lspctl:listShow available servers and status
/lspctl:syncGenerate marketplace from config
/lspctl:install <server>Install specific server
/lspctl:install-allInstall all configured servers
/lspctl:uninstall <server>Uninstall server plugin
/lspctl:uninstall --allRemove all and deregister marketplace

Supported LSP Servers

ServerLanguageBinary
lua_lsLualua-language-server
pylspPythonpylsp
pyrightPythonpyright-langserver
ts_lsTypeScript/JStypescript-language-server
rust_analyzerRustrust-analyzer
goplsGogopls
clangdC/C++clangd
jsonlsJSONvscode-json-language-server
yamllsYAMLyaml-language-server
bashlsBashbash-language-server

Server Settings Reference

Python (pylsp with ruff)

pylsp = {
  settings = {
    pylsp = {
      plugins = {
        ruff = { enabled = true, lineLength = 80 },
        isort = { enabled = true, profile = "black" },
        pycodestyle = { enabled = false },
        pyflakes = { enabled = false },
        mccabe = { enabled = false }
      }
    }
  }
}

Python (pyright)

pyright = {
  settings = {
    python = {
      analysis = {
        typeCheckingMode = "basic",  -- "off", "basic", "standard", "strict"
        autoSearchPaths = true,
        useLibraryCodeForTypes = true
      }
    }
  }
}

Lua

lua_ls = {
  settings = {
    Lua = {
      diagnostics = { globals = { "vim" } },
      runtime = { version = "LuaJIT" },
      workspace = { checkThirdParty = false }
    }
  }
}

Rust

rust_analyzer = {
  settings = {
    ["rust-analyzer"] = {
      checkOnSave = { command = "clippy" },
      files = { excludeDirs = { ".git", "target" } }
    }
  }
}

TypeScript

ts_ls = {
  settings = {
    typescript = {
      preferences = {
        quoteStyle = "single"
      }
    }
  }
}

Troubleshooting

LSP not starting

  1. Check if binary is installed:

    which <command>
    
  2. Run with debug logging:

    claude --enable-lsp-logging
    
  3. Check logs in ~/.claude/debug/

Config not parsing

  1. Validate Lua syntax:

    lua -c ~/.claude/lsp-config.lua
    
  2. Test parser:

    lua ${CLAUDE_PLUGIN_ROOT}/scripts/parse-lua-config.lua ~/.claude/lsp-config.lua
    

Plugin not found

  1. Ensure marketplace was generated:

    /lspctl:sync
    
  2. Check marketplace was added to settings:

    cat ~/.claude/settings.json | grep generated-lsp
    

Migrating from Neovim

Your Neovim LSP config uses lspconfig server names (e.g., lua_ls, pylsp). The lspctl plugin uses the same naming convention.

To migrate:

  1. Copy ensure_installed array from your mason-lspconfig setup
  2. Copy server settings from your vim.lsp.config() calls
  3. Run /lspctl:sync

Source

git clone https://github.com/blvp/cc-lspctl/blob/main/plugins/lspctl/skills/lsp-config/SKILL.mdView on GitHub

Overview

lspctl provides Mason-like LSP management for Claude Code. You define servers in a Lua config, generate a marketplace, and install binaries and plugins as needed. This makes LSP setup reproducible per project or per user.

How This Skill Works

Create a Lua config at ~/.claude/lsp-config.lua or project level to declare ensure_installed servers and per server settings. The lspctl plugin reads this config, builds a marketplace, and supports commands to sync, install, and uninstall servers.

When to Use It

  • First time LSP setup in Claude Code
  • Migrating existing lspconfig setups
  • Managing multiple servers across projects
  • Importing Mason style config into Claude Code
  • Troubleshooting LSP integration and startup

Quick Start

  1. Step 1: Create a Lua config at user level or project level with ensure_installed and per server settings
  2. Step 2: Run /lspctl:sync to generate the marketplace in the generated-lsp-marketplace folder
  3. Step 3: Install servers with /plugin install <server>@generated-lsp or /lspctl:install-all

Best Practices

  • Keep lsp-config.lua under version control for reproducibility
  • Pin binaries and servers in ensure_installed to avoid drift
  • Use dedicated per server settings blocks for critical options
  • Run lspctl:sync regularly to refresh the marketplace
  • Verify startup with /lspctl:list before installing servers

Example Use Cases

  • Enable pylsp with ruff and isort in pylsp plugins
  • Configure pyright with typeCheckingMode and autoSearchPaths
  • Tailor lua_ls with globals vim, LuaJIT runtime, and workspace checkThirdParty
  • Configure rust_analyzer with checkOnSave clippy and exclude target dirs
  • Adjust ts_ls preferences to set quoteStyle to single

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers