diff --git a/Cargo.toml b/Cargo.toml index e610715..eab5733 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" categories =["developement-tools"] license = "GPL-2.0" keywords = ["lsp", "bridge"] -repository = "https://proxy.dandaedre.com/gitea/MadGobblins/vsg_bridge_ls" +repository = "https://proxy.dandaedre.com/gitea/MadGobblins/vsg-bridge-ls" authors = ["dandaedre"] [dependencies] diff --git a/README.md b/README.md index 3203273..158c10e 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,15 @@ # vsg_bridge_ls -`vsg_bridge_ls` exposes [VSG](https://github.com/jeremiah-c-leary/vhdl-style-guide) -diagnostics through the Language Server Protocol. Editor formatting uses the -companion VSG fork, which adds the stream-oriented options required to format -an unsaved buffer. +`vsg_bridge_ls` reports [VSG](https://github.com/jeremiah-c-leary/vhdl-style-guide) +diagnostics through the Language Server Protocol (LSP). A complete setup needs +the companion VSG fork and this bridge. -You need both executables: +Helix is the only actively maintained and tested editor integration. The Vim +and VSCodium recipes are best-effort and may need adjustment for your setup. -- `vsg` from the [companion fork](https://proxy.dandaedre.com/gitea/MadGobblins/vhdl-style-guide) -- `vsg_bridge_ls` from this repository +## 1. Install the VSG fork -## Quick start - -The preferred VSG installation uses `uv pip` and the prebuilt package. From the -directory where you will launch your editor: +The preferred installation uses `uv pip` and the prebuilt package: ```sh uv venv .venv @@ -22,48 +18,62 @@ uv pip install --python .venv/bin/python \ vsg ``` -Then install the bridge: +Without `uv`, use standard `pip`: ```sh -cargo install --git https://proxy.dandaedre.com/gitea/MadGobblins/vsg_bridge_ls.git +python3 -m venv .venv +. .venv/bin/activate +python -m pip install \ + --index-url https://proxy.dandaedre.com/gitea/api/packages/MadGobblins/pypi/simple/ \ + --extra-index-url https://pypi.org/simple \ + vsg ``` -Activate the environment before starting the editor so the bridge can find -`vsg`: +## 2. Install the bridge + +```sh +cargo install --git https://proxy.dandaedre.com/gitea/MadGobblins/vsg-bridge-ls.git +``` + +Activate the environment and verify both executables: ```sh . .venv/bin/activate +command -v vsg +command -v vsg_bridge_ls +vsg_bridge_ls --help ``` -Standard `pip` also works with either the prebuilt package or the fork's -`master` branch. `uv pip` can likewise install `master`; see -[the complete installation guide](doc/installation.md) for every supported -method and PATH details. +## 3. Configure Helix -## Helix - -Add the server to `~/.config/helix/languages.toml`: +Add this minimal setup to `~/.config/helix/languages.toml`: ```toml [language-server.vsg_bridge_ls] command = "vsg_bridge_ls" -args = ["-c", "vhdl/config.yaml"] # Optional; relative to the project. [[language]] name = "vhdl" -language-servers = ["vhdl_ls", "vsg_bridge_ls"] +language-servers = ["vsg_bridge_ls"] +auto-format = false +formatter = { command = "vsg", args = ["--stdin", "--stdout", "--fix", "-fp", "7", "--no-failure"] } ``` -The bridge reports diagnostics. Helix formatting invokes the companion `vsg` -executable directly; the complete formatter configuration and its limitations -are in [the editor guide](doc/editor-configuration.md). +Start Helix from the activated environment: + +```sh +. .venv/bin/activate +hx path/to/file.vhd +``` + +Diagnostics should appear as you edit. Run `:format` to format the current +buffer with the fork. ## More documentation -- [Installation and troubleshooting](doc/installation.md) -- [Editor and formatter configuration](doc/editor-configuration.md) +- [Installation alternatives and PATH troubleshooting](doc/installation.md) +- [Helix, Vim, and VSCodium setup](doc/editor-configuration.md) - [Development and packaging](doc/development.md) -This bridge is deliberately small and currently supports only its documented -capabilities. Contributions should preserve clean LSP standard output and keep -the VSG subprocess boundary explicit. +The bridge is deliberately small. Contributions should preserve clean LSP +standard output and keep the VSG subprocess boundary explicit. diff --git a/doc/editor-configuration.md b/doc/editor-configuration.md index 3fa2ff0..8cdc687 100644 --- a/doc/editor-configuration.md +++ b/doc/editor-configuration.md @@ -1,50 +1,111 @@ # Editor configuration -The bridge provides VSG diagnostics over LSP. Formatting is a separate editor -command that pipes the current buffer directly through the companion VSG fork. +The bridge provides VSG diagnostics over standard-input/standard-output LSP. +Formatting is a separate editor command that pipes the current buffer through +the companion VSG fork. -## Helix diagnostics +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`: ```toml [language-server.vsg_bridge_ls] command = "vsg_bridge_ls" -args = ["-c", "vhdl/config.yaml"] # Optional; relative to the project. [[language]] name = "vhdl" -scope = "source.vhdl" -file-types = ["vhd", "vhdl"] -comment-token = "--" -language-servers = ["vhdl_ls", "vsg_bridge_ls"] -indent = { tab-width = 2, unit = " " } -injection-regex = "vhdl" -``` - -Repeat `-c PATH` to pass multiple VSG configuration files. - -## Helix formatting - -Add the following entries to the same `[[language]]` table: - -```toml +language-servers = ["vsg_bridge_ls"] auto-format = false formatter = { command = "vsg", args = ["--stdin", "--stdout", "--fix", "-fp", "7", "--no-failure"] } ``` -Set `auto-format = true` only after testing the exact formatter command on the -project. Omitting `-fp 7` allows more granular fix selection. VSG's `-ap` -option is for processing all rules and should not be combined blindly with -`--fix`; test the intended arguments in a terminal first: +To use VSG configuration files, add arguments to the server entry. Repeat +`-c PATH` for multiple files; relative paths are resolved from the project: + +```toml +args = ["-c", "vhdl/config.yaml"] +``` + +If another VHDL server is installed, it can run alongside the bridge: + +```toml +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: ```sh vsg --stdin --stdout --fix -fp 7 --no-failure < vhdl/test.vhd ``` -## Other editors +## Vim (best-effort) -Configure `vsg_bridge_ls` as a standard-input/standard-output language server -and ensure its process can find `vsg` on PATH. Only advertise or configure -features documented by the bridge; formatting should invoke `vsg` directly -until the bridge implements LSP document formatting. +This example uses [vim-lsp](https://github.com/prabirshrestha/vim-lsp). With +vim-plug, add the plugin and run `:PlugInstall`: + +```vim +Plug 'prabirshrestha/vim-lsp' +``` + +Then register the bridge in `.vimrc`: + +```vim +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 provide LSP document formatting. Configure VSG as an +external formatter separately if formatting is required in Vim. + +## VSCodium (best-effort) + +VSCodium has no built-in setting for arbitrary LSP commands. One possible +adapter is +[Generic LSP Proxy](https://github.com/mjmorales/vscode-generic-lsp-proxy), +but it is not currently available from Open VSX. Build its VSIX locally: + +```sh +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: + +```json +[ + { + "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 provide LSP document formatting. Configure VSG as an +external formatter separately if formatting is required in VSCodium. diff --git a/doc/installation.md b/doc/installation.md index b22be33..ee6d377 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -58,7 +58,7 @@ python -m pip install \ Install the released branch directly from Gitea: ```sh -cargo install --git https://proxy.dandaedre.com/gitea/MadGobblins/vsg_bridge_ls.git +cargo install --git https://proxy.dandaedre.com/gitea/MadGobblins/vsg-bridge-ls.git ``` For development, clone this repository and use `cargo build`. Cargo normally