Skip to content

Commit

Permalink
fix(vim_fn): check return values of vim.fn against 1 (#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jint-lzxy authored May 16, 2023
1 parent 351549c commit ad5eff7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ end

local shell_config = function()
if global.is_windows then
if not (vim.fn.executable("pwsh") or vim.fn.executable("powershell")) then
if not (vim.fn.executable("pwsh") == 1 or vim.fn.executable("powershell") == 1) then
vim.notify(
[[
Failed to setup terminal config
Expand All @@ -134,7 +134,7 @@ You're recommended to install PowerShell for better experience.]],

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("shell", vim.fn.executable("pwsh") == 1 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", {})
Expand Down
2 changes: 1 addition & 1 deletion lua/keymap/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end

local _lazygit = nil
_G._toggle_lazygit = function()
if vim.fn.executable("lazygit") then
if vim.fn.executable("lazygit") == 1 then
if not _lazygit then
_lazygit = require("toggleterm.terminal").Terminal:new({
cmd = "lazygit",
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ return function()
mason_lspconfig.setup_handlers({ mason_handler })

-- Set lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here.
if vim.fn.executable("dart") then
if vim.fn.executable("dart") == 1 then
local _opts = require("completion.servers.dartls")
local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
nvim_lsp.dartls.setup(final_opts)
Expand Down

0 comments on commit ad5eff7

Please sign in to comment.