update: nvim: split pwsh config as a module

This commit is contained in:
qwjyh 2024-02-20 05:00:41 +09:00
parent be47ce7de7
commit 997545c3de
3 changed files with 47 additions and 20 deletions

View file

@ -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

View file

@ -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', '<C-w>k', '<C-\\><C-N><C-w>k', { noremap = true, desc = "Exi
vim.keymap.set('t', '<C-w>l', '<C-\\><C-N><C-w>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')

View file

@ -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