Validate a swarm-lang file using: swarm format ./file.sw
Swarm comes with a language server protocol (LSP) server.
Make sure the swarm
program is present in your PATH, then
configure your editor.
The current LSP implementation features the following extensions:
- error diagnostic on load/save
Using lsp-mode:
Load the swarm-mode.el and start
the M-x lsp
service in a swarm-mode buffer.
The swarm-lang extension provides highlighting and an
LSP client. That is if you have swarm
executable in PATH, then
the executable will be used as LSP server to show errors as you type.
You can get it by:
- installing from the MS marketplace (link)
- installing from the Open VSX Registry (link)
- building from source in the vscode folder
To configure YAML editor tabs for schema validation, install the YAML plugin. The appropriate settings are already included in .vscode/settings.json
under the workspace root.
Add the following lines to your Vim/Neovim configuration file for files with the .sw
extension to be recognized as swarm
programs:
init.vim
:
au BufRead,BufNewFile *.sw setfiletype swarm
init.lua
:
vim.cmd[[au BufRead,BufNewFile *.sw setfiletype swarm]]
Basic syntax highlighting is available for both Vim and Neovim. To make use of this capability, copy swarm.vim to the syntax
directory in your Vim or Neovim configuration directory.
An LSP configuration leveraging Neovim's native LSP client is also available. It only works with Neovim. To enable it, copy swarm.lua to after/ftplugin
in your Neovim configuration directory.