Skip to content

Commit

Permalink
fix(font-encoding): fix invalid characters on windows, fix #639 (#659)
Browse files Browse the repository at this point in the history
Co-authored-by: 冷酔閑吟 <50296129+Jint-lzxy@users.noreply.github.com>
  • Loading branch information
CharlesChiuGit and Jint-lzxy committed Apr 23, 2023
1 parent be8150f commit e2cfef9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,42 @@ local clipboard_config = function()
end
end

local shell_config = function()
if global.is_windows then
if not (vim.fn.executable("pwsh") or vim.fn.executable("powershell")) then
vim.notify(
[[
Failed to setup terminal config
PowerShell is either not installed, missing from PATH, or not executable;
cmd.exe will be used instead for `:!` (shell bang) and toggleterm.nvim.
You're recommended to install PowerShell for better experience.]],
vim.log.levels.WARN,
{ title = "[core] Runtime error" }
)
return
end

local basecmd = "-NoLogo -MTA -ExecutionPolicy RemoteSigned"
local ctrlcmd = "-Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8"
vim.api.nvim_set_option_value("shell", vim.fn.executable("pwsh") and "pwsh" or "powershell", {})
vim.api.nvim_set_option_value("shellcmdflag", string.format("%s %s;", basecmd, ctrlcmd), {})
vim.api.nvim_set_option_value("shellredir", "-RedirectStandardOutput %s -NoNewWindow -Wait", {})
vim.api.nvim_set_option_value("shellpipe", "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode", {})
vim.api.nvim_set_option_value("shellquote", nil, {})
vim.api.nvim_set_option_value("shellxquote", nil, {})
end
end

local load_core = function()
createdir()
disable_distribution_plugins()
leader_map()

neovide_config()
clipboard_config()
shell_config()

require("core.options")
require("core.mapping")
Expand Down
2 changes: 1 addition & 1 deletion lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ local function load_options()
-- Fix sqlite3 missing-lib issue on Windows
if global.is_windows then
-- Download the DLLs form https://www.sqlite.org/download.html
vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400100/sqlite3.dll"
vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400200/sqlite3.dll"
end
end

Expand Down

0 comments on commit e2cfef9

Please sign in to comment.