2022-01-02 14:53:01 +01:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
function M.search_file(file, args)
|
|
|
|
local Job = require "plenary.job"
|
|
|
|
local stderr = {}
|
2022-07-23 14:16:43 +02:00
|
|
|
local stdout, ret = Job:new({
|
|
|
|
command = "grep",
|
|
|
|
args = { args, file },
|
2023-08-25 11:51:57 +02:00
|
|
|
cwd = vim.loop.cwd(),
|
2022-07-23 14:16:43 +02:00
|
|
|
on_stderr = function(_, data)
|
|
|
|
table.insert(stderr, data)
|
|
|
|
end,
|
|
|
|
}):sync()
|
2022-03-24 16:16:38 +01:00
|
|
|
return ret, stdout, stderr
|
2022-01-02 14:53:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.log_contains(query)
|
|
|
|
local logfile = require("lvim.core.log"):get_path()
|
2022-03-24 16:16:38 +01:00
|
|
|
local ret, stdout, stderr = M.search_file(logfile, query)
|
2022-01-02 14:53:01 +01:00
|
|
|
if ret == 0 then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
if not vim.tbl_isempty(stderr) then
|
|
|
|
error(vim.inspect(stderr))
|
|
|
|
end
|
|
|
|
if not vim.tbl_isempty(stdout) then
|
|
|
|
error(vim.inspect(stdout))
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|