trun

Script for parsing any output. Yes, it is all it does.
git clone git://gtms.dev/trun
Log | Files | Refs | README | LICENSE

helper_functions.lua (1100B)


      1 #!/usr/bin/env lua
      2 
      3 -- This is list of functions you can use inside handler
      4 --
      5 -- Run any os command (add `&` for non blocking execution)
      6 os.execute('... &')
      7 
      8 -- Send command to all neovim instances
      9 local nvim_cmd = function(nvim_cmd)
     10   local servers = io.popen('nvr --serverlist')
     11   for socket in servers:lines() do
     12     local cmd = string.format('nvr --servername "%s" -cc "%s" --nostart -s &',
     13                               socket, nvim_cmd)
     14     os.execute(cmd)
     15   end
     16   servers:close()
     17 end
     18 -- TODO: send command to only specific neovim instances.
     19 -- NOTE: to send command to only specific neovim instance, you can create
     20 -- function inside neovim that will determine this.  So for example if you are
     21 -- inside right directory. `vim.fn.getcwd()`
     22 
     23 -- Send notification (in this case: https://github.com/rcarriga/nvim-notify) to
     24 -- neovim instances. Use with `nvim_cmd`.
     25 local nvim_notify = function(msg, title, level)
     26   local cmd = string.format(
     27                 'lua require(\'notify\')(\'%s\', \'%s\', {title=\'%s\'})', msg,
     28                 level, title)
     29   nvim_cmd(cmd)
     30 end
     31 
     32 -- TODO: Add more...
     33