GithubHelp home page GithubHelp logo

Comments (4)

jbyuki avatar jbyuki commented on September 26, 2024 1

I added a new API to override how the headless instance is spawned. It allows you to filter arguments and environment variables before it gets passed to the child instance like you proposed. The handle to the instance has to be returned by the callback.

For example:

require"osv".on["start_server"] = function(args, env)
      -- do something with args and env, args is a table and env is a dict
      return vim.fn.jobstart(args, {rpc = true, env = env})
end

I will close this for now, let me know if something else could be done.

from one-small-step-for-vimkind.

tmillr avatar tmillr commented on September 26, 2024 1

Thanks!

I was skimming over the source just now. I haven't tried it out yet, but I think 5417de4 fixes the recursive process spawn issue. But I'll let you know if I run into this again.

from one-small-step-for-vimkind.

tmillr avatar tmillr commented on September 26, 2024

Oh, it seems that nvim -u NONE -i NONE -n +'=require"osv".launch({port = 8086})' isn't working either. This might just be the same issue that I was experiencing last time in #37 (having to do with argv getting copied and reused in child processes recursively). I suppose that launching this plugin simply isn't supported via cli args. If that's the case, maybe we should document it?

Edit: just confirmed that this is indeed the issue as the following works just fine as a workaround:

VIMINIT='=require"osv".launch({env = {VIMINIT = ""}, port = 8086})' nvim --headless -i NONE -n

Other ideas:

  • Filter argv before passing it on
  • Even better: somehow blacklist functions which spawn processes (such as osv.launch()) so that they return immediately if called within a nested/child process. To signal this, maybe we could just set an env var or something (which will be checked inside launch() and any other such funcs). Although, this wouldn't keep other cli args (e.g. -c lua ... or -c luafile ... etc.) from running in nested instances.

...or maybe I'm just going about the whole thing wrong lol.

Also is there a way to make launch() wait for a connection before returning?

from one-small-step-for-vimkind.

jbyuki avatar jbyuki commented on September 26, 2024

Good debugging of the issue. I haven't thought about it too much but at the moment the environment variable solution seem to be the most flexible. Maybe another way because I think this usecase is very specific and only people really knowing the inner working would use it, we should provide a solution so it doesn't affect the general usecase. I was thinking about adding a function to check if the server is already running so you can early exit in that case in the lua commands. How does it sound?

EDIT: Actually, this function is already implemented require"osv".is_running() but it is also true that an environment variable solution would avoid the hassle you had and provide an easier solution. On the other hand, like you say, it doesn't completetly solve the problem as it will still run other lua commands. In the end, the perfect solution would be no configuration from the user, and only spawn an embedded neovim instance without such recursive calls. But how to differentiate lua commands which are used to spawn the neovim instance itself and lua commands for the headless debugging instance?

from one-small-step-for-vimkind.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.