summaryrefslogtreecommitdiffstats
path: root/lua/core/misc.lua
blob: 41cbf93a70f80428f0cb247ee263d5e1aaa0f657 (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
local M = {}

M.appid = "Nvim Config"

function M.colorscheme(name)
  vim.cmd('colorscheme '..name)
  for k, v in pairs(vim.fn.getcompletion('', 'color')) do
    if v == name..'.ext' then
      vim.cmd('colorscheme '..name..'.ext')
    end
  end
end

function M.include(fn)
  if not pcall(require, fn) then
    vim.notify('Could not find '..fn, vim.log.levels.WARN, { title = M.appid })
  end
end

function M.readf(fn)
  local f = io.open(fn, "r")
  if not f then return nil end
  local tab = {}
  for l in f:lines() do
    table.insert(tab, l)
  end
  return tab
end

return M