Files

42 lines
1.2 KiB
Lua

-- Environment detection, so one config behaves sensibly on a laptop and on a bare server.
local M = {}
---@param bin string
---@return boolean
function M.has(bin)
return vim.fn.executable(bin) == 1
end
---@param bins string[]|nil
---@return boolean
function M.has_all(bins)
for _, bin in ipairs(bins or {}) do
if not M.has(bin) then
return false
end
end
return true
end
M.is_ssh = vim.env.SSH_TTY ~= nil or vim.env.SSH_CONNECTION ~= nil
-- True when Neovim can reach a system clipboard natively (macOS, Wayland, X11, WSL, Termux).
function M.has_clipboard_tool()
for _, bin in ipairs { 'pbcopy', 'wl-copy', 'xclip', 'xsel', 'win32yank.exe', 'termux-clipboard-set' } do
if M.has(bin) then
return true
end
end
return false
end
-- Icons are drawn by the terminal you are sitting at, not by the server, so assume yes.
-- Set NVIM_NO_NERD_FONT=1 where that is not true.
M.has_nerd_font = vim.env.NVIM_NO_NERD_FONT == nil
-- NVIM_MINIMAL=1 turns off every auto-install (mason tools, treesitter parsers).
-- Use it on locked-down or offline machines; servers already on PATH still get used.
M.minimal = vim.env.NVIM_MINIMAL ~= nil
return M