ref: 076c1a4f04db2173afb395d0af8c63a5bbcab6a8 firenvim/lua d---------
Remove persistent server
lua: rename {utils,websocket}.lua->firenvim{utils,websocket}.lua
Add luacheck to CI
firenvim.lua: call close_server on abrupt socket close

Hopefully this helps with #493
Various attempts at making sure neovim really shuts down

firenvim.lua: schedule os.exit call separately from :qall!
autoload/firenvim.vim: don't close channel, await closure from parent
Fix firenvim not closing properly

If config.globalSettings didn't exist, an error would be triggered and
prevent proper closure of the the server.
If config.globalSettings did exist, the server itself wouldn't be
properly closed as the socket-specific closure didn't get a proper
handle to the server.
firenvim.lua: make sure vm.fn exists before using it
Explain persistent server mode in documentation
Implement persistent server

Currently buggy if `:qall!` is used.

Closes #197
lua: fix missing `bit` dependency on non-luajit neovim

Closes #327
Fix firenvim breaking on big buffers

This was caused by websocket frames being split up in multiple TCP
frames. The solution is to make sure we don't process frames until
they're complete.

Closes #179.
Make firenvim less secure

This commit removes a check ensuring that the `Origin` of a websocket
was that of the firenvim webextension which started neovim. This check
is removed because Mozilla decided to remove the `Origin` field of
websocket connections created from a webextension context (see
https://bugzilla.mozilla.org/show_bug.cgi?id=1596889 and

An alternative would have been to re-create this field with the
webRequest API. However, there are two blockers: this requires a new
permission (I learned from working on Tridactyl that Firefox is pretty
bad at updating extensions that require new permissions) and Chrome is
going to remove the webRequest API anyway.

Note that firenvim should still be secure for the following reasons:
- It binds itself to a random port
- It uses a 32-bit one time password to make sure that the incomming
  connection is made from the webextension that started neovim.
- Neovim kills itself immediately if the websocket connection can't be

Still, Firenvim is less secure because of this removal: theorically
speaking, a malicious webpage could get lucky and discover the right
port and password combination. Before this removal, this wouldn't have
mattered as pages can't forge the Origin of their websockets.
Force exit if :qall doesn't work

firenvim.lua: use server:nodelay

Luv's server:nodelay disables Nagle's algorithm (an algorithm which
coalesces tcp messages in order to help with bandwidth problems but
introduces higher latency).

Closes #95.
lua/{firenvim,websocket}.lua: split coalesced websocket packets

Closes https://github.com/glacambre/firenvim/issues/26
Merge pull request #48 from glacambre/close_port_and_sockets

Make sure to close socket and port when asked
Make sure to close socket and port when asked
Stop recursive resizing requests

Before this commit, the firenvim frame used a resize event listener on
its own window in order to be able to know when it needed to resize
itself. This was a problem because when it tried to resize itself, it
sent a resizing request to the page, which resized the frame element,
which triggered a resizing event in the frame, causing potentially
infinite resizing requests as long as requested width and height didn't
exactly match.

We fix this in multiple ways:
- First, we remove any padding/margin/borders the frame might have. This
  helps in calculating dimensions closer to the ones the window inside
  the frame will have.
- We stop listening for resize events. There is no way to know what
  event should be listened to or ignored. Instead, when the page
  resizes the frame, it sends a resize request to the page.

This probably closes #18.
Turn native messenger into a neovim plugin

This commit removes the rust component, as described in

Closes https://github.com/glacambre/firenvim/issues/22
Implement websocket-handling in vimscript+lua

This can be tested like this: `echo -ne "HTTP" | nvim -u NORC --headless
-c ":set rtp+=/path/to/plugin" -c "call firenvim#run()"`. The first
character that is output can be ignored and the rest is a port number
you should connect to with a websocket.