aboutsummaryrefslogtreecommitdiffstats
path: root/lua/utils/simple.lua
blob: bf158a7d2990b71820144c37176c763ba035a445 (plain) (blame)
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
local M = {}

function M.lower(a, b)
  if a > b then return b else return a end
end

function M.tablelength(T)
  local c = 0
  for _ in pairs(T) do c = c + 1 end
  return c
end

function M.cmdcontent(cmd)
  local b = {}
  local a = io.popen(cmd, 'r')
  if a == nil then return end
  for _ in a:lines() do table.insert(b, _) end
  a:close()
  return b
end

function M.longbufl(buf)
  local a = vim.api.nvim_buf_get_lines(buf, 0, -1, true)
  local greatest = 0
  for i, l in ipairs(a) do
    if string.len(a[i]) > greatest then
      greatest = string.len(a[i])
    end
  end
  return greatest
end

return M