vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

digraph.lua

(617B)


      1 -- insert digraphs using vis-digraph(1)
      2 
      3 vis:map(vis.modes.INSERT, "<C-k>", function(keys)
      4 	if #keys < 2 then
      5 		return -1 -- need more input
      6 	end
      7 	local file = io.popen(string.format("vis-digraph '%s' 2>&1", keys:gsub("'", "'\\''")))
      8 	local output = file:read('*all')
      9 	local success, msg, status = file:close()
     10 	if success then
     11 		if vis.mode == vis.modes.INSERT then
     12 			vis:insert(output)
     13 		elseif vis.mode == vis.modes.REPLACE then
     14 			vis:replace(output)
     15 		end
     16 	elseif msg == 'exit' then
     17 		if status == 2 then
     18 			return -1 -- prefix need more input
     19 		end
     20 		vis:info(output)
     21 	end
     22 	return #keys
     23 end, "Insert digraph")