diff --git a/bin/install.ps1 b/bin/install.ps1 index c58718b..989928e 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -53,6 +53,7 @@ scoop import .\bin\windows\scoop_apps\scoop_minimal_apps.json # neovim New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\init.lua -Target (Resolve-Path .\dotfiles\neovim\init.lua) -Force New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lualine_setup.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lualine_setup.lua) -Force +New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\term_powershell.lua -Target (Resolve-Path .\dotfiles\neovim\lua\term_powershell.lua) -Force New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lspconfig\server_configurations\satysfi_ls.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lspconfig\server_configurations\satysfi_ls.lua) -Force New-Item -ItemType SymbolicLink -Path ~\AppData\Local\nvim\lua\lspconfig\server_configurations\jetls.lua -Target (Resolve-Path .\dotfiles\neovim\lua\lspconfig\server_configurations\jetls.lua) -Force mkdir $env:LOCALAPPDATA\nvim\after\ftplugin diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 618e9c2..cc70fb7 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -16,6 +16,15 @@ vim.opt.rtp:prepend(lazypath) -- Installing plugins require('lazy').setup({ { "catppuccin/nvim", name = "catppuccin" }, -- Color scheme + { + dir = "./lua/term_powershell.lua", + event = "CmdlineEnter", + config = function() + require("term_powershell").setup { + pwsh = true + } + end + }, { 'folke/which-key.nvim', config = function() @@ -266,26 +275,6 @@ vim.keymap.set('t', 'k', 'k', { noremap = true, desc = "Exi vim.keymap.set('t', 'l', 'l', { noremap = true, desc = "Exit terminal-mode and move to right window." }) ------------------------------------------------------------ --- to use PowerShell on Windows --- original code from :h powershell --- vim script func returns 1/0, while lua evals false only if gets false or nil --- so be sure to compare with 1/0 -if vim.fn.has('win32') == 1 then - -- this evaluation is so slow that I removed windows powershell support - -- if vim.fn.executable('pwsh') == 1 then - vim.opt.shell = 'pwsh' - -- else - -- vim.opt.shell = 'powershell' - -- end - vim.opt.shellcmdflag = - '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;' - vim.opt.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' - vim.opt.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' - vim.opt.shellquote = '' - vim.opt.shellxquote = '' -end - ----------------------------------------------------------- -- comment setting for satysfi local ft = require('Comment.ft') diff --git a/dotfiles/neovim/lua/term_powershell.lua b/dotfiles/neovim/lua/term_powershell.lua new file mode 100644 index 0000000..5f0125c --- /dev/null +++ b/dotfiles/neovim/lua/term_powershell.lua @@ -0,0 +1,37 @@ +-- use PowerShell on Windows +-- original code from :h powershell + +local M = {} + +---@class TermPwshConfig +---@field pwsh? boolean Whether to use pwsh instead of windows powershell. + +---Entry. +---@param option TermPwshConfig +M.setup = function(option) + if vim.fn.has('win32') == 1 then + option = option or {} + if option.pwsh then + vim.opt.shell = 'pwsh' + else + -- this evaluation is so slow + -- vim script func returns 1/0, while lua evals false only if gets false or nil + -- so be sure to compare with 1/0 + if vim.fn.executable('pwsh') == 1 then + vim.opt.shell = 'powershell' + else + vim.opt.shell = 'pwsh' + end + end + -- adding option to disable colored output + -- (ref: https://stackoverflow.com/questions/65735639/powershell-disable-colored-command-output) + vim.opt.shellcmdflag = + '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;$PSStyle.OutputRendering=[System.Management.Automation.OutputRendering]::PlainText;' + vim.opt.shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait' + vim.opt.shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode' + vim.opt.shellquote = '' + vim.opt.shellxquote = '' + end +end + +return M