You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+95
Original file line number
Diff line number
Diff line change
@@ -153,4 +153,99 @@ zig-master-0.15.0-dev.77+aa8aa6625 Programming language designed for robustness
153
153
$ doas pkg_delete zig-master-0.15.0-dev.77+aa8aa6625
154
154
```
155
155
156
+
### ZLS
157
+
158
+
If you want to use [Zig Language Server (ZLS)](https://github.com/zigtools/zls/) for [text editor autocomplete and other features](https://langserver.org/), you'd preferably need the zls version matching your installed Zig version.
159
+
160
+
Multiple versions of zls can live in the same NetBSD system. e.g. You can keep `devel/zls` from official pkgsrc, `devel/zls-master` and `devel/zls-0.14.0` together. Just make sure to use the appropriate binary path in the configuration of the text editor.
161
+
162
+
Installation:
163
+
164
+
```sh
165
+
### For zig-master you need devel/zls-master
166
+
$ cd /usr/pkgsrc/devel/zls-master
167
+
$ make makesum # update checksum according to latest master archive
168
+
$ make install
169
+
$ zls-master --version
170
+
0.15.0-dev
171
+
$ which zls-master
172
+
/usr/pkg/bin/zls-master
173
+
### Use the above path in your text editor config to use this zls
174
+
175
+
### For zig-0.14.0 (dev or stable) you need devel/zls-0.14.0
176
+
$ cd /usr/pkgsrc/devel/zls-0.14.0
177
+
$ make install
178
+
$ zls-0.14.0 --version
179
+
0.14.0
180
+
$ which zls-0.14.0
181
+
/usr/pkg/bin/zls-0.14.0
182
+
### Use the above path in your text editor config to use this zls
183
+
```
184
+
185
+
Configuration example with vim:
186
+
187
+
```sh
188
+
$ doas pkgin in vim
189
+
$ vim --version | head -1
190
+
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Feb 27 2025 03:36:34)
191
+
192
+
## install plugin
193
+
$ mkdir -p $HOME/.vim/pack/downloads/opt
194
+
$ cd$HOME/.vim/pack/downloads/opt
195
+
$ git clone https://github.com/yegappan/lsp
196
+
$ vim -u NONE -c "helptags $HOME/.vim/pack/downloads/opt/lsp/doc" -c q
197
+
198
+
$ echo'packadd lsp'>>$HOME/.vimrc
199
+
```
200
+
201
+
Append below to `~/.vimrc` (don't forget to change `path` if needed):
202
+
203
+
```vim
204
+
" detect .zig files as zig code automatically
205
+
autocmd BufNewFile,BufRead *.zig set filetype=zig
206
+
207
+
" Zig language server
208
+
call LspAddServer([#{
209
+
\ name: 'zls',
210
+
\ filetype: ['zig'],
211
+
\ path: '/usr/pkg/bin/zls-master',
212
+
\ args: [],
213
+
\ }])
214
+
```
215
+
216
+
To test:
217
+
218
+
```sh
219
+
$ echo'const std = @import("std")'>> test.zig
220
+
$ vim test.zig
221
+
```
222
+
223
+
- Optionally, type `:LspShowAllServers` and enter to show status. It should show something like:
224
+
225
+
```
226
+
Filetype Information
227
+
====================
228
+
Filetype: 'zig'
229
+
Server Name: 'zls'
230
+
Server Path: '/usr/pkg/bin/zls-master'
231
+
Status: Running
232
+
233
+
Buffer Information
234
+
==================
235
+
Buffer: 'test.zig'
236
+
Server Path: '/usr/pkg/bin/zls-master'
237
+
```
238
+
239
+
`:q` to get back to buffer.
240
+
241
+
- To test definitions `fi` to get cursor over `@import`, `:LspHover` to show definition and information about `@import`. `<esc>` to hide.
242
+
- Buffer should show an `E>` on the left gutter of the line because there is no `;` at the end of the line (intentionally left out). Type `<shift>a;<esc>` to fix it.
243
+
- To try autocomplete suggestions, press `o` (lowercase letter O) to create new line, then try typing `std.d` and it should show options `debug` and `dwarf`. Press `<down><enter>` to select `debug`.
244
+
- To save and exit `:wq<enter>`
245
+
246
+
I was interested in [geany-lsp](https://github.com/techee/geany-lsp) as an example but [it requires Geany 2.1+](https://github.com/techee/geany-lsp/issues/60#issuecomment-2539763729) which was not available in NetBSD repos when writing this.
247
+
248
+
For other text editors, please refer to [this LSP clients list](https://langserver.org/#implementations-client).
249
+
250
+
156
251
License: Anything added by me in this repo (not what is based on another project) is public domain or CC0 1.0 Universal. For things taken from other projects, refer to those projects, such as [pkgsrc](https://github.com/NetBSD/pkgsrc).
0 commit comments