aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/user/utils.lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-02-14 23:34:30 +0200
committersrdusr <trevorgray@srdusr.com>2023-02-14 23:34:30 +0200
commit71f9f188bc6204526e9a9841715a96f480570238 (patch)
tree007a8489f7c0c3d5e20503d5e3b8874ddcec6ec7 /.config/nvim/lua/user/utils.lua
parent663808c9c384429eb71b3cfb0e28a62f690b03a8 (diff)
parent9e8183c3566221476d96033c6ad2a997a7fa96a5 (diff)
downloaddotfiles-71f9f188bc6204526e9a9841715a96f480570238.tar.gz
dotfiles-71f9f188bc6204526e9a9841715a96f480570238.zip
Merge commit '17547a6d143220d61062c62990584eeb22165493'
Diffstat (limited to '.config/nvim/lua/user/utils.lua')
-rw-r--r--.config/nvim/lua/user/utils.lua125
1 files changed, 0 insertions, 125 deletions
diff --git a/.config/nvim/lua/user/utils.lua b/.config/nvim/lua/user/utils.lua
deleted file mode 100644
index f70fac5..0000000
--- a/.config/nvim/lua/user/utils.lua
+++ /dev/null
@@ -1,125 +0,0 @@
-local M = {}
-
---- Shorten Function Names
-local fn = vim.fn
-function M.executable(name)
- if fn.executable(name) > 0 then
- return true
- end
-
- return false
-end
-
-
---------------------------------------------------
-
---- Check whether a feature exists in Nvim
---- @feat: string
---- the feature name, like `nvim-0.7` or `unix`.
---- return: bool
-M.has = function(feat)
- if fn.has(feat) == 1 then
- return true
- end
-
- return false
-end
-
-
---------------------------------------------------
-
----Determine if a value of any type is empty
----@param item any
----@return boolean?
-function M.empty(item)
- if not item then return true end
- local item_type = type(item)
- if item_type == 'string' then return item == '' end
- if item_type == 'number' then return item <= 0 end
- if item_type == 'table' then return vim.tbl_isempty(item) end
- return item ~= nil
-end
-
---------------------------------------------------
-
---- Create a dir if it does not exist
-function M.may_create_dir(dir)
- local res = fn.isdirectory(dir)
-
- if res == 0 then
- fn.mkdir(dir, "p")
- end
-end
-
-
---------------------------------------------------
-
---- Toggle cmp completion
-vim.g.cmp_toggle_flag = false -- initialize
-local normal_buftype = function()
- return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt"
-end
-M.toggle_completion = function()
- local ok, cmp = pcall(require, "cmp")
- if ok then
- local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag
- if next_cmp_toggle_flag then
- print("completion on")
- else
- print("completion off")
- end
- cmp.setup({
- enabled = function()
- vim.g.cmp_toggle_flag = next_cmp_toggle_flag
- if next_cmp_toggle_flag then
- return normal_buftype
- else
- return next_cmp_toggle_flag
- end
- end,
- })
- else
- print("completion not available")
- end
-end
-
-
---------------------------------------------------
-
---- Make sure using latest neovim version
-function M.get_nvim_version()
- local actual_ver = vim.version()
-
- local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
- return nvim_ver_str
-end
-
-function M.add_pack(name)
- local status, error = pcall(vim.cmd, "packadd " .. name)
-
- return status
-end
-
-
---------------------------------------------------
-
---- Toggle autopairs on/off (requires "windwp/nvim-autopairs")
-function M.Toggle_autopairs()
- local ok, autopairs = pcall(require, "nvim-autopairs")
- if ok then
- if autopairs.state.disabled then
- autopairs.enable()
- print("autopairs on")
- else
- autopairs.disable()
- print("autopairs off")
- end
- else
- print("autopairs not available")
- end
-end
-
-return M
-
-
---------------------------------------------------