LSP Editor Integration
Run ion lspto hook up Ion's rich diagnostics to any modern text editor.
Features
- Diagnostics: Real-time linting errors exactly as `ion check` sees them.
- Code Actions: Auto-fix capabilities accessible via quick fixes in your editor.
- Go-To-Definition: Symbol resolution (requires
libclang). - Auto-fix on save: Formats and checks on file save.
Visual Studio Code
Until the official Ion extension is published, you can configure clangd or custom LSP clients manually, or point a generic client to ion lsp.
Example using the Generic LSP Client extension:
json
{
"glspc.servers": {
"cpp": {
"command": "ion",
"args": ["lsp"]
}
}
}Neovim
Configuration for nvim-lspconfig.
lua
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
if not configs.ion then
configs.ion = {
default_config = {
cmd = { 'ion', 'lsp' },
filetypes = { 'c', 'cpp' },
root_dir = lspconfig.util.root_pattern('ion.toml', '.git'),
},
}
end
lspconfig.ion.setup{}Helix
Add the following to your languages.toml:
toml
[[language]]
name = "cpp"
language-servers = [ "ion-lsp" ]
[language-server.ion-lsp]
command = "ion"
args = ["lsp"]Troubleshooting
libclang not found
If go-to-definition isn't working, make sure libclang is installed on your system. Ion dynamically attempts to load the shared library.
Compile commands not found
Ion auto-generates compile_commands.json on every ion build. If the LSP complains about missing headers, ensure you've built the project at least once.