File: digraph.lua

package info (click to toggle)
vis 0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,624 kB
  • sloc: ansic: 23,195; sh: 981; makefile: 363; python: 47
file content (23 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- insert digraphs using vis-digraph(1)

vis:map(vis.modes.INSERT, "<C-k>", function(keys)
	if #keys < 2 then
		return -1 -- need more input
	end
	local file = io.popen(string.format("vis-digraph '%s' 2>&1", keys:gsub("'", "'\\''")))
	local output = file:read('*all')
	local success, msg, status = file:close()
	if success then
		if vis.mode == vis.modes.INSERT then
			vis:insert(output)
		elseif vis.mode == vis.modes.REPLACE then
			vis:replace(output)
		end
	elseif msg == 'exit' then
		if status == 2 then
			return -1 -- prefix need more input
		end
		vis:info(output)
	end
	return #keys
end, "Insert digraph")