Skip to content

Commit 13c8b58

Browse files
authored
Merge pull request #11 from hellium6/zls-pkg
Add devel/zls-master and devel/zls-0.14.0 packages
2 parents ff6fd49 + 393f752 commit 13c8b58

File tree

11 files changed

+200
-0
lines changed

11 files changed

+200
-0
lines changed

README.md

+95
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,99 @@ zig-master-0.15.0-dev.77+aa8aa6625 Programming language designed for robustness
153153
$ doas pkg_delete zig-master-0.15.0-dev.77+aa8aa6625
154154
```
155155

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+
156251
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).

pkgsrc/devel/zls-0.14.0/DESCR

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The Zig Language Server (ZLS) is a tool that implements
2+
Microsoft's Language Server Protocol for Zig in Zig.
3+
In simpler terms: it'll provide you with completions,
4+
go-to definition, etc. when you write Zig code!
5+
6+
(This modified package installs in a different prefix than usual which
7+
might be something like: /usr/pkg/zig-0.14.0)

pkgsrc/devel/zls-0.14.0/Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# $NetBSD: Makefile,v 1.4 2024/08/13 19:41:04 wiz Exp $
2+
3+
DISTNAME= zls-0.14.0
4+
CATEGORIES= devel
5+
MASTER_SITES= ${MASTER_SITE_GITHUB:=zigtools/}
6+
GITHUB_PROJECT= zls
7+
GITHUB_TAG= ${PKGVERSION_NOREV}
8+
9+
## We prepare a version suffix code to make the name unique.
10+
## Allows to install this package with devel/zls in same system.
11+
APPEND_VER= ${DISTNAME:S/zls-//:S/.//g}
12+
PKGNAME= ${DISTNAME:S/zls-/zls-isolated${APPEND_VER}-/}
13+
14+
COMMENT= Language Server for zig (prefix isolated)
15+
MAINTAINER= [email protected]
16+
HOMEPAGE= https://github.com/zigtools/zls/
17+
LICENSE= mit
18+
19+
ZIGSTRIP= no
20+
21+
# Temporary required, a zig build system parser is being written.
22+
ALLOW_NETWORK_ACCESS=yes
23+
24+
post-install:
25+
## Binary link for isolated install
26+
${MKDIR} -p ${DESTDIR}${PREFIX}/bin
27+
${LN} -sf ${ZIG_PREFIX}/bin/zls ${DESTDIR}${PREFIX}/bin/zls-${PKGVERSION_NOREV}
28+
29+
.include "zig-depends.mk"
30+
.include "../../lang/zig-0.14.0/application.mk"
31+
.include "../../mk/bsd.pkg.mk"

pkgsrc/devel/zls-0.14.0/PLIST

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@comment $NetBSD$
2+
bin/zls-${PKGVERSION}
3+
zig-${PKGVERSION}/bin/zls

pkgsrc/devel/zls-0.14.0/distinfo

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$NetBSD: distinfo,v 1.1 2024/04/29 13:27:52 nikita Exp $
2+
3+
BLAKE2s (zls-0.14.0.tar.gz) = 44a15f6654263ddf3d8d1819104339eee91b731c6e45c1ef2eddfdda6563df90
4+
SHA512 (zls-0.14.0.tar.gz) = 2f48c3fbb4956799f367adfd598694cf3a92e8c52cdbba699656d9e54897e2f3980e54a17d2f7391cf39f2bf3c8c1bf0042d403d4cea099a6adf57a949617ffc
5+
Size (zls-0.14.0.tar.gz) = 395229 bytes
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# $NetBSD: zig-depends.mk,v 1.1 2024/04/29 13:27:52 nikita Exp $
2+
3+
## Updated from ${WRKDIR}/zls-0.14.0/build.zig.zon
4+
ZIG_PACKAGE_DEPENDS+= https://github.com/ziglibs/known-folders/archive/aa24df42183ad415d10bc0a33e6238c437fc0f59.tar.gz
5+
ZIG_PACKAGE_DEPENDS+= https://github.com/ziglibs/diffz/archive/ef45c00d655e5e40faf35afbbde81a1fa5ed7ffb.tar.gz

pkgsrc/devel/zls-master/DESCR

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
The Zig Language Server (ZLS) is a tool that implements
2+
Microsoft's Language Server Protocol for Zig in Zig.
3+
In simpler terms: it'll provide you with completions,
4+
go-to definition, etc. when you write Zig code!
5+
6+
(This modified package installs in a different prefix than usual which
7+
might be something like: /usr/pkg/zig-master)

pkgsrc/devel/zls-master/Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# $NetBSD: Makefile,v 1.4 2024/08/13 19:41:04 wiz Exp $
2+
3+
DISTNAME= master
4+
CATEGORIES= devel
5+
## If you get checksum error, run "make makesum" first.
6+
MASTER_SITES= https://github.com/zigtools/zls/archive/refs/heads/
7+
EXTRACT_SUFX= .zip
8+
9+
## "0.15.0-dev" part is taken from ".version" line on build.zig.zon
10+
## Please update if necessary.
11+
PKGNAME= zls-master-0.15.0-dev
12+
13+
## zls master archive extracts in a different dir
14+
WRKSRC= ${WRKDIR}/zls-master
15+
16+
COMMENT= Language Server for zig (prefix isolated)
17+
MAINTAINER= [email protected]
18+
HOMEPAGE= https://github.com/zigtools/zls/
19+
LICENSE= mit
20+
21+
ZIGSTRIP= no
22+
23+
# Temporary required, a zig build system parser is being written.
24+
ALLOW_NETWORK_ACCESS=yes
25+
26+
post-install:
27+
## Binary link for isolated install
28+
${MKDIR} -p ${DESTDIR}${PREFIX}/bin
29+
${LN} -sf ${ZIG_PREFIX}/bin/zls ${DESTDIR}${PREFIX}/bin/zls-master
30+
31+
.include "zig-depends.mk"
32+
.include "../../lang/zig-master/application.mk"
33+
.include "../../mk/bsd.pkg.mk"

pkgsrc/devel/zls-master/PLIST

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@comment $NetBSD$
2+
bin/zls-master
3+
zig-master/bin/zls

pkgsrc/devel/zls-master/distinfo

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$NetBSD: distinfo,v 1.1 2024/04/29 13:27:52 nikita Exp $
2+
3+
BLAKE2s (master.zip) = 22d5b9c0a1247d74c7706db265937125a47417c030d996990ff830fe0b9665c6
4+
SHA512 (master.zip) = aefc4b2d9a12020fe2226f3791bfef432d75566321ea5c6d0ac8e6682e925387e0b0b3eea26fa4e870aed9d4ea9bce62229c30cc297fbf718a01fd662941239a
5+
Size (master.zip) = 437904 bytes
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# $NetBSD: zig-depends.mk,v 1.1 2024/04/29 13:27:52 nikita Exp $
2+
3+
## Updated from ${WRKDIR}/zls-master/build.zig.zon
4+
## Please update if necessary.
5+
ZIG_PACKAGE_DEPENDS+= https://github.com/ziglibs/known-folders/archive/aa24df42183ad415d10bc0a33e6238c437fc0f59.tar.gz
6+
ZIG_PACKAGE_DEPENDS+= https://github.com/ziglibs/diffz/archive/ef45c00d655e5e40faf35afbbde81a1fa5ed7ffb.tar.gz

0 commit comments

Comments
 (0)