bennyp
bennyp•2w ago

Writing the whole buffer to stdout

TL;DR: How to i make sure an entire buffer is written to stdout before continuing? Hello! I'm naively implementing the language server protocol in Deno, based on some youtube tutorials 🤣 I've noticed quite some jank, errors, and dead handlers in my clients, for example, this complaint from neovim:
LSP[design_tokens_ls]: Error INVALID_SERVER_JSON: "Expected value but found invalid token at character 1"
Error executing callback:
/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:256: /usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:72: Headers were expected, a different response was received. The server response was '48

{"jsonrpc":"2.0","id":13,"result":[{"color":{"red":0,"green":0.93,"blue":0,"alpha":1},"range":{"start":{"line":2,"character":20},"end":{"line":2,"character":39}}},{"color":{"red":0,"green":0,"blue":0.93,"alpha":1},"range":{"start":{"line":3,"character":13},"end":{"line":3,"character":31}}},{"color":{"red":0,"green":0,"blue":0.93,"alpha":1},"range":{"start":{"line":4,"character":25},"end":{"line":4,"character":48}}},{"color":{"red":0,"green":0.93,"blue":0,"alpha":1},"range":{"start":{"line":4,"character":25},"end":{"line":4,"character":48}}}]}'.
LSP[design_tokens_ls]: Error INVALID_SERVER_JSON: "Expected value but found invalid token at character 1"
Error executing callback:
/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:256: /usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:72: Headers were expected, a different response was received. The server response was '48

{"jsonrpc":"2.0","id":13,"result":[{"color":{"red":0,"green":0.93,"blue":0,"alpha":1},"range":{"start":{"line":2,"character":20},"end":{"line":2,"character":39}}},{"color":{"red":0,"green":0,"blue":0.93,"alpha":1},"range":{"start":{"line":3,"character":13},"end":{"line":3,"character":31}}},{"color":{"red":0,"green":0,"blue":0.93,"alpha":1},"range":{"start":{"line":4,"character":25},"end":{"line":4,"character":48}}},{"color":{"red":0,"green":0.93,"blue":0,"alpha":1},"range":{"start":{"line":4,"character":25},"end":{"line":4,"character":48}}}]}'.
Investigating further, I believe the problem is here:
No description
2 Replies
bennyp
bennypOP•2w ago
Inspecting the above error message, it seems clear that data is being lost here. A correct response should look like:
Content-Length: 48

{"jsonrpc": 2.0, "id": 13, "result": ["...etc"]}
Content-Length: 48

{"jsonrpc": 2.0, "id": 13, "result": ["...etc"]}
bennyp
bennypOP•2w ago
Stack Overflow
Completion items not appearing with LSP in neovim
I'm writing a language server in typescript. The idea of the language server is to provide snippets, go-to-def, and hover in CSS files for design tokens (aka css variables) Here's the handler for

Did you find this page helpful?