1. Alfredo Di Napoli
  2. beduino

Commits

Alfredo Di Napoli  committed 18b0f49

Support for urxvt is broken, need a policy to support various terminals

  • Participants
  • Parent commits ea0639d
  • Branches master

Comments (0)

Files changed (1)

File ftplugin/ocaml.vim

View file
   if BeduinoSessionExists()
     "Attach to an already running session
     echo "Connecting to an already running Beduino session..."
-    call system(g:beduino_default_terminal ." -e tmux attach-session -t beduino &")
+    call system(g:beduino_default_terminal ." -e \"tmux attach-session -t beduino\" &")
     echo "Connected."
   else
     "Change the Beduino owner to be this one
     let g:beduino_owner = getpid()
     echo "Starting a new Beduino session..."
-    call system(g:beduino_default_terminal ." -e tmux new-session -s beduino \"rlwrap ocaml\" &")
+    call system(g:beduino_default_terminal ." -e \"tmux new-session -s beduino 'rlwrap ocaml'\" &")
     echo "Connected."
   endif
 endfun
 
 fun! BeduinoSessionExists()
-  let w:sessions = system("tmux list-session 2>&1 | grep beduino")
-  if (w:sessions != "")
+  let sessions = system("tmux ls 2>&1 | grep beduino")
+  if (sessions != "")
     return 1
   else
     return 0
   endif
 endfun
 
+fun! BeduinoLoadModule()
+  if BeduinoSessionExists()
+    let module_name = expand("%:p:r")
+    let load_cmd = "#load \"". module_name .".cmo\";;"
+    call system("echo \"". escape(load_cmd,"\"") ."\" > ". g:beduino_buffer_location)
+    call system("tmux load-buffer ". g:beduino_buffer_location ."; tmux pasteb -t beduino")
+  endif
+endfun
+
 function! s:NumSort(a, b)
     return a:a>a:b ? 1 : a:a==a:b ? 0 : -1
 endfunction
 "Mnemonic: Beduino (Eval) Buffer
 map <LocalLeader>bb :call BeduinoEvalBuffer()<RETURN>
 
+"Mnemonic: Beduino Load (module)
+map <LocalLeader>bl :call BeduinoLoadModule()<RETURN>
+
 "Mnemonic: Beduino (Eval) Visual (Selection)
 vmap <LocalLeader>bv :<BS><BS><BS><BS><BS>call BeduinoEvalVisual()<RETURN>