Files
LazyVim/lua/lazyvim/util/terminal.lua
Folke Lemaitre 2f4697443c feat(core)!: move a bunch of LazyVim features to snacks.nvim (#4706)
## Description

LazyVim comes with a bunch of smaller QoL plugin like features, but it's
not easy for non LazyVim users to use them.

That's why I started working on
[snacks.nvim](https://github.com/folke/snacks.nvim), a collection of
small QoL plugins for Neovim.

Snacks also includes a bunch of new improvements to these features.

This PR fully integrates with snacks.

## Todo

- [ ] add proper deprecations where needed
- [ ] create snacks docs
- [ ] document all the new improvements relevant to LazyVim users

## Closes

- [ ] #4492 
- [ ] #4333
- [ ] #4687

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

## Checklist

- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-11-07 15:54:47 +01:00

36 lines
1.1 KiB
Lua

---@class lazyvim.util.terminal
local M = {}
---@param shell? string
function M.setup(shell)
vim.o.shell = shell or vim.o.shell
-- Special handling for pwsh
if shell == "pwsh" or shell == "powershell" then
-- Check if 'pwsh' is executable and set the shell accordingly
if vim.fn.executable("pwsh") == 1 then
vim.o.shell = "pwsh"
elseif vim.fn.executable("powershell") == 1 then
vim.o.shell = "powershell"
else
return LazyVim.error("No powershell executable found")
end
-- Setting shell command flags
vim.o.shellcmdflag =
"-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues['Out-File:Encoding']='utf8';"
-- Setting shell redirection
vim.o.shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode'
-- Setting shell pipe
vim.o.shellpipe = '2>&1 | %%{ "$_" } | Tee-Object %s; exit $LastExitCode'
-- Setting shell quote options
vim.o.shellquote = ""
vim.o.shellxquote = ""
end
end
return M