all repos

gopher.nvim @ b4fd34e

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
29
30
31
32
33
34
35
36
37
38
39
return {
  ---@param t table
  ---@return boolean
  empty = function(t)
    if t == nil then
      return true
    end

    return next(t) == nil
  end,

  ---@param s string
  ---@return string
  rtrim = function(s)
    local n = #s
    while n > 0 and s:find("^%s", n) do
      n = n - 1
    end

    return s:sub(1, n)
  end,

  ---@param lib string
  ---@return boolean
  lualib_is_found = function(lib)
    local is_found, _ = pcall(require, lib)
    return is_found
  end,

  ---@param bin string
  ---@return boolean
  binary_is_found = function(bin)
    if vim.fn.executable(bin) == 1 then
      return true
    end

    return false
  end,
}