Editors
Visual Studio Code
Visual Studio Code is the recommended editor, since it's the best supported editor.
To use WebAssembly Language Tools in Visual Studio Code, you just need to install the extension from the marketplace. You don't need to install the server executable manually, since the extension bundles it for you.
Zed
Install the WebAssembly Text Format extension. Once opened a .wat file, server executable will be automatically downloaded, so you don't need to install it manually.
Neovim
Neovim has built-in support for WebAssembly Language Tools via nvim-lspconfig.
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
For the minimal setup, add the following lines to your init.lua:
vim.lsp.enable("wasm_language_tools")Additionally, you can configure the language server like this:
vim.lsp.config("wasm_language_tools", {
cmd = { "/path/to/wat_server" }, -- optional
settings = {
format = {},
lint = {
unused = "warn",
},
},
})
vim.lsp.enable("wasm_language_tools")If you're using Neovim 0.10 or older:
require("lspconfig").wasm_language_tools.setup({})or with configuration:
require("lspconfig").wasm_language_tools.setup({
settings = {
format = {},
lint = {
unused = "warn",
},
},
})coc.nvim
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
For the minimal setup, add the following lines to your coc-settings.json:
{
"languageserver": {
"wasm-language-tools": {
"command": "wat_server", // or the absolute path to the executable
"filetypes": ["wat"]
}
}
}Emacs
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
Emacs can't recognize .wat files by default. You need to create a major mode like this:
(define-derived-mode wat-mode prog-mode "WAT")
(add-to-list 'auto-mode-alist '("\\.wat\\'" . wat-mode))or use similar packages.
lsp-mode
lsp-mode has built-in support for WebAssembly Language Tools.
You may need to add a hook to start the language server automatically:
(use-package lsp-mode
;; ... other configurations ...
:hook
(wat-mode . lsp-deferred))Additionally, you can configure the language server like this:
(use-package lsp-mode
;; ... other configurations ...
:hook
(wat-mode . lsp-deferred)
:config
(setq lsp-wat-server-command '("/path/to/wat_server")) ; optional
(setq lsp-wat-lint-unused "deny"))To view all available configurations, please refer to the documentation of lsp-mode.
Eglot
NOTE
It's required to install Eglot from GNU-devel ELPA.
Eglot has built-in support for WebAssembly Language Tools.
You may need to add a hook to start the language server automatically:
(add-hook 'wat-mode-hook 'eglot-ensure)or with use-package:
(use-package eglot
;; ... other configurations ...
:hook
(wat-mode . eglot-ensure))Additionally, you can configure the language server like this:
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
`(wat-mode . ("wat_server" :initializationOptions
(:lint (:unused "deny"))))))or configure in .dir-locals.el for specific projects: (recommended)
((nil
. ((eglot-workspace-configuration
. (:wasmLanguageTools (:lint (:unused "deny")))))))lsp-bridge
lsp-bridge has built-in support for WebAssembly Language Tools.
Helix
Helix has built-in support for WebAssembly Language Tools.
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
Additionally, you can configure the language server like this:
[language-server.wasm-language-tools]
command = "wat_server"
config = { format = {}, lint = { unused = "warn" } }
[[language]]
name = "wat"
language-servers = ["wasm-language-tools"]Kakoune
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
For the minimal setup, add the following lines to your kakrc after eval %sh{kak-lsp}:
hook global BufCreate .*[.](wat) %{
set-option buffer filetype wat
}
hook -group lsp-filetype-wat global BufSetOption filetype=wat %{
set-option buffer lsp_servers %{
[wasm-language-tools]
command = "/path/to/wat_server"
root_globs = [".git", ".hg"]
}
}Sublime Text
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
For the minimal setup, add the following lines to your Sublime Text LSP config:
{
"clients": {
"wasm-language-tools": {
"enabled": true,
"command": ["/path/to/wat_server"],
"selector": "source.wat | source.wast"
}
}
}Please note that source.wast in selector is just a trigger for starting language server, but WebAssembly Language Tools doesn't actually support WAST.
Also, Sublime Text can't recognize .wat files by default. You may need to install third-party packages to achieve that.
Fresh
IMPORTANT
You need to install the server executable manually and make sure it's in your $PATH (or specify the executable path manually).
For the minimal setup, add the following lines to your Fresh Editor config ~/.config/fresh/config.json:
{
"languages": {
"wat": {
"extensions": ["wat"],
"comment_prefix": ";;",
"auto_indent": true
}
},
"lsp": {
"wat": {
"command": "wat_server",
"args": [],
"enabled": true
}
}
}or with configuration:
{
"languages": {
"wat": {
"extensions": ["wat"],
"comment_prefix": ";;",
"auto_indent": true
}
},
"lsp": {
"wat": {
"command": "wat_server",
"args": [],
"enabled": true,
"initialization_options": {
"lint": {},
"format": {}
}
}
}
}