From f854c49c29eddbb1082f6ad2f729a366acaa4d3d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 28 Feb 2022 11:31:26 +0100 Subject: [PATCH] home: vim: add 'ambroisie.utils' lua module --- home/vim/default.nix | 1 + home/vim/lua/ambroisie/utils.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 home/vim/lua/ambroisie/utils.lua diff --git a/home/vim/default.nix b/home/vim/default.nix index bb7bdec..ea964cc 100644 --- a/home/vim/default.nix +++ b/home/vim/default.nix @@ -13,6 +13,7 @@ let "after" "autoload" "ftdetect" + "lua" "plugin" ]; in diff --git a/home/vim/lua/ambroisie/utils.lua b/home/vim/lua/ambroisie/utils.lua new file mode 100644 index 0000000..8a6cb0f --- /dev/null +++ b/home/vim/lua/ambroisie/utils.lua @@ -0,0 +1,17 @@ +local M = {} + +--- checks if a given command is executable +---@param cmd string? command to check +---@return boolean executable +M.is_executable = function(cmd) + return cmd and vim.fn.executable(cmd) == 1 +end + +--- return a function that checks if a given command is executable +---@param cmd string? command to check +---@return fun(cmd: string): boolean executable +M.is_executable_condition = function(cmd) + return function() return M.is_executable(cmd) end +end + +return M