Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

neovim/lua/bugabinga/options/shell.lua

Raw
local executable = require 'std.executable'

if 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" }'
  vim.opt.shellxquote = ''
end

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