desdic / greyjoy.nvim

Launcher for Neovim
MIT License
27 stars 3 forks source link

Fix: pass command into shell in buffer mode #32

Closed costowell closed 2 months ago

desdic commented 2 months ago

Thanks :) but this will be a breaking change (Not that this is a problem) but is it because you only want a single line or do you need something the shell sources when running bash ?

Then it might be better to expand the change a bit and make a

  1. shell_command instead of command
  2. make the shell a variable and default to sh (or maybe vim.opt.shell)
costowell commented 2 months ago

The vscode tasks.json sometimes has the command and args bundled together, and it ends up looking for an executable named, for example, echo hello, instead of just echo. When using toggleterm, this does not happen because the command is passed into the shell. My thought was to keep the behavior consistent and support more possible configs.

In retrospect, I should have elaborated a little more haha :)

costowell commented 2 months ago
2. make the shell a variable and default to sh (or maybe vim.opt.shell)

Totally agree with this. There are some shells that have different syntax that is possibly incompatible with some commands. I think that a shell option is in order, but it should default to sh otherwise.

desdic commented 2 months ago

Totally agree with this. There are some shells that have different syntax that is possibly incompatible with some commands. I think that a shell option is in order, but it should default to sh otherwise.

perfect, didn't see this one .. but if you change it to vim.opt.shell or a variable I'll merge :)

costowell commented 2 months ago

I opted to have a config option which defaults to vim.o.shell. Best of both worlds :)

desdic commented 2 months ago

Just testet it and its throwing an error .. does it work for you ? it seems like the config is nil

Error executing vim.schedule lua callback: Vim:E475: Invalid value for argument cmd: 'v:null' is not executable                                                           
stack traceback:                                                                                                                                                          
        [C]: in function 'jobstart'                                                                                                                                       
        /home/kgn/src/private/greyjoy.nvim/lua/greyjoy/init.lua:188: in function 'to_buffer'                                                                              
        /home/kgn/src/private/greyjoy.nvim/lua/greyjoy/init.lua:98: in function 'cb'                                                                                      
        ...ocal/share/nvim/lazy/dressing.nvim/lua/dressing/util.lua:206: in function <...ocal/share/nvim/lazy/dressing.nvim/lua/dressing/util.lua:202>                    
        [C]: in function 'wait'                                                                                                                                           
        /home/kgn/.local/share/nvim/lazy/nvim-lint/lua/lint.lua:166: in function 'cancel'                                                                                 
        /home/kgn/.local/share/nvim/lazy/nvim-lint/lua/lint.lua:254: in function 'try_lint'                                                                               
        /home/kgn/.config/nvim/lua/plugins/nvim-lint.lua:46: in function </home/kgn/.config/nvim/lua/plugins/nvim-lint.lua:45>   

and vim.o.shell contains zsh don't know if there is an option for full path (checking)

desdic commented 2 months ago

yes if you change

local shell_command = { config["default_shell"], "-c", commandstr }

to

local shell_command = { greyjoy.default_shell, "-c", commandstr }

then it works :)

regarding the shell then vim.opt.shell._info.default gives full path but its fine with my to have the non full path

desdic commented 2 months ago

Merged and thank you for the MR :)