Skip to content

Commit fd06ad1

Browse files
authored
feat(nvim): ex-commands :! integration (#4)
* feat(nvim): ex-commands `:!` integration Settings with documentation for using Nushell for: - filtering buffer content through external commands. Now `:!` `:r!` `:w !` work just fine. - vim diff mode with external diff commands `nvim -d {file1} {file2}` with `set diffopt-=internal` - `:make` and quickfix buffer with `makeprg` * fix(nvim): reword comments for options - better clarifications for shelltemp shellredir and shellpipe - remove extra `NOTE:`
1 parent 9c7f8cf commit fd06ad1

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

nvim/init.lua

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,43 @@ if not vim.loop.fs_stat(lazypath) then
2121
end ---@diagnostic disable-next-line: undefined-field
2222
vim.opt.rtp:prepend(lazypath)
2323

24-
-- INFO: settings to set nushell as the shell
25-
vim.opt.shellredir = "--stdin < %s"
26-
vim.opt.shellcmdflag = "-c"
27-
vim.opt.shellquote = ""
28-
vim.opt.shellxquote = " "
29-
vim.opt.shellxescape = ""
24+
25+
-- INFO: settings to set nushell as the shell for the :! command
26+
-- --
27+
-- path to the Nushell executable
3028
vim.opt.sh = "nu"
3129

32-
-- NOTE: you can instead uncomment the following to for instance provide custom config paths
30+
-- WARN: disable the usage of temp files for shell commands
31+
-- because Nu doesn't support `input redirection` which Neovim uses to send buffer content to a command:
32+
-- `{shell_command} < {temp_file_with_selected_buffer_content}`
33+
-- When set to `false` the stdin pipe will be used instead.
34+
-- NOTE: some info about `shelltemp`: https://github.com/neovim/neovim/issues/1008
35+
vim.opt.shelltemp = false
36+
37+
-- string to be used to put the output of shell commands in a temp file
38+
-- 1. when 'shelltemp' is `true`
39+
-- 2. in the `diff-mode` (`nvim -d file1 file2`) when `diffopt` is set
40+
-- to use an external diff command: `set diffopt-=internal`
41+
vim.opt.shellredir = "out+err> %s"
42+
43+
-- flags for nu:
44+
-- * `--stdin` redirect all input to -c
45+
-- * `--no-newline` do not append `\n` to stdout
46+
-- * `--commands -c` execute a command
47+
vim.opt.shellcmdflag = "--stdin --no-newline -c"
48+
49+
-- disable all escaping and quoting
50+
vim.opt.shellxescape = ""
51+
vim.opt.shellxquote = ""
52+
vim.opt.shellquote = ""
53+
54+
-- string to be used with `:make` command to:
55+
-- 1. save the stderr of `makeprg` in the temp file which Neovim reads using `errorformat` to populate the `quickfix` buffer
56+
-- 2. show the stdout, stderr and the return_code on the screen
57+
-- NOTE: `ansi strip` removes all ansi coloring from nushell errors
58+
vim.opt.shellpipe = '| complete | update stderr { ansi strip } | tee { get stderr | save --force --raw %s } | into record'
59+
60+
-- NOTE: you can uncomment the following to for instance provide custom config paths
3361
-- depending on the OS
3462
-- In this particular example using vim.env.HOME is also cross-platform
3563

0 commit comments

Comments
 (0)