all repos

gopher.nvim @ 011769b

Minimalistic plugin for Go development

gopher.nvim/lua/gopher/_utils/init.lua(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local utils = {}

---@param t table
---@return boolean
function utils.is_tbl_empty(t)
  if t == nil then
    return true
  end
  return next(t) == nil
end

---@param msg string
---@param lvl any
function utils.deferred_notify(msg, lvl)
  vim.defer_fn(function()
    vim.notify(msg, lvl)
  end, 0)
end

-- safe require
---@param  module string module name
function utils.sreq(module)
  local ok, m = pcall(require, module)
  assert(ok, string.format("gopher.nvim dependency error: %s not installed", module))
  return m
end

return utils