Comments (20)
This can effectively divide some tasks into additional processes. Exposing additional unixsockets or sockets and named pipes to the outside world, which is not safe in my opinion.
from znvim.
If this is the case, then using restapi is indeed the best solution
from znvim.
In theory, this is possible, but you probably need to use Lua as the callback of the key mapping to pass the message to Zig
from znvim.
Can you explain in detail your specific demand scenario?
from znvim.
Thank you for responding. Let's imagine this scenario:
- I open a Neovim session with a named pipe:
nvim --listen ./nvim.pipe
- I press a keymap in Neovim, let's say
<C-S-o>
. - My already running Zig application receives the signal and connect to that particular Neovim instance.
I could maybe implement a simple REST API in Zig to listen to calls from Neovim. But I'm wondering if there's a more efficient way to achieve the same thing.
Thank you very much.
from znvim.
If you just start a zig instance to connect to neovim, most current solutions start external programs as sub-processes, and use the stdio of the sub-process for communication.
from znvim.
I used to do the same thing when I was working with Go.
I would set up a REST API, and Neovim just use curl to send JSON payload to the REST end point.
from znvim.
For example, coc.nvim, it starts a child process to communicate with it
from znvim.
In short, all kinds of neovim remote clients need to connect to neovim through stdio or named pipe or socket.
from znvim.
For example, coc.nvim, it starts a child process to communicate with it
Thank you. I'm still very confused of how it works but I'll look into it 👍
from znvim.
The channels supported by neovim include socket, named pipe, or stdio (start a child process and directly use the stdio of the child process to communicate with it)
The communication protocol can optionally use the msgpackrpc protocol.
from znvim.
https://neovim.io/doc/user/api.html#rpc-connecting
https://neovim.io/doc/user/channel.html#channel-intro
from znvim.
Would that work if the user start nvim
regularly in a terminal or in tmux
? 🤔
from znvim.
Since in this case the terminal / tmux spawns the nvim
process, not our Zig program.
from znvim.
Of course it can run normally, you just need to let neovim's configuration file actively start a jobstart.
from znvim.
Of course, maintaining an additional restapi as you mentioned before is also a solution.
from znvim.
When started as a child process, the zig instance will be in the same life cycle as neovim
from znvim.
When started as a child process, the zig instance will be in the same life cycle as neovim
Ah... so something like coc.nvim
was started as child process, from Neovim, via jobstart
.
However, I'm trying to connect to a Zig daemon that's already running 🤔, kinda like Emacs.
So.... I think the REST API might be the way to go.. Since spawning a big heavy GUI program every time Neovim is opened seems undesirable.
from znvim.
However, security is a concern, since I'd have to expose a named pipe / port 🤔
from znvim.
Thank you so much for all the answers. 🙏
I'll go with the restapi solution.
from znvim.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from znvim.