Closed euclidianAce closed 2 months ago
I'd like to use this, but am unclear on how poll.c
is being compiled. How is the tealls.poll
module being added to lua here?
luarocks make
should build the c module and copy the already built lua files to the correct place (to do an in tree build, use luarocks init
to make a local ./luarocks
that works on a local ./lua_modules
) also note that luarocks has no teal integration so you'll have to do cyan build && ./luarocks make
to do a full build
A couple notes: I've been pretty busy and haven't looked at this for a bit. So keep in mind this is a pretty rough draft, and if I recall correctly the event loop is pretty eager to just spin the cpu.
Thanks, I have it building and running now :)
I was getting errors of the form:
no type information for required module: 'dkjson'
no type information for required module: 'lfs'
But was able to avoid these by adding dkjson.d.tl
and lfs.d.tl
files to the project. Do you have a better way of providing type definitions for dependencies?
You can find type definitions for some lua modules in the teal-types repo here. We don't have a great way of distributing them so for now you'll just have to manually download them and add them somewhere to your LUA_PATH
Just want to mention that for some reason I am finding that some RPCs are not received when using this MR. I can clearly see in the neovim LSP log that they are being sent, but they do not appear in the teal-language-server log anywhere
Ok figured out my issue! Turns out you need to explicitly set stdin
to be unbuffered like this:
io.stdin:setvbuf 'no'
io.stdout:setvbuf 'no'
Otherwise, poll.c
will think that there is no data available when there is
Rather than using sockets, this pr implements a small C module wrapping around
poll(2)
to check if stdin has any data. This is preferential to sockets since a suprising amount of clients don't actually support using a socket and only use stdio.Additionally this implements a very rough outline of an event-loop/async work-queue where documents can cancel type checking on themselves if they've been updated before the check completes. This gives a massive speed boost to
textDocument/didChange
so I've also reenabled it. (Previously we only checked ontextDocument/didSave
since typechecking is quite expensive)closes #3
also a windows implementation will have to be figured out since
poll(2)
is a unix thing