Skip to content

Commit

Permalink
feat(nu support): add
Browse files Browse the repository at this point in the history
This allows things like `:r !ls` to function properly with `nu`, which is not
a POSIX shell. It also makes sure if you change the shell, it uses the default
POSIX shell options.
  • Loading branch information
xav-ie committed Jan 19, 2025
1 parent 7b4a1b0 commit 8695750
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions config/extraConfigLua.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,65 @@ _: {
desc = "Notify when recording macro",
})
'';

# better nu support in nvim
# https://www.kiils.dk/en/blog/2024-06-22-using-nushell-in-neovim/
nuSupport = # lua
''
local posix_shell_options = {
shellcmdflag = "-c",
shellpipe = "2>&1 | tee",
shellquote = "",
shellredir = ">%s 2>&1",
shelltemp = true,
shellxescape = "",
shellxquote = "",
}
local nu_shell_options = {
shellcmdflag = "--login --stdin --no-newline -c",
shellpipe = "| complete \z
| update stderr { ansi strip } \z
| tee { get stderr | save --force --raw %s } \z
| into record",
shellquote = "",
shellredir = "out+err> %s",
shelltemp = false,
shellxescape = "",
shellxquote = "",
}
local function set_options(options)
for k, v in pairs(options) do
vim.opt[k] = v
end
end
local function apply_shell_options()
if vim.opt.shell:get():match("nu$") ~= nil then
set_options(nu_shell_options)
else
set_options(posix_shell_options)
end
end
apply_shell_options()
vim.api.nvim_create_autocmd("OptionSet", {
pattern = "shell",
callback = function()
apply_shell_options()
end,
})
'';

in
# lua
''
${clipBoardConfig}
${caseChangeFunctions}
${nuSupport}
'';
};
}

0 comments on commit 8695750

Please sign in to comment.