swarm/editors
Karl Ostmo b8d37a9364
extract doc generator to separate executable (#1671)
Closes #1443.

Also added `-Wunused-packages` to clean up dependencies.

## Demo

This still works as usual:

    stack run

Output editor keywords:

    stack run swarm-docs -- editors --emacs
2023-12-04 03:45:07 +00:00
..
emacs extract doc generator to separate executable (#1671) 2023-12-04 03:45:07 +00:00
vim Implement entity tags and commands (#1635) 2023-11-20 00:01:46 +00:00
vscode extract doc generator to separate executable (#1671) 2023-12-04 03:45:07 +00:00
README.md Add syntax highlighting and LSP configuration for Vim/Neovim (#1518) 2023-09-13 22:11:29 +00:00

Text Editor Configuration

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.

EMACS

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.

VS Code and VS Codium

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

YAML schema validation

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.

Vim and Neovim

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.