repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/lua/bugabinga/options/shell.lua

Raw
if vim.fn.executable 'nu' then
  -- integrate Nushell with nvim
  vim.opt.shell = 'nu --error-style plain --table-mode none'
  -- flags for nu:
  -- * `--stdin`       redirect all input to -c
  -- * `--no-newline`  do not append `\n` to stdout
  -- * `--commands` execute a command
  vim.opt.shellcmdflag = '--error-style plain --table-mode none --stdin --no-newline --commands'
  -- string to be used to put the output of shell commands in a temp file
  -- 1. when 'shelltemp' is `true`
  -- 2. in the `diff-mode` (`nvim -d file1 file2`) when `diffopt` is set
  --    to use an external diff command: `set diffopt-=internal`
  vim.opt.shellredir = 'out+err> "%s"'
  -- string to be used with `:make` command to:
  -- 1. save the stderr of `makeprg` in the temp file which Neovim reads using `errorformat` to populate the `quickfix` buffer
  -- 2. show the stdout, stderr on the screen
  -- NOTE: `ansi strip` removes all ansi coloring from nushell errors
  vim.opt.shellpipe =
  '| complete | get stderr stdout | str join (char nl) | ansi strip | tee { save --force --raw "%s" }'
  -- WARN: disable the usage of temp files for shell commands
  -- because Nu doesn't support `input redirection` which Neovim uses to send buffer content to a command:
  --      `{shell_command} < {temp_file_with_selected_buffer_content}`
  -- When set to `false` the stdin pipe will be used instead.
  -- NOTE: some info about `shelltemp`: https://github.com/neovim/neovim/issues/1008
  vim.opt.shelltemp = false
  vim.opt.shellxquote = ''
  vim.opt.shellxescape = ''
  vim.opt.shellquote = ''
end

require 'bugabinga.health'.add_dependency
{
  name = 'Nushell',
  name_of_executable = 'nu',
}