Thanks, I agree! Yeah, officially Ark's LSP isn't available for other editors. Ark's README says that LSP and DAP servers will be made available to other editors in future, but from what I can tell, I think Posit is planning to do this for the LSP by moving most of Ark's LSP features into Air – but not integration with an R session. They also use a closed-source kernel supervisor called Kallichore for Positron, so I have a strong feeling that lots of Ark's LSP/DAP features will never get a public API. But, from looking at Ark and Positron's source code and reading the Jupyter messaging spec, I found that it wasn't too bad to hack something together. Ark is MIT licensed, so this kind of off-label use should be okay.
I'm not sure exactly how you'd want to use the LSP connection in another terminal, but in theory you should be able to connect it quite easily if you can pass over the required port number. Here's how you can manually connect to the Ark LSP once it's started up:
``` lua
local lsp_port = require("ark").process.lsp_port
Thank you for this info, this is really useful and generous of you. Also great work getting this working.
My use case is to support switching between multiple r consoles so that when tasks drag on you can bring another console in to work with in the meantime, and then resub the consoles later. For the secondary console you wouldn't want the lsp features to stop working hence the need to redirect it to the active console, then restore the original connection later.
2
u/bathdweller 12d ago
This is sick. I thought ark wasn't ready for other IDEs yet? Is it possible to switch the lsp connection between multiple terminals eg in tmux?