A barebones LSP server for ngn/k.
This is mostly just an experiment, but there’s room for growth. Currently built on top of pygls, the only service it currently offers is basic semantic highlighting. What’s potentially interesting is that semantic highlighting is done through ngn/k’s ffi interface, and the actual parsing of the source to calculate tokens is done with a script written in K.
- poetry - This is mostly used for packaging
- ngn/k - Needed to build the ffi interface library
There is now a pure ngn/k implementation of this LSP, under the k
directory. It’s made up of several files which import each other
with relative paths and thus needs to be run from the directory
containing all of them. Other than that, that’s it. Just run
lsp.k
like so:
$ k lsp.k
The rest of the document describes running the pygls
version.
Building libk.so
or libk.dylib
is mostly left as an exercise to
the reader. See the makefile for a head start. Ideally it would be
as simple as the following:
$ make libk.so
But currently there aren’t targets for Darwin and you may run into
issues for your system. I was mostly able to get away with
replacing -shared
with -dynamiclib -install_name libk.dylib
to
build on my Mac laptop.
Next you can install the python package under the release tab as follows:
$ python3 -m pip install ngnk_lsp-0.1.0.tar.gz
The package comes with the script `ngnklsp` which can be used to start the LSP.
If you’re playing with the code it might be easier to work with the source directly. You can build and install with poetry as follows:
$ poetry build $ poetry install
Once built you want to make sure it’s visible from whereever you
fire up the server, and then run poetry run ngnklsp
from
the directory containing the project. I’ve set DYLD_LIBRARY_PATH
in a startup script.
Also left as an exercise to the reader. :)
I’m happy to post references to relevant info if anyone cares to submit a PR. Here’s what I followed to have it setup on Emacs.
- Adding a new language server ( I use ngnk-mode. )
Basically left up to the community. If there’s interest I may work on it further or someone may want to take this as a starting point or inspiration or whatever.