auto-dark-mode.nvim icon indicating copy to clipboard operation
auto-dark-mode.nvim copied to clipboard

Unreliable with non-standard shell

Open bugabinga opened this issue 1 year ago • 5 comments

I like to use a non-standard shell for vim.opt.shell (Nushell). It happens to work on Linux, but does not on Windows (Nushell is cross-platform).

I think the issue is that query_command in init.lua is a shell script, that assumes the default shells per platform.

I would like to refactor the code to:

  1. change query_command to a table, that always represents one command + arguments (no shell features allowed, e.g. pipes)
  2. change vim.fn.jobstart to vim.system, which is not dependent on the shell option in Neovim.

Thoughts?

bugabinga avatar Feb 27 '24 09:02 bugabinga

Hi! The refactoring of query_command indeed seems nice and makes sense, but

change vim.fn.jobstart to vim.system

I'm not sure about this one, since the plugin relies on vim.fn.jobstart and I don't know how exactly vim.system works, but this is also open to discussion :) I'll try to check out the vim.system API and come back with a reply on that ;)

f-person avatar Feb 27 '24 13:02 f-person

My only concern is that vim.system is very recent (0.10, nightly exclusive at the time of writing). An effort to make query_command shell agnostic sounds like a good idea.

nekowinston avatar Feb 27 '24 13:02 nekowinston

I noticed, that the help file for jobstart states:

		If {cmd} is a List it runs directly (no 'shell').

That means, changing query_command to a table and adapting the parsing of the query result could be enough, right?

bugabinga avatar Feb 27 '24 14:02 bugabinga

Yes. The only shell pipe we're using is in WSL https://github.com/f-person/auto-dark-mode.nvim/blob/76e8d40d1e1544bae430f739d827391cbcb42fcc/lua/auto-dark-mode/init.lua#L100

which I think should be able to be moved into lua native code in https://github.com/f-person/auto-dark-mode.nvim/blob/76e8d40d1e1544bae430f739d827391cbcb42fcc/lua/auto-dark-mode/init.lua#L24-L39

nekowinston avatar Feb 27 '24 14:02 nekowinston

Sorry, I got held up on further reviewing the PR, I'll try to have another look on the weekend. 😅

nekowinston avatar Mar 07 '24 08:03 nekowinston