commit 141ae8ea8c62e31d87176d67ca101992bc4f2ddc
parent ec61d49aea9a0388284e7525c33a0984711fa08e
Author: mcol <mcol@posteo.net>
Date: Sun, 25 Nov 2018 20:18:03 +0000
Segmented parts into smaller files, removed hardcoded settings, and added more flexible options set by global variables
Diffstat:
10 files changed, 288 insertions(+), 383 deletions(-)
diff --git a/README.md b/README.md
@@ -1,34 +1,112 @@
-## vimlab
+# vimlab
This is a collection of code sourced from a few places, modified, expanded and put in one place for my own use.
-It is my attempt at making vim with vim-slime as painless as possible when using matlab.
-It is also largely configured to my setup specifically and I don't know how flexible it is.
-#### Features
+It is my attempt at making vim and matlab work together as painlessly as possible. Some things are still a work in progress.
-* [Everything from Fabrice Guy's code](https://www.vim.org/scripts/script.php?script_id=2407), plus:
-* Hitting enter in vim over a word to open it in the variable editor or in vim, if it is a variable or m file.
+## Features
+
+* [Fabrice Guy's](https://www.vim.org/scripts/script.php?script_id=2407) syntax highlighting, matchit pairing of for/end, if/end etc, and indentation rules.
+* Hitting enter in vim on a word to open it in the variable editor or in vim, if it is a variable or m file.
* Better section folding and layout memory
* Lots of matlab's own keybindings for running code lines, sections, selection, script
* Debugging keybindings, including setting and clearing markers and navigating the function stack
* Automatic session saving
-* Automatic code checking and error highlighting with Thomas Ibbotson's mlint functions
-* A script to find .m files in local directories and add them to the list of functions for syntax highlighting
+* Automatic code checking and error highlighting with Thomas Ibbotson's [mlint.vim](https://www.vim.org/scripts/script.php?script_id=2378)
+* A shell script to find .m files in specified local directories and add them to the list of functions for syntax highlighting
+
+## Usage
+
+### vim
+
+Most of the cool stuff requires vim be run in server mode. To run a vim server that can use all the functions here, including automatic session restoration, open it with:
+
+ vim --servername vimlab
+
+### Session restoration
+
+To enable session saving and restoration, add this to your .vimrc:
+
+ let g:vimlab_session = "~/.cache/vim/sessions/matlab-session.vim"
+
+changing the path to where you keep vim sessions, and open vim with:
+
+ vim --servername vimlab -S $HOME/.cache/vim/sessions/matlab-session.vim
+
+You can change the default binding to save and exit (which is XA in normal mode):
+
+ nnoremap XA <Plug>VimlabEndSession
+
+
+### vim-slime
+
+To send commands to matlab, you'll need [vim-slime](https://github.com/jpalardy/vim-slime) set up. Not everything here requires it, so those that do will have * in the subtitle.
+
+### Opening variables, functions or scripts from vim*
+
+Hitting enter when the cursor is on a word will either:
+1. open it in the variable editor if it is a variable, or
+2. open it in the vim server if it is a script or function and on matlabs path.
+
+This requires the included op.m function be on matlab's path.
+
+### Running code*
+
+| Key | Function |
+|----------------|-------------------------------|
+| F9 | run the current paragraph/visual selection (same as <C-c><C-c> from vim-slime).|
+| F8 | run the current line.|
+| F7 | run the current word.|
+| F4 |run the current section (bound by %%).|
+| F2 | run the name of the current file as a script (so must be on matlabs path).|
+| \<C-w\> | run _who_, listing variables in the current workspace.|
+
+### Debugging*
+
+| Key | Function |
+|----------------|-------------------------------|
+| \a | **a**dd a debug marker at the current line (this saves the buffer) |
+| \c | **c**lear the marker at the current line |
+| \s or F10 | **s**tep to the next line in debug mode |
+| \g or F5 | **g**o on with running the code |
+| \e | toggle stopping to debug at **e**rrors |
+| \x | e**x**it debug mode |
+| \f | **f**lush all markers |
+| \ds | list the debug **s**tack |
+| \du | go **u**p the stack |
+| \dd | go **d**own the stack |
+
+These keybindings assume the leader key is the default backslash.
+
+### Code checking
+
+This plugin contains Thomas Ibbotson's [mlint.vim](https://www.vim.org/scripts/script.php?script_id=2378). If mlint isn't on your system's \$PATH, you can set the path by putting this in your .vimrc:
+
+ let g:mlint_path_to_mlint = "$HOME/applications/MATLAB/R2018b/bin/glnxa64/mlint"
+
+This will automatically run mlint when the cursor is idle, but this can be disabled by setting this variable to anything:
+
+ let g:mlint_hover = 1
+
+| Key | Function |
+|------|---------|
+| \ll | run mlint manually |
+| \lm | see the message from the current line |
+| \lo | view an outline of all messages |
+| \ln | jump to the next message |
+| \lp | jump to the previous message |
+
+### Auto close of for, if, switch statements
+
+For, if, and switch statements will automatically get an end placed below them on the next empty line. So if there is a code block on the next line, the statement will surround it. To disable this altogether, set the variable *g:vimlab_no_autoend*
-#### Requirements
+### Misc
-* [vim-slime](https://github.com/jpalardy/vim-slime)
-* MATLAB/R201xx/bin/glnxa64/mlint needs to be on $PATH
-* _packadd! matchit_ should be put in vimrc
-* no doubt other things I have missed
+For matchit word pairing of things such as if/end, allowing the use of % to navigate these pairs, add the following to your .vimrc:
-#### Some sources:
+ packadd! matchit
-* Fabrice Guy for 80% of it
-* Thomas Ibbotson for the mlint code checking functions (todo: add link to its web page)
-* [ebranlard/vim-matlab-behave](https://github.com/ebranlard/vim-matlab-behave) for a few lines of formatting
-#### Todo:
+## Other plugins that go well with this
-* automatic 'end' when writing if/for/switch statements ?
-* make set and clear debug marker a toggle (F12 for normal matlab behaviour)
+* [vim-bbye](https://github.com/moll/vim-bbye)
diff --git a/after/matlab.vim b/after/matlab.vim
@@ -3,8 +3,7 @@
"
" Place in your after/ftplugin directory.
"
-" Last Change: 2011 Oct 21
-" Maintainer: Thomas Ibbotson <thomas.ibbotson@gmail.com>
+" Last Change: 2018-11-25 (added next/previous keybindings)
" License: Copyright 2008-2009, 2011 Thomas Ibbotson
" This program is free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
@@ -40,6 +39,7 @@
if exists("b:did_mlint_plugin")
finish
endif
+
" This variable can be anything as long as it exists.
" We may as well set it to something useful (like the version number)
let b:did_mlint_plugin = 6
@@ -60,6 +60,16 @@ if !hasmapto('<Plug>mlintOutline')
map <buffer> <unique> <LocalLeader>lo <Plug>mlintOutline
endif
+if !hasmapto(':cnext<CR>')
+ map <buffer> <unique> <LocalLeader>ln :cnext<CR>
+endif
+
+if !hasmapto(':cprevious<CR>')
+ map <buffer> <unique> <LocalLeader>lp :cprevious<CR>
+endif
+
+
+
if !hasmapto('<SID>RunLint')
noremap <unique> <script> <Plug>mlintRunLint <SID>RunLint
noremap <SID>RunLint :call <SID>RunLint()<CR>
diff --git a/doc/matlab.txt b/doc/matlab.txt
@@ -1,111 +0,0 @@
-MatlabEditionFiles *matlab* *MatlabEditionFiles*
-A set of files useful to edit Matlab files.
-
-Included is :
-1. Syntax highlighting |matlab-syntax|
-2. Using the matchit.vim script |matlab-matchit|
-3. Correct indentation |matlab-indent|
-4. Integration of the mlint Matlab code checker |matlab-compiler|
-5. Tag support |matlab-tags|
-6. Installation details |matlab-instal|
-
-================================================================================
-1. Syntax highlighting *matlab-syntax*
-
-syntax/matlab.vim : Updates the matlab.vim syntax file provided in the vim
-distribution :
-- highlights keywords dealing with exceptions : try / catch / rethrow
-- highlights keywords dealing with class definitions : classdef / properties /
- methods / events
-
-================================================================================
-2. Correct settings in order to use the matchit.vim script *matlab-matchit*
-
-The matchit.vim extends the % matching and enables to jump through matching
-groups such as "if/end" or "switch/end" blocks (see :help matchit in vim)
-
-ftplugin/matlab.m provides the suitable definition for b:match_words in order
-to jump between if/end, classdef/end, methods/end, events/end, properties/end,
-while/end, for/end, switch/end, try/end, function/end blocks
-
-================================================================================
-3. Correct indentation *matlab-indent*
-
- indent/matlab.vim : Updates the matlab.vim indention file
-provided in the vim distribution. This script provides a correct indentation
-for :
-- switch / end, try / catch blocks
-- classdef / methods / properties / events
-- mutli-line (lines with line continuation operator (...))
-
-This script has been tested with the Matlab R2008a release on many files and
-the result of indentation compared to the one provided by the Matlab Editor
-(using the 'indent all functions' option).
-
-NOTE : to work correctly, this script need the matchit.vim (vimscript#39) to
-be installed. (see also |matchit|)
-
-================================================================================
-4. Integration of the mlint Matlab code checker *matlab-compiler*
-
-compiler/mlint.m provides the settings to use mlint (Matlab code ckecker) and
-puts the messages reported in the quickfix buffer.
-
-Whenever you want to check your code, just type :make and then :copen and vim
-opens a quickfix buffer which enables to jump to errors (using :cn, :cp or
-Enter to jump to the error under the cursor : see |quickfix| in vim)
-
-================================================================================
-5. Tag support *matlab-tags*
-The .ctags file (in the matlab.zip) defines the Matlab language so that the
-exuberant ctags (http://ctags.sourceforge.net ) can construct the tag file :
-you can now jump to tags (using CTRL-] (or CTRL-$ if using Windows) and go
-back again (CTRL-T) See |tags| in vim.
-
-These scripts have been tested using gvim 7.2 and Matlab R2008a on Windows.
-
-================================================================================
-6. Installation details *matlab-instal*
-
-The package is matlab.zip : just unzip it to extract the files.
-
-- help file
-
- Copy doc/matlab.txt to your $HOME/vimfiles/doc directory.
- And then run the command to create help for matlab : >
- :helptags $HOME/vimfiles/doc
-< Then the command >
- :help matlab
-< is available
-
-- Syntax highlighting
- Copy syntax/matlab.vim to your $HOME/vimfiles/syntax
- directory
-
-- Correct settings in order to use the matchit.vim script
- In your vimrc file, add the following line : >
- source $VIMRUNTIME/macros/matchit.vim
-<
- And copy ftplugin/matlab.vim to your $HOME/vimfiles/ftplugin directory
-
-- Correct indentation
- In your vimrc file, add the following lines : >
- source $VIMRUNTIME/macros/matchit.vim
- filetype indent on
-<
- And copy indent/matlab.vim to your $HOME/vimfiles/indent directory
-
-- Integration of the mlint Matlab code checker with the :make command
-
- Add the following line to your vimrc file : >
- autocmd BufEnter *.m compiler mlint
-<
- And copy compiler/mlint.vim to your $HOME/vimfiles/compiler directory
-
-- Tag support
-
- Copy the .ctags to your $HOME directory. And then run the
- command to create your tags file : for example : >
- ctags -R *
-
-
diff --git a/ftplugin/matlab.vim b/ftplugin/matlab.vim
@@ -1,236 +1,75 @@
"------------------------------------------------------------------
-" m-file filetype settings
+" General settings for matlab files
"------------------------------------------------------------------
-" Credit to this section goes to Fabrice Guy
+"
-if exists("b:did_ftplugin")
+if exists("b:did_ftplugin_vimlab")
finish
endif
-let b:did_ftplugin = 1
+let b:did_ftplugin_vimlab = 1
-let s:save_cpo = &cpo
-set cpo-=C
+
+" map hash sign to percentage sign for easier commenting
+inoremap <buffer> # %
setlocal fo+=croql
setlocal comments=:%>,:%
-if exists("loaded_matchit")
- let s:conditionalEnd = '\([-+{\*\:(\/]\s*\)\@<!\<end\>\(\s*[-+}\:\*\/)]\)\@!'
- let b:match_words = '\<classdef\>\|\<methods\>\|\<events\>\|\<properties\>\|\<if\>\|\<while\>\|\<for\>\|\<switch\>\|\<try\>\|\<function\>:' . s:conditionalEnd
-endif
-
-setlocal suffixesadd=.m
-setlocal suffixes+=.asv
-" Change the :browse e filter to primarily show M-files
-if has("gui_win32") && !exists("b:browsefilter")
- let b:browsefilter="M-files (*.m)\t*.m\n" .
- \ "All files (*.*)\t*.*\n"
-endif
-
-let b:undo_ftplugin = "setlocal suffixesadd< suffixes< "
- \ . "| unlet! b:browsefilter"
- \ . "| unlet! b:match_words"
-
-let &cpo = s:save_cpo
-
"------------------------------------------------------------------
-" mlint code checking keybindings
+" Auto closing of for, if, switch statements
"------------------------------------------------------------------
-" mlint is from <MATLABROOT>/bin/<ARCH> and must be on your path
-" mlint.vim from vim-matlab appears to not get sourced automatically
-"runtime vimlab/compiler/mlint.vim
-let g:mlint_path_to_mlint = "/home/mlv/applications/MATLAB/R2018b/bin/glnxa64/mlint"
-runtime vimlab/after/matlab.vim
-
-" check code by running mlin
-"nnoremap <Leader>cc <Plug>mlintRunLint
-"nnoremap <Leader>cg <Plug>mlintGetLintMessage
-"nnoremap <Leader>co <Plug>mlintOutline
-
-" open quickfix to view errors
-"nnoremap <Leader>co :copen<CR>
+if !exists("g:no_vimlab_autoend")
+ function! VimlabAutoEnd()
+ if match(synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name"), "Comment") == -1
+ let l:win_view = winsaveview()
+ call search("^$\\|\\%$", 'W')
+ if line(".") == line("$")
+ :normal! oend
+ else
+ :normal! Oend
+ endif
+ :normal! =ip
+ call winrestview(l:win_view)
+ endif
+ call feedkeys('A')
+ endfunction
-" go to next and previous errors
-"nnoremap <Leader>cn :cn<CR>
-"nnoremap <Leader>cp :cp<CR>
+ inoremap <buffer> <silent> if<space> if<space><Esc>:call Matlab_auto_end()<CR>
+ inoremap <buffer> <silent> for<space> for<space><Esc>:call Matlab_auto_end()<CR>
+ inoremap <buffer> <silent> switch<space> switch<space><Esc>:call Matlab_auto_end()<CR>
+endif
"------------------------------------------------------------------
-" Section folding
+" Session saving and restoration
"------------------------------------------------------------------
-
-" 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
-
- " expand tabs into spaces
- 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 "="
+if exists("g:vimlab_session")
+ function! VimlabSaveSession()
+ wall
+ mksession! g:vimlab_session
+ endfunction
+
+ function! VimlabEndSession()
+ call VimlabSaveSession()
+ confirm qall
+ endfunction
+
+ if !hasmapto('<Plug>VimlabEndSession')
+ nnoremap <buffer> XA <Plug>VimlabEndSession
endif
-endfunction
-setlocal foldmethod=expr
-setlocal foldexpr=MatlabFolds()
-
-
-"------------------------------------------------------------------
-" vim-slime configuration git://github.com/jpalardy/vim-slime.git
-"------------------------------------------------------------------
-let g:slime_target = "tmux"
-let g:slime_dont_ask_default = 1
-let g:slime_default_config = {"socket_name": "default", "target_pane": "1"}
-let g:slime_paste_file = "/tmp/slime_paste"
-
-
-" open word under cursor using op.m function
-" if g:op_cmd_terminal is set to something else (e.g. "xterm"), then this
-" sends that as an additional arg to op.m
-if !exists("g:op_cmd_terminal")
- nnoremap <silent> <CR> yiw:SlimeSend1 op <C-r>" vimlab;<CR>
- nnoremap <silent> <Leader><CR> yiw:SlimeSend1 op <C-r>";<CR>
-else
- exec "nnoremap <silent> <CR> yiw:SlimeSend1 op <C-r>\" vimlab " . g:op_cmd_terminal . ";<CR>"
- exec "nnoremap <silent> <Leader><CR> yiw:SlimeSend1 op <C-r>\" '' " . g:op_cmd_terminal . ";<CR>"
endif
-""" Running code
-" F9 will send paragraph or visual selection
-xmap <F9> <Plug>SlimeRegionSend
-nmap <F9> <Plug>SlimeParagraphSend
-
-" F8 will run current line
-map <F8> <Esc>ms0v$<F9>`s
-
-" F7 will run the current small word
-map <F7> <Esc>msviw<F9>`s
-
-" F4 will run the current section
-map <silent> <F4> ms:mkview<CR>:execute 'try \| foldopen! \| catch \| \| endtry'<CR>$?%%\\|\%^?<CR>v$/%%\\|\%$<CR>?^.*\S<CR>$<F9>`s:let @/=""<CR>:loadview<CR>
-
-" F2 will call script by title, so must be on matlab path
-map <silent> <F2> <Esc>:let @" = expand("%")<CR>:SlimeSend1 <C-r>";<CR>
-
-" list variables
-nnoremap <silent> <C-w> :SlimeSend1 who<CR>
-
-" execute sfig function to save current figure
-nnoremap <silent> <leader>fw :SlimeSend1 sfig('', '', '', 1);<CR>
-
-""" Debugging
-hi matlabDebug ctermfg=2 ctermbg=1 cterm=bold
-
-" toggle debug marker
-function! Matlab_debug_toggle_marker(line)
- if (matchdelete(line(".")) == 0)
- " remove marker
- call SlimeSend1 "dbclear in" . expand("%") . " at " . line(".")
- else
- " add marker
- call matchaddpos('matlabDebug', [line('.')], 10, line('.'))
- call SlimeSend("dbstop in " . expand("%") . " at " . line("."))
- endif
-endfunction
-nnoremap <silent> <Leader>t :call Matlab_debug_toggle_marker(line("."))<CR>
-
-" (a)dd - this will save the buffer, as matlab needs the current version
-nnoremap <silent> <Leader>a :w<CR>:let @" = "dbstop in " . expand("%") . " at " . line(".")<CR>:SlimeSend1 <C-r>"<CR>:call matchaddpos('matlabDebug', [line('.')], 10, line('.'))<CR>
-
-" (c)lear
-nnoremap <silent> <Leader>c :let @" = "dbclear in " . expand("%") . " at " . line(".")<CR>:SlimeSend1 <C-r>"<CR>:call matchdelete(line('.'))<CR>
-
-" (s)tep
-nnoremap <silent> <Leader>s :SlimeSend1 dbstep<CR>
-nnoremap <silent> <F10> :SlimeSend1 dbstep<CR>
-
-" (g)o onward
-nnoremap <silent> <Leader>g :SlimeSend1 dbcont<CR>
-nnoremap <silent> <F5> :SlimeSend1 dbcont<CR>
-
-" stop on (e)rror
-nnoremap <silent> <Leader>e :SlimeSend1 dbstop if error<CR>
-
-" e(x)it debugging
-nnoremap <silent> <Leader>x :SlimeSend1 dbquit all<CR>
-
-" (f)lush all markers
-nnoremap <silent> <Leader>f :call clearmatches()<CR>:SlimeSend1 dbclear all<CR>
-
-" dbstack, dbup and dbdown
-nnoremap <silent> <Leader>ds :SlimeSend1 dbstack<CR>
-nnoremap <silent> <Leader>du :SlimeSend1 dbup<CR>
-nnoremap <silent> <Leader>dd :SlimeSend1 dbdown<CR>
-
-
"------------------------------------------------------------------
-" Writing
+" Matchit definitions (from Fabrice Guy)
"------------------------------------------------------------------
-" map hash sign to percentage sign for commenting
-inoremap # %
-
-
-" colors for comments and section headers
-hi HComment ctermfg=3 cterm=bold
-hi MComment ctermfg=10
-
-
-" automatically add 'end' to if, for and switch statements
-function! Matlab_auto_end()
- if match(synIDattr(synIDtrans(synID(line("."), col("."), 0)), "name"), "Comment") == -1
- let l:win_view = winsaveview()
- call search("^$\\|\\%$", 'W')
- if line(".") == line("$")
- :normal! oend
- else
- :normal! Oend
- endif
- :normal! =ip
- call winrestview(l:win_view)
- endif
- call feedkeys('A')
-endfunction
-inoremap <silent> if<space> if<space><Esc>:call Matlab_auto_end()<CR>
-inoremap <silent> for<space> for<space><Esc>:call Matlab_auto_end()<CR>
-inoremap <silent> switch<space> switch<space><Esc>:call Matlab_auto_end()<CR>
-
-
-" Save matlab session manually
-map <Leader>ss :w<CR>:mksession! ~/.cache/vim/sessions/matlab-session.vim<Cr>
-" and automatically on exit
-nnoremap XA :mksession! ~/.cache/vim/sessions/matlab-session.vim<CR>:wqa<CR>
-
+let s:save_cpo = &cpo
+set cpo-=C
-" ctrl-i to indent the whole file
-function! IndentFile()
- mkview
- let l:win_view = winsaveview()
- :normal! gg=G
- silent loadview
- call winrestview(l:win_view)
-endfunction
-nnoremap <C-i> :call IndentFile()<CR>
+if exists("loaded_matchit")
+ let s:conditionalEnd = '\([-+{\*\:(\/]\s*\)\@<!\<end\>\(\s*[-+}\:\*\/)]\)\@!'
+ let b:match_words = '\<classdef\>\|\<methods\>\|\<events\>\|\<properties\>\|\<if\>\|\<while\>\|\<for\>\|\<switch\>\|\<try\>\|\<function\>:' . s:conditionalEnd
+endif
+let &cpo = s:save_cpo
diff --git a/ftplugin/matlab/folding.vim b/ftplugin/matlab/folding.vim
@@ -0,0 +1,39 @@
+"------------------------------------------------------------------
+" 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
+
+ " expand tabs into spaces
+ 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()
diff --git a/ftplugin/matlab/slime.vim b/ftplugin/matlab/slime.vim
@@ -0,0 +1,74 @@
+"------------------------------------------------------------------
+" vim-slime configuration git://github.com/jpalardy/vim-slime.git
+"------------------------------------------------------------------
+
+""" Open the word under the cursor in vim or variable editor
+nnoremap <buffer> <silent> <CR> yiw:SlimeSend1 op <C-r>" vimlab;<CR>
+nnoremap <buffer> <silent> <Leader><CR> yiw:SlimeSend1 op <C-r>";<CR>
+
+
+""" Running code
+" F9 will send paragraph or visual selection
+xmap <buffer> <F9> <Plug>SlimeRegionSend
+nmap <buffer> <F9> <Plug>SlimeParagraphSend
+
+" F8 will run current line
+map <buffer> <F8> <Esc>ms0v$<F9>`s
+
+" F7 will run the current small word
+map <buffer> <F7> <Esc>msviw<F9>`s
+
+" F4 will run the current section
+map <buffer> <silent> <F4> ms:mkview<CR>:execute 'try \| foldopen! \| catch \| \| endtry'<CR>$?%%\\|\%^?<CR>v$/%%\\|\%$<CR>?^.*\S<CR>$<F9>`s:let @/=""<CR>:loadview<CR>
+
+" F2 will call script by title, so must be on matlab path
+nnoremap <buffer> <silent> <F2> <Esc>:let @" = expand("%:r")<CR>:SlimeSend1 <C-r>";<CR>
+
+" list variables
+nnoremap <buffer> <silent> <C-w> :SlimeSend1 who<CR>
+
+
+""" Debugging
+hi matlabDebug term=bold,reverse cterm=bold ctermfg=0 ctermbg=10 gui=bold guifg=bg guibg=LightGreen
+" toggle debug marker
+function! Matlab_debug_toggle_marker(line)
+ if (matchdelete(line(".")) == 0)
+ " remove marker
+ call SlimeSend1 "dbclear in" . expand("%") . " at " . line(".")
+ else
+ " add marker
+ call matchaddpos('matlabDebug', [line('.')], 10, line('.'))
+ call SlimeSend("dbstop in " . expand("%") . " at " . line("."))
+ endif
+endfunction
+nnoremap <buffer> <silent> <Leader>t :call Matlab_debug_toggle_marker(line("."))<CR>
+
+" (a)dd - this will save the buffer, as matlab needs the current version
+nnoremap <buffer> <silent> <Leader>a :w<CR>:let @" = "dbstop in " . expand("%") . " at " . line(".")<CR>:SlimeSend1 <C-r>"<CR>:call matchaddpos('matlabDebug', [line('.')], 10, line('.'))<CR>
+
+" (c)lear
+nnoremap <buffer> <silent> <Leader>c :let @" = "dbclear in " . expand("%") . " at " . line(".")<CR>:SlimeSend1 <C-r>"<CR>:call matchdelete(line('.'))<CR>
+
+" (s)tep
+nnoremap <buffer> <silent> <Leader>s :SlimeSend1 dbstep<CR>
+nnoremap <buffer> <silent> <F10> :SlimeSend1 dbstep<CR>
+
+" (g)o onward
+nnoremap <buffer> <silent> <Leader>g :SlimeSend1 dbcont<CR>
+nnoremap <buffer> <silent> <F5> :SlimeSend1 dbcont<CR>
+
+" stop on (e)rror
+nnoremap <buffer> <silent> <Leader>e :SlimeSend1 dbstop if error<CR>
+
+" e(x)it debugging
+nnoremap <buffer> <silent> <Leader>x :SlimeSend1 dbquit all<CR>
+
+" (f)lush all markers
+nnoremap <buffer> <silent> <Leader>f :call clearmatches()<CR>:SlimeSend1 dbclear all<CR>
+
+" dbstack, dbup and dbdown
+nnoremap <buffer> <silent> <Leader>ds :SlimeSend1 dbstack<CR>
+nnoremap <buffer> <silent> <Leader>du :SlimeSend1 dbup<CR>
+nnoremap <buffer> <silent> <Leader>dd :SlimeSend1 dbdown<CR>
+
+
diff --git a/license.txt b/license.txt
@@ -1,24 +0,0 @@
-Copyright (c) 2009, Fabrice
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the distribution
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/op.m b/op.m
@@ -6,16 +6,18 @@ function exitcode = op(name, server, term)
%
% If name is an m file, it will open it in vim via the system command.
%
-% If you have a function and variable with the same name, WHICH YOU SHOULDNT,
+% If you have a function and variable with the same name, which you shouldnt,
% this will open the file, not the variable.
%
-% The purpose of this is to bind the enter key in vim to send a command to
-% matlab to execute this function with the word under the cursor. i.e.
-% op('aWordInVim', 'vimlab'), which will either open aWordInVim in the variable
-% editor, or send it to the vimlab vim server instance.
+% The purpose of this is to bind a key in vim to send a command to matlab to
+% execute this function with the word under the cursor. i.e. op('aWordInVim',
+% 'vimlab'), which will either open aWordInVim in the variable editor, or send
+% it to the vimlab vim server instance.
%
% There is a limitation, and that is that this can only open variables from the
-% base workspace.
+% base workspace. If this is required, the command 'workspace' can be used from
+% matlab to open the workspace directly.
+%
%
% INPUTS:
%
@@ -36,10 +38,7 @@ function exitcode = op(name, server, term)
% OUTPUTS:
%
% exitcode : the exit code returned from the executed system command.
-% This might be useful for debugging.
-%
-%
-% Author: MColligan
+% This might be useful for debugging your setup.
%
@@ -49,7 +48,7 @@ if nargin < 3
end
if nargin < 2
- server = '';
+ server = 'vimlab';
end
diff --git a/syntax/add-syntax-functions.sh b/syntax/add-syntax-functions.sh
@@ -11,12 +11,9 @@
# The custom-syntax file is then sourced by the syntax file to provide syntax
# highlighting to custom functions.
#
-# This can be automated by adding something like this to your crontab (the path
-# may need changing):
-# 0 12 * * 1 $HOME/.vim/bundle/vimlab/syntax/add-syntax-functions.sh
-#
+# This can be automated by adding something like this to your crontab
#
-# Author: MColligan
+# 0 12 * * 1 $HOME/.vim/bundle/vimlab/syntax/add-syntax-functions.sh
#
diff --git a/syntax/matlab.vim b/syntax/matlab.vim
@@ -308,6 +308,10 @@ syn keyword matlabFunc multibandread multibandwrite
"Custom m files
runtime syntax/custom-syntax
+" colors for comments and section headers
+hi HComment ctermfg=3 cterm=bold
+hi MComment ctermfg=10
+
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet