robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

anondevegfeat(startup): warn if NVIM_LOG_FILE is inaccessible #3807032aee065a8

master
702 B30 linesraw
1local M = {}
2
3--- Checks that the logfile is accessible.
4function M.check_log_file()
5  if vim.fn.mode() == 'c' then -- Ex mode
6    return
7  end
8
9  local wanted = vim.fn.getenv('__NVIM_LOG_FILE_WANT')
10  if not wanted or wanted == vim.NIL then
11    return
12  end
13
14  local actual = vim.fn.getenv('NVIM_LOG_FILE')
15
16  local msg --[[@type string]]
17  if not actual or actual == vim.NIL or actual == '' then
18    msg = ('log: %q not accessible, logging disabled (stderr)'):format(wanted)
19  elseif actual ~= wanted then
20    msg = ('log: %q not accessible, logging to: %q'):format(wanted, actual)
21  else
22    return
23  end
24
25  vim.defer_fn(function()
26    vim.notify(msg, vim.log.levels.WARN)
27  end, 100)
28end
29
30return M