blob: 6dd1f00ca9deca7ab454d6c0882181fab3619607 (
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
|
local M = {}
function M.textreg(s)
return { lines = { tostring(s) }, type = 'v' }
end
function M.readonly(getter)
return {
read = function() return M.textreg(getter()) end,
write = function() return false end,
readonly = true,
}
end
function M.path(path)
return vim.fn.expand(path)
end
function M.shell_quote(s)
return "'" .. s:gsub("'", "'\\''") .. "'"
end
function M.system(argv, input, label)
local result = vim.system(argv, { text = false, stdin = input }):wait()
if result.code ~= 0 then
error((label or argv[1]) .. ': ' .. (result.stderr or ('exit status ' .. result.code)))
end
return result.stdout or ''
end
return M
|