dotfiles

personal dotfiles
git clone anongit@rnpnr.xyz:dotfiles.git
Log | Files | Refs | Feed | Submodules

util.lua (822B)


      1 local util = {}
      2 
      3 function util.splitext(file)
      4 	if file == nil then return nil, nil end
      5 	local i = file:reverse():find('%.')
      6 	if i == nil then return file, nil end
      7 	return file:sub(0, -(i + 1)), file:sub(-i)
      8 end
      9 
     10 function util.message_clear(vis)
     11 	vis:message("") -- hack: focus the message window
     12 	vis.win.file:delete(0, vis.win.file.size)
     13 	vis:command("q")
     14 end
     15 
     16 -- returns a function that when called runs all functions in argv
     17 function util.function_chain(argv)
     18 	return function ()
     19 		for _, f in ipairs(argv) do f() end
     20 	end
     21 end
     22 
     23 -- returns a function that when called runs vis:feedkeys(keys)
     24 function util.feedkeys(keys)
     25 	return function ()
     26 		vis:feedkeys(keys)
     27 	end
     28 end
     29 
     30 -- returns a function that when called runs vis:command(cmd)
     31 function util.command(cmd)
     32 	return function()
     33 		vis:command(cmd)
     34 	end
     35 end
     36 
     37 return util