=== modified file 'doc/prism.txt' --- doc/prism.txt 2015-08-26 23:37:48 +0000 +++ doc/prism.txt 2013-03-03 14:56:47 +0000 @@ -36,15 +36,6 @@ |PrismEnable| enables the prism syntax rules |PrismDisable| disables the prism syntax rules -There are also two functions you can use for closing open brackets: - -PrismClose() returns string that will close all open brackets -PrismCloseInner() returns string that will close innermost open bracket - -You can bind it such as ctrl-space closes the innermost open bracket: > - - :imoremap =PrismCloseInner() - ============================================================================== 3. CONFIGURATION *prism-configuration* === modified file 'plugin/prism.vim' --- plugin/prism.vim 2015-08-26 23:37:48 +0000 +++ plugin/prism.vim 2013-03-23 19:12:02 +0000 @@ -1,24 +1,27 @@ " Vim global plugin for short description " Maintainer: Jan Pobrislo -" Version: 0.2 +" Version: 0.1 " Description: Long description. -" Last Change: 2015-08-27 +" Last Change: 2013-03-03 " License: Vim License (see :help license) " Location: plugin/prism.vim -" Website: https://webprojekty.cz/ccx/bzr/vim-prism +" Website: https://github.com//prism " " See prism.txt for help. This can be accessed by doing: " " :helptags ~/.vim/doc " :help prism -let g:prism_version = '0.2' +let g:prism_version = '0.1' " Allow use of line continuation. let s:save_cpo = &cpo set cpo&vim " load guard +" uncomment after plugin development. +" XXX The conditions are only as examples of how to use them. Change them as +" needed. XXX if exists("g:loaded_prism") let &cpo = s:save_cpo finish @@ -68,13 +71,6 @@ endif endfun -" produce contains= string for round/square/curly variations of given depth -fun! s:con(depth) - return 'contains=prism'.a:depth.'r,prism'.a:depth.'s,prism'.a:depth.'c' -endfun - -" create syntax rules for bracketed regions, on top of existing syntax rules -" call this from after/syntax/filetype.vim fun! Prism(depth, contains, containedin) if !g:prism_enabled return @@ -98,58 +94,19 @@ let l:containedin = a:containedin endif - exe 'syn region prism0r transparent matchgroup=hlLevel0 start=/(/ end=/)/ '.s:con(1).l:contains.' '.l:containedin - exe 'syn region prism0c transparent matchgroup=hlLevel0 start=/{/ end=/}/ '.s:con(1).l:contains.' '.l:containedin - exe 'syn region prism0s transparent matchgroup=hlLevel0 start=/\[/ end=/\]/ '.s:con(1).l:contains.' '.l:containedin + exe 'syn region prism0 transparent matchgroup=hlLevel0 start=/(/ end=/)/ contains=prism1'.l:contains.' '.l:containedin + exe 'syn region prism0 transparent matchgroup=hlLevel0 start=/{/ end=/}/ contains=prism1'.l:contains.' '.l:containedin + exe 'syn region prism0 transparent matchgroup=hlLevel0 start=/\[/ end=/\]/ contains=prism1'.l:contains.' '.l:containedin for n in range(1, l:depth - 1) - exe 'syn region prism'.n.'r transparent matchgroup=hlLevel'.n.' start=/(/ end=/)/ contained '.s:con(n+1).l:contains - exe 'syn region prism'.n.'c transparent matchgroup=hlLevel'.n.' start=/{/ end=/}/ contained '.s:con(n+1).l:contains - exe 'syn region prism'.n.'s transparent matchgroup=hlLevel'.n.' start=/\[/ end=/\]/ contained '.s:con(n+1).l:contains - endfor - exe 'syn region prism'.l:depth.'r transparent matchgroup=hlLevel'.l:depth.' start=/(/ end=/)/ contained '.s:con(0).l:contains - exe 'syn region prism'.l:depth.'c transparent matchgroup=hlLevel'.l:depth.' start=/{/ end=/}/ contained '.s:con(0).l:contains - exe 'syn region prism'.l:depth.'s transparent matchgroup=hlLevel'.l:depth.' start=/\[/ end=/\]/ contained '.s:con(0).l:contains -endfun - -" Returns string that closes all open brackets at the point of cursor -fun! PrismClose() - let l:result = '' - for id in synstack(line("."), col(".")) - let l:name = synIDattr(id, "name") - if l:name[:4] == 'prism' - let l:type = name[strlen(name)-1] - if l:type == 'r' - let l:result = ')' . l:result - elseif l:type == 's' - let l:result = ']' . l:result - elseif l:type == 'c' - let l:result = '}' . l:result - endif - endif - endfor - return l:result -endfun - -" Returns string that closes innermost open bracket at the point of cursor -fun! PrismCloseInner() - let l:result = '' - for id in synstack(line("."), col(".")) - let l:name = synIDattr(id, "name") - if l:name[:4] == 'prism' - let l:type = name[strlen(name)-1] - if l:type == 'r' - let l:result = ')' - elseif l:type == 's' - let l:result = ']' - elseif l:type == 'c' - let l:result = '}' - endif - endif - endfor - return l:result -endfun - + exe 'syn region prism'.n.' transparent matchgroup=hlLevel'.n.' start=/(/ end=/)/ contained contains=prism'.(n+1).l:contains + exe 'syn region prism'.n.' transparent matchgroup=hlLevel'.n.' start=/{/ end=/}/ contained contains=prism'.(n+1).l:contains + exe 'syn region prism'.n.' transparent matchgroup=hlLevel'.n.' start=/\[/ end=/\]/ contained contains=prism'.(n+1).l:contains + endfor + exe 'syn region prism'.l:depth.' transparent matchgroup=hlLevel'.l:depth.' start=/(/ end=/)/ contained contains=prism0'.l:contains + exe 'syn region prism'.l:depth.' transparent matchgroup=hlLevel'.l:depth.' start=/{/ end=/}/ contained contains=prism0'.l:contains + exe 'syn region prism'.l:depth.' transparent matchgroup=hlLevel'.l:depth.' start=/\[/ end=/\]/ contained contains=prism0'.l:contains +endfun "reset &cpo back to users setting let &cpo = s:save_cpo -" vim: sw=4 sts=4 ts=4 noet +" vim: set sw=2 sts=2 et fdm=marker: