blob: 4f2b9dc47ef18038c8169a9af97bffd84ed9f836 (
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
34
|
-- misc stuff implemented in lua
local M = {}
function M.do_under_cursor(obj, cb)
return cb(vim.fn.expand(vim.fn.expand(obj)))
end
function M.word_under_cursor(cb)
return M.do_under_cursor('<cword>', cb)
end
function M.expr_under_cursor(cb)
return M.do_under_cursor('<cexpr>', cb)
end
function M.file_under_cursor(cb)
return M.do_under_cursor('<cfile>', cb)
end
function M.open_under_cursor(cmd)
return M.file_under_cursor(function(txt)
if not cmd then
vim.fn.inputsave()
cmd = vim.fn.input('open with: ')
vim.fn.inputrestore()
end
if cmd then
c = vim.loop.spawn(cmd, { args = {txt} }, function() c:close() end)
end
end)
end
return M
|