-
-
Notifications
You must be signed in to change notification settings - Fork 390
Installation
- Visual Studio Code
- Sublime Text
- Neovim / Vim8
- Kate
- Emacs
- Doom Emacs
- Spacemacs
- Helix
- Prebuilt Binaries
- From Source
Using ZLS in Visual Studio Code is as simple as installing the official Zig Language extension (open in VSCode).
{
"clients": {
"zig": {
"command": ["zls"],
"enabled": true,
"languageId": "zig",
"scopes": ["source.zig"],
"syntaxes": ["Packages/Zig Language/Syntaxes/Zig.tmLanguage"]
}
}
}{
"clients": {
"zig": {
"command": ["zls"],
"enabled": true,
"selector": "source.zig"
}
}
}Run :CocInstall coc-zls to install coc-zls. This extension supports the same functionality as the VS Code extension.
{
"languageserver": {
"zls" : {
"command": "command_or_path_to_zls",
"filetypes": ["zig"]
}
}
}- Install YouCompleteMe from here.
- Add these lines to your vimrc:
"ensure zig is a recognized filetype
autocmd BufNewFile,BufRead *.zig set filetype=zig
let g:ycm_language_server =
\\ [
\\{
\\ 'name': 'zls',
\\ 'filetypes': [ 'zig' ],
\\ 'cmdline': [ '/path/to/zls_executable' ]
\\ }
\\ ]Requires Nvim 0.5 (HEAD)!
nvim-lspconfig already ships a configuration for zls. A simple init.vim might look like this:
call plug#begin('~/.config/nvim/plugged')
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
Plug 'ziglang/zig.vim'
call plug#end()
:lua << EOF
local lspconfig = require('lspconfig')
local on_attach = function(_, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
require('completion').on_attach()
end
local servers = {'zls'}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
}
end
EOF
" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect
" Enable completions as you type
let g:completion_enable_auto_popup = 1- Install the LanguageClient-neovim from here.
- Edit your neovim configuration and add
zlsfor zig filetypes:
let g:LanguageClient_serverCommands = {
\\ 'zig': ['~/code/zls/zig-out/bin/zls'],
\\ }- Install language support for Zig from here.
- Enable
LSP clientplugin in Kate settings. - Add this snippet to
LSP client'suser settings (e.g./$HOME/.config/kate/lspclient) (or paste it inLSP client'sGUI settings)
{
"servers": {
"zig": {
"command": ["zls"],
"url": "https://github.com/zigtools/zls",
"highlightingModeRegex": "^Zig$"
}
}
};; Setup lsp-mode as desired.
;; See https://emacs-lsp.github.io/lsp-mode/page/installation/ for more information.
(require 'lsp-mode)
;; Either place zls in your PATH or add the following:
(setq lsp-zig-zls-executable "<path to zls>")- Enable
:tool lspmodule. - Enable
:lang (zig +lsp)module. - Run
doom syncin a terminal.
- Add
lspandzigtodotspacemacs-configuration-layersin your.spacemacsfile. - If you don't have
zlsin yourPATH, add the following todotspacemacs/user-configin your.spacemacsfile:
(setq lsp-zig-zls-executable "<path to zls>")- Just add
zlsto yourPATH. - run
hx --healthto check if helix foundzls.
Note We currently recommend using the latest binaries as Zig and ZLS are fast-evolving.
| x86-64 | AArch64 | x86 | |
|---|---|---|---|
| Linux | x86-64 Linux | AArch64 Linux | x86 Linux |
| Windows | x86-64 Windows | - | x86 Windows |
| MacOS | x86-64 Macos | AArch64 MacOS | - |
Head to the Releases tab and select the right executable in the Assets section at the bottom of the latest release.
To untar the release artifact, simply install zstd with your package manager of choice or other means, and then:
tar --use-compress-program unzstd -x --strip-components=1 -f [archive] [output_path]See this section in the README.
Questions not answered by this wiki? Join our Discord server or start a discussion!