Giter Club home page Giter Club logo

Comments (6)

dbarnett avatar dbarnett commented on July 28, 2024

@tarruda @equalsraf
Any idea whether this is intentional behavior? Is it actually parsing the command and emulating a subshell on the vim end?

It is kind of a hack how vroom catches system calls, but we don't really have any better alternatives short of modifying vim. Maybe we could detect and handle neovim specially? I don't really want to try parsing commands looking for subshells in vroom, though.

from vroom.

tarruda avatar tarruda commented on July 28, 2024

Any idea whether this is intentional behavior? Is it actually parsing the command and emulating a subshell on the vim end?

As far as I know, no emulation is done on vim/nvim. system() simply passes the input string to the shell, though in nvim this function was recently modified to use pipes for writing input and reading output(vim uses temporary files)

What command vroom sends to vim/nvim when it finds an expectation like ! (echo failed >&2 && exit 1) 2> /tmp/* (glob)?

I wonder if this is related to #36. If so, maybe this will fix it

from vroom.

dbarnett avatar dbarnett commented on July 28, 2024

It evaluates to system('(echo failed >&2 && exit 1) 2> /tmp/nvimIOIkOk/2') in both vim and nvim, with &shell set to shell.vroomfaker. Without the parentheses it works as expected, but with them it executes only what's inside the parentheses.

I'd be surprised if it was related to special characters, but we could always see if the fix for #36 makes any difference.

from vroom.

equalsraf avatar equalsraf commented on July 28, 2024

Does not seem to be related. Internally the command Neovim passes to os_system is

(echo failed >&2 && exit 1) 2> /tmp/foo

this in turn gets converted into

shell.vroomfaker -c (echo failed >&2 && exit 1) 2> /tmp/foo

Up to the point where uv_spawn() is called. Command arguments also seem correct (-c is argv[1] and the remaining argv[2]).

I've added some debug statements to shell.vroomfaker, e.g. sys.argv is

sys.argv:     shell.vroomfaker -c (echo failed >&2 && exit 1) 2> /tmp/foo
sys.argv[2]: (echo failed >&2 && exit 1) 2> /tmp/foo
command:     echo failed >&2 && exit 1

Now the same debug statements for vim mode looks like this

sys.argv:     shell.vroomfaker -c ((echo failed >&2 && exit 1) 2> /tmp/foo) > /tmp/v5bLAKo/0
sys.argv[2]: ((echo failed >&2 && exit 1) 2> /tmp/foo) > /tmp/v5bLAKo/0
command:     (echo failed >&2 && exit 1) 2> /tmp/foo

Based on the comments in SplitCommand vroom seems to be extracting the contents of a parenthesis block on the assumption Vim calls (CMD) > TMPFILE - except Neovim just passes the command without the parenthesis or the temp file redirect.

Is this it or did I miss something?

from vroom.

equalsraf avatar equalsraf commented on July 28, 2024

Not sure this is the preferred way to go about it but here is a quick fix to disable SplitCommand for Neovim using an environment variable

index 80e3dd6..50b8e6d 100755
--- a/scripts/shell.vroomfaker
+++ b/scripts/shell.vroomfaker
@@ -41,7 +41,10 @@ try:
     controls = pickle.load(f)

   # Parse the user command out from vim's gibberish.
-  command, rebuild = vroom.vim.SplitCommand(sys.argv[2])
+  if os.getenv('VROOM_NEOVIM'):
+    command, rebuild = (sys.argv[2], lambda cmd: cmd)
+  else:
+    command, rebuild = vroom.vim.SplitCommand(sys.argv[2])
   logs.append(vroom.test.Received(command))
   handled = False

diff --git a/vroom/neovim_mod.py b/vroom/neovim_mod.py
index f50ec42..aececd7 100644
--- a/vroom/neovim_mod.py
+++ b/vroom/neovim_mod.py
@@ -21,6 +21,7 @@ class Communicator(VimCommunicator):
         '-c', 'set shell=' + args.shell,
         '-c', 'source %s' % CONFIGFILE]
     env['NVIM_LISTEN_ADDRESS'] = args.servername
+    env['VROOM_NEOVIM'] = '1'
     self.env = env
     self._cache = {}

from vroom.

dbarnett avatar dbarnett commented on July 28, 2024

Thanks for digging into the details. Looks like a fine approach to me. Want to add some comments and send it as a pull req?

from vroom.

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.