added os detection to use powershell in windows instead of cmd

This commit is contained in:
Simon Ziegler
2025-12-12 11:50:11 +01:00
parent 867b395a65
commit 4895b5472b
3 changed files with 28 additions and 11 deletions

View File

@@ -3,7 +3,7 @@ require("config.lazy")
require("typst-preview").setup({
-- This function will be called to determine the root of the typst project
get_root = function(path_of_main_file)
get_root = function()
local root = os.getenv("TYPST_ROOT")
if root then
return root
@@ -13,3 +13,18 @@ require("typst-preview").setup({
})
vim.opt.expandtab = false
--OS detection
local mySysname = vim.loop.os_uname().sysname
local isMac = mySysname == "Darwin"
local isLinux = mySysname == "Linux"
local isWin = mySysname:find("Windows") and true or false
local isWsl = isLinux and vim.loop.os_uname().release:find("Microsoft") and true or false
--Set shell
if isWin then
if vim.fn.executable("pwsh") == 1 then
vim.opt.shell = "pwsh" --"pwsh" for 7.x if installed
else
vim.opt.shell = "powershell" --"powershell" for 5.x
end
end