vsg-bridge-ls/doc/editor-configuration.md

3.9 KiB

Editor configuration

The bridge provides VSG diagnostics over standard-input/standard-output LSP. It also provides rule-scoped Quick Fixes and an explicit source.fixAll.vsg action. LSP document formatting remains a separate editor command that pipes the current buffer through the companion VSG fork.

Helix is the only actively maintained and tested integration. The Vim and VSCodium recipes are best-effort starting points and may need adjustment. Whichever editor you use, launch it from the activated VSG environment or set absolute paths for both executables.

Helix

Add this configuration to ~/.config/helix/languages.toml:

[language-server.vsg_bridge_ls]
command = "vsg_bridge_ls"

[[language]]
name = "vhdl"
language-servers = ["vsg_bridge_ls"]
auto-format = false
formatter = { command = "vsg", args = ["--stdin", "--stdout", "--fix", "-fp", "7", "--no-failure"] }

To use VSG configuration files, add arguments to the server entry. Repeat -c PATH for multiple files; relative paths are resolved from the project:

args = ["-c", "vhdl/config.yaml"]

The experimental grouped same-line action additionally requires --experimental-multi-rule-line-fix in this argument list. It is deliberately off by default; read its safety notes before enabling it.

If another VHDL server is installed, it can run alongside the bridge:

language-servers = ["vhdl_ls", "vsg_bridge_ls"]

Set auto-format = true only after testing the formatter on the project. Omitting -fp 7 allows more granular fix selection. Test alternate arguments in a terminal first:

vsg --stdin --stdout --fix -fp 7 --no-failure < vhdl/test.vhd

Use Helix's action picker (space, then a by default) on a diagnosed line to choose one VSG rule correction or Fix all VSG findings. Hover (space, then k by default) shows the effective rule configuration and documentation.

Vim (best-effort)

This example uses vim-lsp. With vim-plug, add the plugin and run :PlugInstall:

Plug 'prabirshrestha/vim-lsp'

Then register the bridge in .vimrc:

if executable('vsg_bridge_ls')
  au User lsp_setup call lsp#register_server({
        \ 'name': 'vsg_bridge_ls',
        \ 'cmd': {server_info->['vsg_bridge_ls']},
        \ 'allowlist': ['vhdl'],
        \ })
endif

Start Vim from the activated .venv. To pass a VSG configuration file, change the command to ['vsg_bridge_ls', '-c', 'vhdl/config.yaml'].

The bridge does not advertise LSP document formatting. Its standard code actions should appear through vim-lsp's normal code-action UI; keep VSG as an external formatter if you also want Vim's format command.

VSCodium (best-effort)

VSCodium has no built-in setting for arbitrary LSP commands. One possible adapter is Generic LSP Proxy, but it is not currently available from Open VSX. Build its VSIX locally:

git clone https://github.com/mjmorales/vscode-generic-lsp-proxy.git
cd vscode-generic-lsp-proxy
npm install
npm run compile
npx vsce package
codium --install-extension generic-lsp-proxy-*.vsix
cd ..

Create .vscode/lsp-proxy.json in the VHDL project:

[
  {
    "languageId": "vhdl",
    "command": "vsg_bridge_ls",
    "transport": "stdio",
    "fileExtensions": [".vhd", ".vhdl"]
  }
]

Launch the project from the activated environment with codium ., then open a VHDL file. If diagnostics do not appear, check Output: Generic LSP Proxy. Desktop and sandboxed VSCodium installations may require an absolute command path or other PATH adjustments.

The bridge does not advertise LSP document formatting. Its Quick Fixes and source fix-all should appear through the proxy's normal code-action UI when the proxy preserves code-action literals; keep VSG as an external formatter if you also want VSCodium's format command.