commit 07e380ea17cf80f6fafb747ce7fdc06527e73ed6
parent 89734f96ed141e70cdd232d45ceed00a99f48b03
Author: mcol <mcol@posteo.net>
Date: Thu, 6 Dec 2018 11:06:32 +0000
begin work on using tmux so running code does not depend on X
Diffstat:
M | ftplugin/matlab.vim | | | 148 | ++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- |
1 file changed, 86 insertions(+), 62 deletions(-)
diff --git a/ftplugin/matlab.vim b/ftplugin/matlab.vim
@@ -47,6 +47,7 @@ setlocal fo+=croql
setlocal comments=:%>,:%
+
"------------------------------------------------------------------
" Auto closing of for, if, switch statements
"------------------------------------------------------------------
@@ -62,8 +63,10 @@ if !exists("g:no_vimlab_autoend")
endif
call append(l:endline, "end")
norm =ip`m
+ call feedkeys("A")
+ else
+ call feedkeys("i")
endif
- call feedkeys("A")
endfunction
inoremap <unique> <buffer> <silent> if<space> if<space><Esc>:call VimlabAutoEnd()<CR>
@@ -74,6 +77,62 @@ endif
"------------------------------------------------------------------
+" Matlab section folding
+"------------------------------------------------------------------
+
+" remember folding layout
+autocmd BufWinLeave *.m mkview
+autocmd BufWinEnter *.m silent loadview
+
+" format folded section header text
+function! MyFoldText()
+ let line = getline(v:foldstart)
+
+ let nucolwidth = &fdc + &number * &numberwidth
+ let windowwidth = winwidth(0) - nucolwidth - 3
+ let foldedlinecount = v:foldend - v:foldstart
+
+ let onetab = strpart(' ', 0, &tabstop)
+ let line = substitute(line, '\t', onetab, 'g')
+
+ let line = strpart(line, 0, windowwidth - len(foldedlinecount))
+ let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
+ return line . repeat(" ",fillcharcount) . ' ' . foldedlinecount
+endfunction
+set foldtext=MyFoldText()
+
+
+" This is from ebranlard/vim-matlab-behave
+" enable matlab section folding
+function! MatlabFolds()
+ let thisline = getline(v:lnum)
+ if match(thisline,'^[\ ]*%%') >=0
+ return ">1"
+ else
+ return "="
+ endif
+endfunction
+setlocal foldmethod=expr
+setlocal foldexpr=MatlabFolds()
+
+
+
+"------------------------------------------------------------------
+" delete input argument in function line
+"------------------------------------------------------------------
+
+function! VimlabDeleteInput()
+ call search(',\|(\|^', 'bz', line("."))
+ "exec "normal ?,\\|{\\|("
+endfunction
+nnoremap <Plug>VimlabDeleteInput :call VimlabDeleteInput()<CR>
+if !hasmapto('<Plug>VimlabDeleteInput')
+ nmap <unique> <buffer> <silent> <leader>iw <Plug>VimlabDeleteInput
+endif
+
+
+
+"------------------------------------------------------------------
" Session saving and restoration
"------------------------------------------------------------------
" This can be enabled by setting the g:vimlab_session to the path of session file
@@ -100,6 +159,7 @@ if exists("g:vimlab_session")
endif
+
"------------------------------------------------------------------
" Matchit definitions (from Fabrice Guy)
"------------------------------------------------------------------
@@ -125,19 +185,36 @@ if !exists("g:vimlab_terminal")
let g:vimlab_terminal = "urxvtc"
endif
-function! VimlabOpenServer()
- SlimeSend0("op " . expand('<cword>') . " " . g:vimlab_server . " " . g:vimlab_terminal . ";")
-endfunction
-function! VimlabOpenNewWindow()
- SlimeSend0("op " . expand('<cword>') . " " . expand("''") . " " . g:vimlab_terminal . ";")
-endfunction
+"let g:vimlab_use_tmux = 1
+"let g:vimlab_server = "test"
+let g:vimlab_tmux = ".+"
+if exists("g:vimlab_use_tmux")
+ function TmuxNewLine()
+ call system("tmux send -t " g:vimlab_tmux . " enter")
+ endfunction
+ function! VimlabOpenServer()
+ let l:keys = "\"op " . expand('<cword>') . " " . g:vimlab_server . " " . g:vimlab_terminal . ";\""
+ let l:cmd = "tmux send -t " . g:vimlab_tmux
+ call system(l:cmd . " " . l:keys . ' enter')
+ endfunction
+ function! VimlabOpenNewWindow()
+ SlimeSend0("op " . expand('<cword>') . " " . expand("''") . " " . g:vimlab_terminal . ";")
+ endfunction
+else
+ function! VimlabOpenServer()
+ SlimeSend0("op " . expand('<cword>') . " " . g:vimlab_server . " " . g:vimlab_terminal . ";")
+ endfunction
+ function! VimlabOpenNewWindow()
+ SlimeSend0("op " . expand('<cword>') . " " . expand("''") . " " . g:vimlab_terminal . ";")
+ endfunction
+endif
nnoremap <Plug>VimlabOpenServer :call VimlabOpenServer()<CR>
nnoremap <Plug>VimlabOpenNewWindow :call VimlabOpenNewWindow()<CR>
if !hasmapto("<Plug>VimlabOpenServer")
" open when hitting return
- nmap <unique> <buffer> <silent> <CR> <Plug>VimlabOpenServer
+ nmap <unique> <buffer> <CR> <Plug>VimlabOpenServer
endif
if !hasmapto("<Plug>VimlabOpenNewWindow")
@@ -189,6 +266,7 @@ nnoremap <unique> <buffer> <silent> <F2> :SlimeSend0(expand("%:r"))<CR>
nnoremap <unique> <buffer> <silent> <C-w> :SlimeSend1 who<CR>
+
"------------------------------------------------------------------
" Debugging code
"------------------------------------------------------------------
@@ -249,60 +327,6 @@ nnoremap <unique> <buffer> <silent> <Leader>dd :SlimeSend1 dbdown<CR>
-"------------------------------------------------------------------
-" Matlab section folding
-"------------------------------------------------------------------
-
-" remember folding layout
-autocmd BufWinLeave *.m mkview
-autocmd BufWinEnter *.m silent loadview
-
-" format folded section header text
-function! MyFoldText()
- let line = getline(v:foldstart)
-
- let nucolwidth = &fdc + &number * &numberwidth
- let windowwidth = winwidth(0) - nucolwidth - 3
- let foldedlinecount = v:foldend - v:foldstart
-
- let onetab = strpart(' ', 0, &tabstop)
- let line = substitute(line, '\t', onetab, 'g')
-
- let line = strpart(line, 0, windowwidth - len(foldedlinecount))
- let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
- return line . repeat(" ",fillcharcount) . ' ' . foldedlinecount
-endfunction
-set foldtext=MyFoldText()
-
-
-" This is from ebranlard/vim-matlab-behave
-" enable matlab section folding
-function! MatlabFolds()
- let thisline = getline(v:lnum)
- if match(thisline,'^[\ ]*%%') >=0
- return ">1"
- else
- return "="
- endif
-endfunction
-setlocal foldmethod=expr
-setlocal foldexpr=MatlabFolds()
-
-
-
-"------------------------------------------------------------------
-" delete input argument in function line
-"------------------------------------------------------------------
-
-function! VimlabDeleteInput()
- call search(',\|(\|^', 'bz', line("."))
- "exec "normal ?,\\|{\\|("
-endfunction
-nnoremap <Plug>VimlabDeleteInput :call VimlabDeleteInput()<CR>
-if !hasmapto('<Plug>VimlabDeleteInput')
- nmap <unique> <buffer> <silent> <leader>iw <Plug>VimlabDeleteInput
-endif
-
""" end
let &cpo = s:save_cpo