diff --git a/README.md b/README.md index f11b6ac..aee4585 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ A: Disable stuff in your `vimrc`, see [rapid-options][6] for details: > Q: Which keys get mapped to what? Will that override my own mappings? A: rapid-for-vim will not override existing mappings unless the corresponding option is explicitly set. To use different key bindings use the - ``mapping. Otherwise rapid-for-vim create the followin mappings: > + ``mapping. Otherwise rapid-for-vim create the followin mappings: > Show all structure values Show structure values at cursorline @@ -127,7 +127,7 @@ A: rapid-for-vim will not override existing mappings unless the corresponding Disable override existing mapping and Vim's default with let g:rapidGoDefinitionKeyMap = 0 - u List all significant appearances of word under cursor. + u List all significant references of word under cursor. Override existing mapping with let g:rapidListUsageKeyMap = 1 @@ -162,11 +162,19 @@ A: rapid-for-vim will not override existing mappings unless the corresponding Override existing mapping with let g:rapidAutoFormKeyMap = 1 -Q: Does rapid-for-vim provide a mapping for indenting a complete file? +Q: When I switch syntax off I get false indentation sometimes? +A: Indentation partly depends on `syntax on` . If you have strings with ! or + keywords in it Indentation may get confused without syntax on. It should + do fine for the most part of your editing. See next question. + +Q: Does rapid-for-vim provide a mapping for indenting the whole file? A: No, but you may put the following in your .vimrc or ~/.vim/after/ftplugin/rapid.vim: > - nnoremap ANYKEY gg=G``zz + nnoremap mzgg=G`z +or if you don't use syntax highlighting > + + nnoremap :syntax onnormal mzgg=G`z:syntax off Q: Scrolling feels sluggish. What can I do? A: Switch error highlighting off: > diff --git a/doc/rapid.txt b/doc/rapid.txt index e5277a5..7111570 100644 --- a/doc/rapid.txt +++ b/doc/rapid.txt @@ -1,4 +1,4 @@ -*rapid.txt* Abb Rapid Command for Vim version 7.4 Last change: 20. Feb 2020 +*rapid.txt* Abb Rapid Command for Vim version 7.4 Last change: 30. Nov 2020 VIM REFERENCE MANUAL by Patrick Meiser-Knosowski @@ -121,7 +121,7 @@ A: rapid-for-vim will not override existing mappings unless the corresponding Disable override existing mapping and Vim's default with let g:rapidGoDefinitionKeyMap = 0 - u List all significant appearances of word under cursor. + u List all significant references of word under cursor. Override existing mapping with let g:rapidListUsageKeyMap = 1 @@ -156,11 +156,18 @@ A: rapid-for-vim will not override existing mappings unless the corresponding Override existing mapping with let g:rapidAutoFormKeyMap = 1 -Q: Does rapid-for-vim provide a mapping for indenting a complete file? +Q: When I switch syntax off I get false indentation sometimes? +A: Indentation partly depends on `syntax on` . If you have strings with ! or + keywords in it Indentation may get confused without syntax on. It should + do fine for the most part of your editing. See next question. + +Q: Does rapid-for-vim provide a mapping for indenting the whole file? A: No, but you may put the following in your .vimrc or `~/.vim/after/ftplugin/rapid.vim`: > - nnoremap ANYKEY gg=G``zz + nnoremap mzgg=G`z +or if you don't use syntax highlighting > + nnoremap :syntax onnormal mzgg=G`z:syntax off Q: Scrolling feels sluggish. What can I do? A: Switch error highlighting off: > @@ -209,7 +216,7 @@ Exceptions may be |g:rapidCompleteCustom| and |g:rapidPathToBodyFiles|. Also see these options for alternative mappings. |g:rapidConcealStructKeyMap| `` - `` change concealing of structure values |g:rapidGoDefinitionKeyMap| `gd` to see declaration of word under cursor -|g:rapidListUsageKeyMap| `u` lists all appearances of current word +|g:rapidListUsageKeyMap| `u` lists all references of current word |g:rapidListDefKeyMap| `f` lists PROC/TRAP/... of current file |g:rapidMoveAroundKeyMap| `[[`, `]]` ... jumps around PROC/TRAP/... |g:rapidFunctionTextObject| `if`, `af` and `aF` def/deffct text objects @@ -244,9 +251,6 @@ Also see these options for alternative mappings. |g:rapidCompleteStd| Disable standard 'complete' setting |g:rapidCompleteCustom| Enable custom 'complete' setting -*rapid-endwise-options* -|g:rapidEndwiseUpperCase| Use upper case for `vim-endwise` - *rapid-auto-correct-cfg* |g:rapidAutoCorrCfgLineEnd| Auto correct mixed unix/dos line endings in *.cfg @@ -309,6 +313,15 @@ colorscheme tortus or tortusless which makes use of these groups: Index: |rapid-index| ============================================================================== *rapid-indent* + +Note: rapid-for-vim indentation works best with |syn-on|. +You may map > + nnoremap mzgg=G`z +or if you don't use syntax highlighting > + nnoremap :syntax onnormal mzgg=G'z:syntax off +to indent the whole file with one key stroke. + +Index: |rapid-index| *g:rapidSpaceIndent* g:rapidSpaceIndent: ------------------- @@ -445,7 +458,7 @@ Index: |rapid-index| g:rapidListUsageKeyMap: ----------------------- - `u`: List all appearances, outside of enum declarations and comments + `u`: List all references, outside of enum declarations and comments of the word under the cursor in the |quickfix-window|. To force this mapping if `u` is already mapped: > @@ -502,7 +515,8 @@ Note: These mappings overshadow the default Vim commands To force these mappings off and make Vims default available: > let g:rapidMoveAroundKeyMap = 0 -Note that |g:rapidFunctionTextObject| depend on these mappings. +Note that |g:rapidFunctionTextObject| and |g:rapidCommentTextObject| depend on +this feature. Index: |rapid-index| @@ -659,17 +673,6 @@ See also |rapid-complete|. If omitted or set to 0 no custom files get added to complete. -Index: |rapid-index| -============================================================================== - *g:rapidEndwiseUpperCase* -g:rapidEndwiseUpperCase: ------------------------- - -Insert upper case `ENDIF` etc. instead of lower case when `vim-endwise` -triggers: > - let g:rapidEndwiseUpperCase = 1 - - Index: |rapid-index| ============================================================================== *rapid-debug* diff --git a/ftdetect/rapid.vim b/ftdetect/rapid.vim index 7234566..5d3dbfb 100644 --- a/ftdetect/rapid.vim +++ b/ftdetect/rapid.vim @@ -2,7 +2,7 @@ " Language: ABB Rapid Command " Maintainer: Patrick Meiser-Knosowski " Version: 2.0.0 -" Last Change: 11. Apr 2019 +" Last Change: 17. Sep 2020 " Credits: " " Suggestions of improvement are very welcome. Please email me! @@ -23,7 +23,7 @@ augroup rapidftdetect au! filetypedetect BufRead *.cfg,*.Cfg,*.CFG if getline(1) =~ '^\w\+:CFG' | call RapidAutoCorrCfgLineEnding() | endif augroup END if !exists("*RapidAutoCorrCfgLineEnding()") - function RapidAutoCorrCfgLineEnding() + function RapidAutoCorrCfgLineEnding() abort setf rapid if get(g:,'rapidAutoCorrCfgLineEnd',1) silent! %s/\r// diff --git a/ftplugin/rapid.vim b/ftplugin/rapid.vim index 2eb1779..e1a469d 100644 --- a/ftplugin/rapid.vim +++ b/ftplugin/rapid.vim @@ -2,12 +2,18 @@ " Language: ABB Rapid Command " Maintainer: Patrick Meiser-Knosowski " Version: 2.2.1 -" Last Change: 08. Apr 2020 +" Last Change: 22. Dec 2020 " Credits: Peter Oddings (KnopUniqueListItems/xolox#misc#list#unique) " Thanks for beta testing to Thomas Baginski " " Suggestions of improvement are very welcome. Please email me! " +" TODO: - set buftype=nofile bufhidden=delete instead of temp file for altered +" quick fix +" - proper altering of quickfix: see :help quickfix-window then /filled +" - [[,]]... mappings for jumping from section to section in .cfg files +" - test compatiblity with quickfix-reflector +" " ToDo's {{{ " TODO - make file search case insensitive " - make [[, [], ][ and ]] text objects @@ -89,7 +95,7 @@ if !exists("*s:KnopVerboseEcho()") unlet g:knopVerboseMsg echomsg "Switch verbose messages off with \":let g:knopVerbose=0\" any time. You may put this in your .vimrc" endif - function s:KnopVerboseEcho(msg, ...) + function s:KnopVerboseEcho(msg, ...) abort if get(g:,'knopVerbose',0) if type(a:msg) == v:t_list let l:msg = a:msg @@ -109,14 +115,14 @@ if !exists("*s:KnopVerboseEcho()") endif endfunction " s:KnopVerboseEcho() - function s:KnopDirExists(in) + function s:KnopDirExists(in) abort if finddir( substitute(a:in,'\\','','g') )!='' return 1 endif return 0 endfunction " s:KnopDirExists - function s:KnopFnameescape4Path(in) + function s:KnopFnameescape4Path(in) abort " escape a path for use as 'execute "set path=" . s:KnopFnameescape4Path(mypath)' " use / (not \) as a separator for the input parameter let l:out = fnameescape( a:in ) @@ -128,14 +134,14 @@ if !exists("*s:KnopVerboseEcho()") return l:out endfunction - function s:knopCompleteEnbMsg() + function s:knopCompleteEnbMsg() abort if exists("g:knopCompleteMsg") unlet g:knopCompleteMsg call s:KnopVerboseEcho("Add the following files to 'complete'.\n Try and to complete words from there:") endif endfunction " s:knopCompleteEnbMsg - function s:KnopSplitAndUnescapeCommaSeparatedPathStr(commaSeparatedPathStr) + function s:KnopSplitAndUnescapeCommaSeparatedPathStr(commaSeparatedPathStr) abort let l:pathList = [] for l:pathItem in split(a:commaSeparatedPathStr,'\\\@1KnopNTimesSearch(nCount,sSearchPattern,sFlags) + function KnopNTimesSearch(nCount,sSearchPattern,sFlags) abort let l:nCount=a:nCount let l:sFlags=a:sFlags while l:nCount>0 @@ -311,7 +315,7 @@ if !exists("*s:KnopVerboseEcho()") " Rapid Helper {{{ - function RapidCleanBufferList() + function RapidCleanBufferList() abort if exists("g:knopTmpFile") let l:knopTmpFile = substitute(g:knopTmpFile,'.*[\\/]\(VI\w\+\.tmp\)','\1','') endif @@ -332,10 +336,7 @@ if !exists("*s:KnopVerboseEcho()") call setbufvar(l:b["bufnr"],"&buflisted",0) endif " delete those strange empty unnamed buffers - if l:b["name"]=="" " not named - \&& l:b["windows"]==[] " not shown in any window - \&& !l:b["hidden"] " not hidden - \&& !l:b["changed"] " not modified + if l:b['name']=='' && l:b['windows']==[] && !l:b['changed'] execute "silent bwipeout! " . l:b["bufnr"] endif endfor @@ -345,7 +346,7 @@ if !exists("*s:KnopVerboseEcho()") augroup END endfunction " RapidCleanBufferList() - function s:RapidCurrentWordIs() + function s:RapidCurrentWordIs() abort " returns the string "" depending on the word under the cursor " let l:numLine = line(".") @@ -399,7 +400,8 @@ if !exists("*s:KnopVerboseEcho()") " elseif l:currentChar =~ '\d' && \( synIDattr(synID(line("."),col("."),0),"name")=="rapidFloat" - \|| synIDattr(synID(line("."),col("."),0),"name")=="") + \|| synIDattr(synID(line("."),col("."),0),"name")=="" + \) return ("num" . l:word) " elseif l:nextChar == "(" && @@ -428,7 +430,7 @@ if !exists("*s:KnopVerboseEcho()") return "none" endfunction " s:RapidCurrentWordIs() - function s:RapidPutCursorOnModuleAndReturnEndmoduleline() + function s:RapidPutCursorOnModuleAndReturnEndmoduleline() abort if search('\c^\s*module\s','bcW') let l:numEndmodule = search('\v\c^\s*endmodule>','nW') if l:numEndmodule <= 0 @@ -448,16 +450,16 @@ if !exists("*s:KnopVerboseEcho()") " Go Definition {{{ - function s:RapidSearchUserDefined(declPrefix,currentWord) + function s:RapidSearchUserDefined(declPrefix,currentWord) abort " let l:numSearchStartLine = line(".") let l:numSearchStartColumn = col(".") - let l:numProcStart = search('\v\c^\s*((local|global|task)\s+)?(proc|func|trap)\s+','bcnW') + let l:numProcStart = search('\v\c^\s*((local|task)\s+)?(proc|func|trap)\s+','bcnW') let l:numProcEnd = search('\v\c^\s*end(proc|func|trap)>','cnW') " " if search starts inside a proc, search local decl if l:numProcStart != 0 && l:numProcEnd != 0 - \&& search('\v\c^\s*(((local|global|task)\s+)?(proc|func|trap)\s+|endmodule)','cnW') > l:numProcEnd + \&& search('\v\c^\s*(((local|task)\s+)?(proc|func|trap)\s+|endmodule)','cnW') > l:numProcEnd \&& search('\v\c^\s*end(proc|func|trap)>','bcnW') < l:numProcStart " " search FOR loop local auto declaration @@ -488,7 +490,7 @@ if !exists("*s:KnopVerboseEcho()") call s:KnopVerboseEcho("search Proc/Func/Trap argument declaration") call cursor(l:numProcStart,1) let l:noneCloseParen = '([^)]|\n)*' - if search('\c\v^'.l:noneCloseParen.'\('.l:noneCloseParen.'\w(\s|\n)*\zs<'.a:currentWord.'>'.l:noneCloseParen.'\)','cW',line(".")) + if search('\c\v^'.l:noneCloseParen.'\('.l:noneCloseParen.'\k(\s|\n)*\zs<'.a:currentWord.'>'.l:noneCloseParen.'\)','cW',line(".")) call s:KnopVerboseEcho("Found VARIABLE declaration in ARGUMENT list",1) return 0 " @@ -512,7 +514,7 @@ if !exists("*s:KnopVerboseEcho()") let l:numFoundLine = line(".") let l:numFoundCol = col(".") " rule out proc local declarations - if search('\v\c^\s*((local|global|task)\s+)?(end)?(proc|func|trap|record|module)>','W') && + if search('\v\c^\s*((local|task)\s+)?(end)?(proc|func|trap|record|module)>','W') && \( expand("") !~ '\c\v^\s*end(proc|func|trap|record)>' \|| expand("") =~ '\c\v^\s*endmodule>' \) @@ -526,7 +528,7 @@ if !exists("*s:KnopVerboseEcho()") " search Module local proc (et al) declaration call s:KnopVerboseEcho("search Module local proc (et al) declaration") let l:numEndmodule=s:RapidPutCursorOnModuleAndReturnEndmoduleline() - if search('\v\c^\s*((local|global|task)\s+)?(proc|func\s+\w+|trap|record)\s+\zs'.a:currentWord.'>','cW',l:numEndmodule) + if search('\v\c^\s*((local|task)\s+)?(proc|func\s+\k+|trap|record)\s+\zs'.a:currentWord.'>','cW',l:numEndmodule) call s:KnopVerboseEcho("Found declaration of PROC, FUNC, TRAP or RECORD in this MODULE",1) return 0 " @@ -541,7 +543,7 @@ if !exists("*s:KnopVerboseEcho()") " " first fill location list with all (end)?(proc|func|trap|record) and variable " declarations with currentWord - let l:prefix = '/\c\v^\s*(local\s+|task\s+|global\s+)?((var|pers|const)\s+\w+\s+' + let l:prefix = '/\c\v^\s*(local\s+|task\s+)?((var|pers|const)\s+\k+\s+' let l:suffix = '>|(end)?(proc|func|trap|record)>)/j' " since this finds all (not only global) ends, the previous must also list local if l:i =~ 'task' if has("win32") @@ -571,9 +573,9 @@ if !exists("*s:KnopVerboseEcho()") " search for global proc in loclist call s:KnopVerboseEcho("search for global proc in loclist") if l:i =~ 'task' - let l:procdecl = '\v\c^\s*(task\s+|global\s+)?(proc|func\s+\w+|trap|record)\s+' + let l:procdecl = '\v\c^\s*(task\s+)?(proc|func\s+\k+|trap|record)\s+' elseif l:i =~ 'system' - let l:procdecl = '\v\c^\s*(global\s+)?(proc|func\s+\w+|trap|record)\s+' + let l:procdecl = '\v\c^\s*(proc|func\s+\k+|trap|record)\s+' endif let l:loclist = getloclist(0) let l:qf = [] @@ -595,7 +597,7 @@ if !exists("*s:KnopVerboseEcho()") " " then search for global variable in loc list call s:KnopVerboseEcho("search for global variable in loc list") - let l:procdecl = '\v\c^\s*(local\s+|task\s+|global\s+)?(proc|func\s+\w+|trap|record)\s+' " procdecl must also contain local, since all ends are present + let l:procdecl = '\v\c^\s*(local\s+|task\s+)?(proc|func\s+\k+|trap|record)\s+' " procdecl must also contain local, since all ends are present let l:endproc = '\v\c^\s*end(proc|func|trap|record)>' let l:skip = 0 if l:i =~ 'task' @@ -672,17 +674,17 @@ if !exists("*s:KnopVerboseEcho()") return -1 endfunction " s:RapidSearchUserDefined() - function RapidGoDefinition() + function RapidGoDefinition() abort augroup RapidCleanBufferList " work around where buffer list is not cleaned if knopVerbose is enabled autocmd! autocmd CursorMoved * call RapidCleanBufferList() augroup END " - let l:declPrefix = '\c\v^\s*(local\s+|task\s+|global\s+)?(var|pers|const|alias)\s+\w+\s+' + let l:declPrefix = '\c\v^\s*(local\s+|task\s+)?(var|pers|const|alias)\s+\k+\s+' " " suche das naechste wort - if search('\w','cW',line(".")) + if search('\k','cW',line(".")) " let l:currentWord = s:RapidCurrentWordIs() " @@ -730,7 +732,7 @@ if !exists("*s:KnopVerboseEcho()") " Auto Form {{{ - function s:RapidGetGlobal(sAction) + function s:RapidGetGlobal(sAction) abort if a:sAction=~'^[lg]' let l:sGlobal = a:sAction else @@ -744,7 +746,7 @@ if !exists("*s:KnopVerboseEcho()") return '' endfunction " s:RapidGetGlobal() - function s:RapidGetType(sAction) + function s:RapidGetType(sAction) abort if a:sAction =~ '^.[pftr]' let l:sType = substitute(a:sAction,'^.\(\w\).','\1','') else @@ -762,24 +764,24 @@ if !exists("*s:KnopVerboseEcho()") return '' endfunction " s:RapidGetType() - function s:RapidGetName() - let l:sName = substitute(input("\nName?\n Type for word under cursor.\n> "),'[^ 0-9a-zA-Z_]*','','g') + function s:RapidGetName() abort + let l:sName = substitute(input("\nName?\n Type for word under cursor.\n> "),'[^ _0-9[:upper:][:lower:]]*','','g') if l:sName=="" return '' elseif l:sName=~'^ $' " sName from current word let l:sName = expand("") endif - let l:sName = substitute(l:sName,'\W*','','g') + let l:sName = substitute(l:sName,'[^_0-9[:upper:][:lower:]]*','','g') return l:sName endfunction " s:RapidGetName() - function s:RapidGetDataType(sAction) + function s:RapidGetDataType(sAction) abort if a:sAction=~'..[bndsprjtw]' let l:sDataType = substitute(a:sAction,'..\(\w\)','\1','') else let l:sDataType = substitute(input("\nData type? \n \Choose [b]ool, [n]um, [d]num, [s]ring, [p]ose, [r]obtarget, [j]ointtarget, [t]ooldata, [w]objdata,\n - \ or enter your desired data type\n> "),'[^ 0-9a-zA-Z_{}]*','','g') + \ or enter your desired data type\n> "),'[^ _0-9[:upper:][:lower:],{}]*','','g') endif if l:sDataType=~'\c^b$' return "bool" @@ -803,7 +805,7 @@ if !exists("*s:KnopVerboseEcho()") return substitute(l:sDataType,'[^0-9a-zA-Z_{}]*','','g') endfunction " s:RapidGetDataType() - function s:RapidGetReturnVar(sDataType) + function s:RapidGetReturnVar(sDataType) abort if a:sDataType=~'\c^bool\>' return "bResult" elseif a:sDataType=~'\c^num\>' @@ -826,7 +828,7 @@ if !exists("*s:KnopVerboseEcho()") return substitute(a:sDataType,'^\(..\).*','\l\1','')."Result" endfunction " s:RapidGetReturnVar() - function s:RapidPositionForEdit(sType) + function s:RapidPositionForEdit(sType) abort let l:commentline = '^\s*!' " empty file if line('$')==1 && getline('.')=='' | return | endif @@ -871,7 +873,7 @@ if !exists("*s:KnopVerboseEcho()") endif endfunction " s:RapidPositionForEdit() - function s:RapidPositionForRead(sType) + function s:RapidPositionForRead(sType) abort call s:RapidPositionForEdit(a:sType) if getline('.')=~'^\s*$' \&& line('.')!=line('$') @@ -879,7 +881,7 @@ if !exists("*s:KnopVerboseEcho()") endif endfunction " s:RapidPositionForRead() - function s:RapidReadBody(sBodyFile,sType,sName,sGlobal,sDataType,sReturnVar) + function s:RapidReadBody(sBodyFile,sType,sName,sGlobal,sDataType,sReturnVar) abort let l:sBodyFile = glob(fnameescape(g:rapidPathToBodyFiles)).a:sBodyFile if !filereadable(glob(l:sBodyFile)) call s:KnopVerboseEcho([l:sBodyFile,": Body file not readable."],1) @@ -914,7 +916,7 @@ if !exists("*s:KnopVerboseEcho()") endif endfunction " s:RapidReadBody() - function s:RapidDefaultBody(sType,sName,sGlobal,sDataType,sReturnVar) + function s:RapidDefaultBody(sType,sName,sGlobal,sDataType,sReturnVar) abort call s:RapidPositionForEdit(a:sType) call setline('.',a:sGlobal . a:sType . " " . a:sDataType . " " . a:sName . '()') if a:sType =~ '\v\c(trap|record)' | silent substitute/()// | endif @@ -950,7 +952,7 @@ if !exists("*s:KnopVerboseEcho()") call search('^\s*!','eW',l:end) endfunction " s:RapidDefaultBody() - function RapidAutoForm(sAction) + function RapidAutoForm(sAction) abort " check input if a:sAction !~ '^[ gl][ pftr][ bndsprjtw]$' | return | endif " @@ -999,14 +1001,14 @@ if !exists("*s:KnopVerboseEcho()") " List Def/Usage {{{ - function RapidListDefinition() + function RapidListDefinition() abort augroup RapidCleanBufferList " work around where buffer list is not cleaned if knopVerbose is enabled autocmd! autocmd CursorMoved * call RapidCleanBufferList() augroup END " list defs in qf - if s:KnopSearchPathForPatternNTimes('\v\c^\s*(global\s+|task\s+|local\s+)?(proc|func|trap|record|module)>','%','','rapid')==0 + if s:KnopSearchPathForPatternNTimes('\v\c^\s*(task\s+|local\s+)?(proc|func|trap|record|module)>','%','','rapid')==0 if getqflist()==[] | return | endif " put cursor back after manipulating qf if getbufvar('%', "&buftype")!="quickfix" @@ -1015,7 +1017,7 @@ if !exists("*s:KnopVerboseEcho()") endif if getbufvar('%', "&buftype")!="quickfix" | return | endif setlocal modifiable - silent %substitute/\v\c^.*\|\s*((global\s+|task\s+|local\s+)?(proc|func|trap|record|module)>)/\1/ + silent %substitute/\v\c^.*\|\s*((task\s+|local\s+)?(proc|func|trap|record|module)>)/\1/ 0 if !exists("g:rapidTmpFile") let g:rapidTmpFile=tempname() @@ -1037,14 +1039,14 @@ if !exists("*s:KnopVerboseEcho()") endif endfunction " RapidListDefinition() - function RapidListUsage() + function RapidListUsage() abort augroup RapidCleanBufferList " work around where buffer list is not cleaned if knopVerbose is enabled autocmd! autocmd CursorMoved * call RapidCleanBufferList() augroup END " - if search('\w','cW',line(".")) + if search('\k','cW',line(".")) let l:currentWord = s:RapidCurrentWordIs() " if l:currentWord =~ '^userdefined.*' @@ -1080,10 +1082,6 @@ if !exists("*s:KnopVerboseEcho()") let l:qfresult = [] for l:i in getqflist() if bufname(get(l:i,'bufnr')) !~ '\~$' - " \&& (get(l:i,'text') =~ '\v\c^([^"]*"[^"]*"[^"]*)*[^"]*<'.l:currentWord.'>' - " \|| (bufname(get(l:i,'bufnr')) !~ '\v\c\w+\.mod$' - " \&& bufname(get(l:i,'bufnr')) !~ '\v\c\w+\.sys$' - " \&& bufname(get(l:i,'bufnr')) !~ '\v\c\w+\.prg$')) call add(l:qfresult,l:i) endif endfor @@ -1103,7 +1101,7 @@ if !exists("*s:KnopVerboseEcho()") " Function Text Object {{{ if get(g:,'rapidMoveAroundKeyMap',1) " depends on move around key mappings - function RapidFunctionTextObject(inner,withcomment) + function RapidFunctionTextObject(inner,withcomment) abort if a:inner==1 let l:n = 1 else @@ -1135,7 +1133,7 @@ if !exists("*s:KnopVerboseEcho()") " Comment Text Object {{{ if get(g:,'rapidMoveAroundKeyMap',1) " depends on move around key mappings - function RapidCommentTextObject(around) + function RapidCommentTextObject(around) abort if getline('.')!~'^\s*!' && !search('^\s*!',"sW") return endif @@ -1192,6 +1190,9 @@ if get(g:,'rapidFormatComments',1) endif endif " format comments +setlocal fileencoding=latin1 +let b:undo_ftplugin = b:undo_ftplugin." fenc<" + " path for gf, :find etc if get(g:,'rapidPath',1) @@ -1222,7 +1223,7 @@ let s:pathToCurrentFile = substitute(expand("%:p:h"),'\\','/','g') " complete custom files if exists('g:rapidCompleteCustom') for s:customCompleteAdditions in g:rapidCompleteCustom - let s:file = substitute(s:customCompleteAdditions,'^.*[\\/]\(\w\+\.\)\(src\|sub\|dat\)$','\1\2','') + let s:file = substitute(s:customCompleteAdditions,'^.*[\\/]\(\k\+\.\)\(\w\+\)$','\1\2','') call s:KnopAddFileToCompleteOption(s:customCompleteAdditions,s:pathList,s:pathToCurrentFile.'/'.s:file,) endfor endif @@ -1263,37 +1264,33 @@ unlet s:pathList unlet s:pathToCurrentFile " conceal structure values (for MoveJ * v2500,z100...) -if get(g:,'rapidConcealStructs',1) +if !exists("*RapidConcealLevel") + function RapidConcealLevel(lvl) abort + " g:rapidConcealStructs may be used as input for a:lvl - if !exists("*RapidConcealLevel") - function RapidConcealLevel(lvl) - " g:rapidConcealStructs may be used as input for a:lvl + if a:lvl == 2 + " conceal all structure values + setlocal conceallevel=2 concealcursor=nc + return - if a:lvl == 2 - " conceal all structure values - setlocal conceallevel=2 concealcursor=nc - return - - elseif a:lvl == 1 - " conceal less structure values - setlocal conceallevel=2 concealcursor= - return - - endif + elseif a:lvl == 1 + " conceal less structure values + setlocal conceallevel=2 concealcursor= + return - " conceal no structure values - setlocal conceallevel=0 concealcursor= + endif - endfunction " RapidConcealLevel(lvl) + " conceal no structure values + setlocal conceallevel=0 concealcursor= - endif " !exists("*RapidConcealLevel") + endfunction " RapidConcealLevel(lvl) - call RapidConcealLevel(get(g:,'rapidConcealStructs',1)) +endif " !exists("*RapidConcealLevel") - let b:undo_ftplugin = b:undo_ftplugin." cole< cocu<" +call RapidConcealLevel(get(g:,'rapidConcealStructs',1)) -endif " get(g:,'rapidConcealStructs',1) +let b:undo_ftplugin = b:undo_ftplugin." cole< cocu<" " }}} Vim Settings @@ -1301,13 +1298,16 @@ endif " get(g:,'rapidConcealStructs',1) " endwise support if exists("loaded_endwise") - if get(g:,'rapidEndwiseUpperCase',0) - let b:endwise_addition = '\=submatch(0)=~"CASE" ? "ENDTEST" : submatch(0)=~"IF" ? "ENDIF" : "END" . submatch(0)' - else - let b:endwise_addition = '\=submatch(0)=~"case" ? "endtest" : submatch(0)=~"if" ? "endif" : "end" . submatch(0)' - endif + let b:endwise_addition = '\=submatch(0)=~#"CASE" ? "ENDTEST" ' + let b:endwise_addition .= ': submatch(0)=~#"DEFAULT" ? "ENDTEST" ' + let b:endwise_addition .= ': submatch(0)=~#"IF" ? "ENDIF" ' + let b:endwise_addition .= ': submatch(0)=~"case" ? "endtest" ' + let b:endwise_addition .= ': submatch(0)=~"default" ? "endtest" ' + let b:endwise_addition .= ': submatch(0)=~"if" ? "endif" ' + let b:endwise_addition .= ': submatch(0)=~"\\u" ? "END" . toupper(submatch(0)) ' + let b:endwise_addition .= ': "end" . tolower(submatch(0))' let b:endwise_words = 'proc,func,trap,record,then,do,:' - let b:endwise_pattern = '^\s*\(local\s\+\)\?\zs\(proc\|func\|trap\|record\|if[^!]*\\ze' + let b:endwise_pattern = '^\s*\(local\s\+\)\?\zs\(proc\|func\|trap\|record\|module\|if[^!]*\\ze' let b:endwise_syngroups = 'rapidTypeDef,rapidRepeat,rapidConditional' endif @@ -1321,7 +1321,7 @@ if exists("loaded_matchit") " depends on matchit (or matchup) \.'^\s*\[^!]\+\.*:^\s*\.*,' \.'^\s*\[^!]\+\.*:^\s*\.*,' \.'^\s*\.*:^\s*\.*:^\s*\.*:^\s*\.*,' - \.'^\s*\(global\s\+\|local\s\+\|task\s\+\)\?\<\(proc\|func\|trap\|record\)\>.*:\:\:^\s*\.*:\:\:^\s*\.*:^\s*\.*:^\s*\.*,' + \.'^\s*\(local\s\+\|task\s\+\)\?\<\(proc\|func\|trap\|record\)\>.*:\:\:^\s*\.*:\:\:^\s*\.*:^\s*\.*:^\s*\.*,' \.'^\s*\.*:^\s*\.*' let b:match_ignorecase = 1 " Rapid does ignore case endif @@ -1331,67 +1331,82 @@ endif " Move Around and Function Text Object key mappings {{{ if get(g:,'rapidMoveAroundKeyMap',1) - " Move around functions - nnoremap [[ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(global\s+\|local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 'bs') unlet b:knopCount:normal! zt - onoremap [[ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(global\s+\|local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>.*\n\zs', 'bsW')unlet b:knopCount - xnoremap [[ :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*(global\s+\|local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 'bsW') unlet b:knopCount - nnoremap ]] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(global\s+\|local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 's') unlet b:knopCount:normal! zt - onoremap ]] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(global\s+\|local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 'sW') unlet b:knopCount - xnoremap ]] :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*(global\s+\|local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>.*\n', 'seWz')unlet b:knopCount - nnoremap [] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>', 'bs') unlet b:knopCount:normal! zb - onoremap [] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>\n^(.\|\n)', 'bseW') unlet b:knopCount - xnoremap [] :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>', 'bsW') unlet b:knopCount - nnoremap ][ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>', 's') unlet b:knopCount:normal! zb - onoremap ][ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v\ze^\s*end(proc\|func\|trap\|record\|module)>', 'sW') unlet b:knopCount - xnoremap ][ :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>(\n)?', 'seWz') unlet b:knopCount - " Move around comments - nnoremap [; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v(^\s*!.*\n)@unlet b:knopCount - onoremap [; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v(^\s*!.*\n)@unlet b:knopCount - xnoremap [; :let b:knopCount=v:count1exe "normal! gv"call KnopNTimesSearch(b:knopCount, '\v(^\s*!.*\n)@unlet b:knopCount - nnoremap ]; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v^\s*!.*\n\s*([^!\t ]\|$)', 's')unlet b:knopCount - onoremap ]; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v^\s*!.*\n(\s*[^!\t ]\|$)', 'seW')normal! ==unlet b:knopCount - xnoremap ]; :let b:knopCount=v:count1exe "normal! gv"call KnopNTimesSearch(b:knopCount, '\v^\s*!.*\n\ze\s*([^!\t ]\|$)', 'seW')unlet b:knopCount - " inner and around function text objects - if get(g:,'rapidFunctionTextObject',0) - \|| mapcheck("aF","x")=="" && !hasmapto('RapidTxtObjAroundFuncInclCo','x') - xmap aF RapidTxtObjAroundFuncInclCo - endif - if get(g:,'rapidFunctionTextObject',0) - \|| mapcheck("af","x")=="" && !hasmapto('RapidTxtObjAroundFuncExclCo','x') - xmap af RapidTxtObjAroundFuncExclCo - endif - if get(g:,'rapidFunctionTextObject',0) - \|| mapcheck("if","x")=="" && !hasmapto('RapidTxtObjInnerFunc','x') - xmap if RapidTxtObjInnerFunc - endif - if get(g:,'rapidFunctionTextObject',0) - \|| mapcheck("aF","o")=="" && !hasmapto('RapidTxtObjAroundFuncInclCo','o') - omap aF RapidTxtObjAroundFuncInclCo - endif - if get(g:,'rapidFunctionTextObject',0) - \|| mapcheck("af","o")=="" && !hasmapto('RapidTxtObjAroundFuncExclCo','o') - omap af RapidTxtObjAroundFuncExclCo - endif - if get(g:,'rapidFunctionTextObject',0) - \|| mapcheck("if","o")=="" && !hasmapto('RapidTxtObjInnerFunc','o') - omap if RapidTxtObjInnerFunc - endif - " inner and around comment text objects - if get(g:,'rapidCommentTextObject',0) - \|| mapcheck("ac","x")=="" && !hasmapto('RapidTxtObjAroundComment','x') - xmap ac RapidTxtObjAroundComment - endif - if get(g:,'rapidCommentTextObject',0) - \|| mapcheck("ic","x")=="" && !hasmapto('RapidTxtObjInnerComment','x') - xmap ic RapidTxtObjInnerComment - endif - if get(g:,'rapidCommentTextObject',0) - \|| mapcheck("ac","o")=="" && !hasmapto('RapidTxtObjAroundComment','o') - omap ac RapidTxtObjAroundComment - endif - if get(g:,'rapidCommentTextObject',0) - \|| mapcheck("ic","o")=="" && !hasmapto('RapidTxtObjInnerComment','o') - omap ic RapidTxtObjInnerComment + if bufname("%") =~ '\c\.cfg$' + nnoremap ]] :call search('^#','sw') + nnoremap [[ :call search('^#','bsw') + nnoremap ][ :call search('.*\(\n#\\|\%$\)','sw') + nnoremap [] :call search('^#\n\w\+:\n\n','besw') + xnoremap ]] :exe "normal! gv"call search('\(^#\\|\%$\)','sW') + xnoremap [[ :exe "normal! gv"call search('^#','bsW') + xnoremap ][ :exe "normal! gv"call search('\(\n#\\|\%$\)','sW') + xnoremap [] :exe "normal! gv"call search('^#\n\w\+:\n\n','besW') + onoremap ]] :exe "normal! v"call search('\(\ze\n#\\|\%$\)','eW') + onoremap [[ :call search('^#','bW') + onoremap ][ :exe "normal! v"call search('\(\n#\\|\%$\)','sW') + onoremap [] :exe "normal! V"call search('^#\n\w\+:\n\n','besW') + else + " Move around functions + nnoremap [[ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 'bs') unlet b:knopCount:normal! zt + onoremap [[ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>.*\n\zs', 'bsW')unlet b:knopCount + xnoremap [[ :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*(local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 'bsW') unlet b:knopCount + nnoremap ]] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 's') unlet b:knopCount:normal! zt + onoremap ]] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*(local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>', 'sW') unlet b:knopCount + xnoremap ]] :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*(local\s+\|task\s+)?(proc\|func\|trap\|record\|module)>.*\n', 'seWz')unlet b:knopCount + nnoremap [] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>', 'bs') unlet b:knopCount:normal! zb + onoremap [] :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>\n^(.\|\n)', 'bseW') unlet b:knopCount + xnoremap [] :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>', 'bsW') unlet b:knopCount + nnoremap ][ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>', 's') unlet b:knopCount:normal! zb + onoremap ][ :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\c\v\ze^\s*end(proc\|func\|trap\|record\|module)>', 'sW') unlet b:knopCount + xnoremap ][ :let b:knopCount=v:count1exe "normal! gv" call KnopNTimesSearch(b:knopCount, '\c\v^\s*end(proc\|func\|trap\|record\|module)>(\n)?', 'seWz') unlet b:knopCount + " Move around comments + nnoremap [; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v(^\s*!.*\n)@unlet b:knopCount + onoremap [; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v(^\s*!.*\n)@unlet b:knopCount + xnoremap [; :let b:knopCount=v:count1exe "normal! gv"call KnopNTimesSearch(b:knopCount, '\v(^\s*!.*\n)@unlet b:knopCount + nnoremap ]; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v^\s*!.*\n\s*([^!\t ]\|$)', 's')unlet b:knopCount + onoremap ]; :let b:knopCount=v:count1 call KnopNTimesSearch(b:knopCount, '\v^\s*!.*\n(\s*[^!\t ]\|$)', 'seW')normal! ==unlet b:knopCount + xnoremap ]; :let b:knopCount=v:count1exe "normal! gv"call KnopNTimesSearch(b:knopCount, '\v^\s*!.*\n\ze\s*([^!\t ]\|$)', 'seW')unlet b:knopCount + " inner and around function text objects + if get(g:,'rapidFunctionTextObject',0) + \|| mapcheck("aF","x")=="" && !hasmapto('RapidTxtObjAroundFuncInclCo','x') + xmap aF RapidTxtObjAroundFuncInclCo + endif + if get(g:,'rapidFunctionTextObject',0) + \|| mapcheck("af","x")=="" && !hasmapto('RapidTxtObjAroundFuncExclCo','x') + xmap af RapidTxtObjAroundFuncExclCo + endif + if get(g:,'rapidFunctionTextObject',0) + \|| mapcheck("if","x")=="" && !hasmapto('RapidTxtObjInnerFunc','x') + xmap if RapidTxtObjInnerFunc + endif + if get(g:,'rapidFunctionTextObject',0) + \|| mapcheck("aF","o")=="" && !hasmapto('RapidTxtObjAroundFuncInclCo','o') + omap aF RapidTxtObjAroundFuncInclCo + endif + if get(g:,'rapidFunctionTextObject',0) + \|| mapcheck("af","o")=="" && !hasmapto('RapidTxtObjAroundFuncExclCo','o') + omap af RapidTxtObjAroundFuncExclCo + endif + if get(g:,'rapidFunctionTextObject',0) + \|| mapcheck("if","o")=="" && !hasmapto('RapidTxtObjInnerFunc','o') + omap if RapidTxtObjInnerFunc + endif + " inner and around comment text objects + if get(g:,'rapidCommentTextObject',0) + \|| mapcheck("ac","x")=="" && !hasmapto('RapidTxtObjAroundComment','x') + xmap ac RapidTxtObjAroundComment + endif + if get(g:,'rapidCommentTextObject',0) + \|| mapcheck("ic","x")=="" && !hasmapto('RapidTxtObjInnerComment','x') + xmap ic RapidTxtObjInnerComment + endif + if get(g:,'rapidCommentTextObject',0) + \|| mapcheck("ac","o")=="" && !hasmapto('RapidTxtObjAroundComment','o') + omap ac RapidTxtObjAroundComment + endif + if get(g:,'rapidCommentTextObject',0) + \|| mapcheck("ic","o")=="" && !hasmapto('RapidTxtObjInnerComment','o') + omap ic RapidTxtObjInnerComment + endif endif endif @@ -1500,13 +1515,16 @@ endif " mappings {{{ " Go Definition -nnoremap RapidGoDef :call RapidGoDefinition():call RapidCleanBufferList() +" nnoremap RapidGoDef :call RapidGoDefinition():call RapidCleanBufferList() +nnoremap RapidGoDef :call RapidGoDefinition() " list all PROCs of current file -nnoremap RapidListDef :call RapidListDefinition():call RapidCleanBufferList() +" nnoremap RapidListDef :call RapidListDefinition():call RapidCleanBufferList() +nnoremap RapidListDef :call RapidListDefinition() " list usage -nnoremap RapidListUse :call RapidListUsage():call RapidCleanBufferList() +" nnoremap RapidListUse :call RapidListUsage():call RapidCleanBufferList() +nnoremap RapidListUse :call RapidListUsage() " auto form nnoremap RapidAutoForm :call RapidAutoForm(" ") diff --git a/indent/rapid.vim b/indent/rapid.vim index 24b1e8d..a52800e 100644 --- a/indent/rapid.vim +++ b/indent/rapid.vim @@ -1,8 +1,8 @@ " ABB Rapid Command indent file for Vim " Language: ABB Rapid Command " Maintainer: Patrick Meiser-Knosowski -" Version: 2.0.1 -" Last Change: 11. Feb 2020 +" Version: 2.2.2 +" Last Change: 20. Dec 2020 " Credits: Based on indent/vim.vim " " Suggestions of improvement are very welcome. Please email me! @@ -23,7 +23,7 @@ if exists("g:rapidNoSpaceIndent") endif " Only load this indent file when no other was loaded. -if exists("b:did_indent") || exists("g:rapidNoIndent") && g:rapidNoIndent==1 +if exists("b:did_indent") || get(g:,'rapidNoIndent',0) finish endif let b:did_indent = 1 @@ -32,12 +32,16 @@ setlocal nolisp setlocal nosmartindent setlocal autoindent setlocal indentexpr=GetRapidIndent() -setlocal indentkeys=!^F,o,O,0=~endmodule,0=~error,0=~undo,0=~backward,0=~endproc,0=~endrecord,0=~endtrap,0=~endfunc,0=~else,0=~endif,0=~endtest,0=~endfor,0=~endwhile,: +if get(g:,'rapidNewStyleIndent',0) + setlocal indentkeys=!^F,o,O,0=~endmodule,0=~error,0=~undo,0=~backward,0=~endproc,0=~endrecord,0=~endtrap,0=~endfunc,0=~else,0=~endif,0=~endtest,0=~endfor,0=~endwhile,:,<[>,<]>,<(>,<)> +else + setlocal indentkeys=!^F,o,O,0=~endmodule,0=~error,0=~undo,0=~backward,0=~endproc,0=~endrecord,0=~endtrap,0=~endfunc,0=~else,0=~endif,0=~endtest,0=~endfor,0=~endwhile,: +endif let b:undo_indent="setlocal lisp< si< ai< inde< indk<" if get(g:,'rapidSpaceIndent',1) - " use spaces for indention, 2 is enough, more or even tabs are looking awful - " on the teach pendant + " Use spaces for indention, 2 is enough. + " More or even tabs wastes space on the teach pendant. setlocal softtabstop=2 setlocal shiftwidth=2 setlocal expandtab @@ -63,69 +67,74 @@ function GetRapidIndent() endtry endfunction -function s:GetRapidIndentIntern() - let l:currentLine = getline(v:lnum) +function s:GetRapidIndentIntern() abort + + let l:currentLineNum = v:lnum + let l:currentLine = getline(l:currentLineNum) + if l:currentLine =~ '^!' && !get(g:,'rapidCommentIndent',0) - " if first char is ! line comment, do not change indent - " this may be usefull if code did get commented out at the first column + " If current line is ! line comment, do not change indent + " This may be usefull if code is commented out at the first column. return 0 endif + " Find a non-blank line above the current line. let l:preNoneBlankLineNum = s:RapidPreNoneBlank(v:lnum - 1) if l:preNoneBlankLineNum == 0 " At the start of the file use zero indent. return 0 endif + let l:preNoneBlankLine = getline(l:preNoneBlankLineNum) let l:ind = indent(l:preNoneBlankLineNum) - " Add a 'shiftwidth' - let l:i = match(l:preNoneBlankLine, '\c\v^\s* - \( - \((local|task|global)\s+)? - \(module\s+\w - \|record\s+\w - \|proc\s+\w - \|func\s+\w - \|trap\s+\w - \) - \|[^!]*\s*(!.*)?$ - \|else\s*(!.*)?$ - \|[^!]*\s*(!.*)?$ - \|[^!]*[^!]+: - \|[^!"]*\s*: - \)' - \) - if l:i >= 0 - let l:ind += &sw - endif - let l:i = match(l:preNoneBlankLine, '\c\v^\s*(backward|error|undo)\s*(!.*)?$') - if l:i >= 0 + " Define add a 'shiftwidth' pattern + let l:addShiftwidthPattern = '\c\v^\s*(' + let l:addShiftwidthPattern .= '((local|task)\s+)?(module|record|proc|func|trap)\s+\k' + let l:addShiftwidthPattern .= '|(backward|error|undo)>' + let l:addShiftwidthPattern .= ')' + " + " Define Subtract 'shiftwidth' pattern + let l:subtractShiftwidthPattern = '\c\v^\s*(' + let l:subtractShiftwidthPattern .= 'end(module|record|proc|func|trap)>' + let l:subtractShiftwidthPattern .= '|(backward|error|undo)>' + let l:subtractShiftwidthPattern .= ')' + + " Add shiftwidth + if l:preNoneBlankLine =~ l:addShiftwidthPattern + \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "then", 0)>=0 + \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "else", 0)>=0 + \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "do", 0)>=0 + \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "case", 0)>=0 + \|| s:RapidLenTilStr(l:preNoneBlankLineNum, "default", 0)>=0 let l:ind += &sw endif - " Subtract a 'shiftwidth' - if l:currentLine =~ '\c\v^\s* - \(end(module|record|proc|func|trap|if|for|while|test)\s*(!.*)?$ - \|[^!]*else\s*(!.*)?$ - \|[^!]*elseif>(\W|$) - \|[^!]*[^!]+: - \|[^!]*\s*: - \)' - let l:ind -= &sw - endif - if l:currentLine =~ '\c\v^\s*(backward|error|undo)\s*(!.*)?$' - let l:ind -= &sw + " Subtract shiftwidth + if l:currentLine =~ l:subtractShiftwidthPattern + \|| s:RapidLenTilStr(l:currentLineNum, "endif", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "endfor", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "endwhile", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "endtest", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "else", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "elseif", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "case", 0)>=0 + \|| s:RapidLenTilStr(l:currentLineNum, "default", 0)>=0 + let l:ind = l:ind - &sw endif - " first case after a test - if l:currentLine =~ '\c\v^\s*case>' && l:preNoneBlankLine =~ '\c\v^\s*test>' + " First case (or default) after a test gets the indent of the test. + if (s:RapidLenTilStr(l:currentLineNum, "case", 0)>=0 || s:RapidLenTilStr(l:currentLineNum, "default", 0)>=0) && s:RapidLenTilStr(l:preNoneBlankLineNum, "test", 0)>=0 let l:ind += &sw endif " continued lines with () or [] let l:OpenSum = s:RapidLoneParen(l:preNoneBlankLineNum,"(") + s:RapidLoneParen(l:preNoneBlankLineNum,"[") - let l:CloseSum = s:RapidLoneParen(l:preNoneBlankLineNum,")") + s:RapidLoneParen(l:preNoneBlankLineNum,"]") + if get(g:,'rapidNewStyleIndent',0) + let l:CloseSum = s:RapidLoneParen(l:preNoneBlankLineNum,")") + s:RapidLoneParen(l:currentLineNum,"]") + else + let l:CloseSum = s:RapidLoneParen(l:preNoneBlankLineNum,")") + s:RapidLoneParen(l:preNoneBlankLineNum,"]") + endif if l:OpenSum > l:CloseSum let l:ind += (l:OpenSum * 4 * &sw) elseif l:OpenSum < l:CloseSum @@ -135,125 +144,106 @@ function s:GetRapidIndentIntern() return l:ind endfunction -function s:RapidLoneParen(lnum,lchar) - " init - let s:line = getline(a:lnum) - let s:len = strlen(s:line) - if s:len == 0 - return 0 +" Returns the length of the line until a:str occur outside a string or +" comment. Search starts at string index a:startIdx. +" If a:str is a word also add word bounderies and case insesitivity. +" Note: rapidTodoComment and rapidDebugComment are not taken into account. +function s:RapidLenTilStr(lnum, str, startIdx) abort + + let l:line = getline(a:lnum) + let l:len = strlen(l:line) + let l:idx = a:startIdx + let l:str = a:str + if l:str =~ '^\k\+$' + let l:str = '\c\<' . l:str . '\>' endif - let s:opnParen = 0 - let s:clsParen = 0 - " + + while l:len > l:idx + let l:idx = match(l:line, l:str, l:idx) + if l:idx < 0 + " a:str not found + return -1 + endif + let l:synName = synIDattr(synID(a:lnum,l:idx+1,0),"name") + if l:synName != "rapidString" + \&& l:synName != "rapidConcealableString" + \&& (l:synName != "rapidComment" || l:str =~ '^!') + " a:str found outside string or line comment + return l:idx + endif + " a:str is part of string or line comment + let l:idx += 1 " continue search for a:str + endwhile + + " a:str not found or l:len <= a:startIdx + return -1 +endfunction + +" a:lchar shoud be one of (, ), [, ], { or } +" returns the number of opening/closing parenthesise which have no +" closing/opening match in getline(a:lnum) +function s:RapidLoneParen(lnum,lchar) abort if a:lchar == "(" || a:lchar == ")" - let s:opnParChar = "(" - let s:clsParChar = ")" + let l:opnParChar = "(" + let l:clsParChar = ")" elseif a:lchar == "[" || a:lchar == "]" - let s:opnParChar = "[" - let s:clsParChar = "]" + let l:opnParChar = "[" + let l:clsParChar = "]" elseif a:lchar == "{" || a:lchar == "}" - let s:opnParChar = "{" - let s:clsParChar = "}" + let l:opnParChar = "{" + let l:clsParChar = "}" else return 0 endif - " find first ! which is not part of a string - let s:i = stridx(s:line, "!", 0) - if s:i > 0 - " ! found - let s:i = 0 - while s:i < s:len - let s:i = stridx(s:line, "!", s:i) - if s:i >= 0 - if synIDattr(synID(a:lnum,s:i+1,0),"name") == "rapidString" - \|| synIDattr(synID(a:lnum,s:i+1,0),"name") == "rapidConcealableString" - " ! is part of string - let s:i += 1 " continue search for ! - else - " ! is start of line comment - let s:len = s:i " len = start of line comment - endif - else - " no start of line comment found - let s:i = s:len " finish - endif - endwhile - elseif s:i == 0 - " first char is ! - return 0 - endif + let l:line = getline(a:lnum) - " too long lines are ignored - if s:len > 4096 - return 0 + " look for the first ! which is not part of a string + let l:len = s:RapidLenTilStr(a:lnum,"!",0) + if l:len == 0 + return 0 " first char is !; ignored endif + let l:opnParen = 0 " count opening brakets - let s:i = 0 - while s:i < s:len - let s:i = stridx(s:line, s:opnParChar, s:i) - if s:i >= 0 && s:i <= s:len - " brakets that are part of a strings or comment are ignored - if synIDattr(synID(a:lnum,s:i+1,0),"name") != "rapidString" - \&& synIDattr(synID(a:lnum,s:i+1,0),"name") != "rapidConcealableString" - \&& synIDattr(synID(a:lnum,s:i+1,0),"name") != "rapidComment" - let s:opnParen += 1 - endif - else - let s:i = s:len + let l:i = 0 + while l:i >= 0 + let l:i = s:RapidLenTilStr(a:lnum, l:opnParChar, l:i) + if l:i >= 0 + let l:opnParen += 1 + let l:i += 1 endif - let s:i += 1 endwhile + let l:clsParen = 0 " count closing brakets - let s:i = 0 - while s:i < s:len - let s:i = stridx(s:line, s:clsParChar, s:i) - if s:i >= 0 && s:i <= s:len - " brakets that are part of a strings or comment are ignored - if synIDattr(synID(a:lnum,s:i+1,0),"name") != "rapidString" - \&& synIDattr(synID(a:lnum,s:i+1,0),"name") != "rapidConcealableString" - \&& synIDattr(synID(a:lnum,s:i+1,0),"name") != "rapidComment" - let s:clsParen += 1 - endif - else - let s:i = s:len + let l:i = 0 + while l:i >= 0 + let l:i = s:RapidLenTilStr(a:lnum, l:clsParChar, l:i) + if l:i >= 0 + let l:clsParen += 1 + let l:i += 1 endif - let s:i += 1 endwhile - if (a:lchar == "(" || a:lchar == "[" || a:lchar == "{") && s:opnParen>s:clsParen - return (s:opnParen-s:clsParen) - elseif (a:lchar == ")" || a:lchar == "]" || a:lchar == "}") && s:clsParen>s:opnParen - return (s:clsParen-s:opnParen) + if (a:lchar == "(" || a:lchar == "[" || a:lchar == "{") && l:opnParen>l:clsParen + return (l:opnParen-l:clsParen) + elseif (a:lchar == ")" || a:lchar == "]" || a:lchar == "}") && l:clsParen>l:opnParen + return (l:clsParen-l:opnParen) endif return 0 endfunction -function s:RapidPreNoneBlank(lnum) - " this function handles &foo-headers and comments like blank lines +" This function works almost like prevnonblank() but handles %%%-headers and +" comments like blank lines +function s:RapidPreNoneBlank(lnum) abort + let nPreNoneBlank = prevnonblank(a:lnum) - " At the start of the file use zero indent. - if nPreNoneBlank == 0 - return 0 - endif - let l:i=1 - while l:i>=1 && nPreNoneBlank>=0 - if getline(nPreNoneBlank) =~ '\v\c^\s* - \(\%\%\%.*$ - \|(!.*)?$ - \)' - let nPreNoneBlank = prevnonblank(nPreNoneBlank - 1) - " At the start of the file use zero indent. - if nPreNoneBlank == 0 - return 0 - endif - else - let l:i=0 - endif + while nPreNoneBlank>0 && getline(nPreNoneBlank) =~ '\v\c^\s*(\%\%\%|!)' + " Previouse none blank line irrelevant. Look further aback. + let nPreNoneBlank = prevnonblank(nPreNoneBlank - 1) endwhile return nPreNoneBlank diff --git a/syntax/rapid.vim b/syntax/rapid.vim index cc95992..e131ff0 100644 --- a/syntax/rapid.vim +++ b/syntax/rapid.vim @@ -1,8 +1,8 @@ " ABB Rapid Command syntax file for Vim " Language: ABB Rapid Command " Maintainer: Patrick Meiser-Knosowski -" Version: 2.2.0 -" Last Change: 06. Apr 2020 +" Version: 2.2.2 +" Last Change: 22. Dec 2020 " Credits: Thanks for beta testing to Thomas Baginski " " Suggestions of improvement are very welcome. Please email me! @@ -20,6 +20,8 @@ " " TODO: - highlight rapid constants and maybe constants from common " technology packages +" - optimize rapidErrorStringTooLong +" - error highlight for missing 2nd point in MoveCirc et al " Init {{{ " Remove any old syntax stuff that was loaded (5.x) or quit when a syntax file @@ -63,50 +65,73 @@ endif syn case ignore " }}} init -" {{{ highlighting for *.cfg -if bufname("%") =~ '\c\.cfg$' +" common highlighting {{{ + +" Error {{{ +if get(g:,'rapidShowError',1) + " + " This error must be defined befor rapidCharCode and rapidEscapedBackSlash + " a string containing a single \ which is not a char code + syn match rapidErrorSingleBackslash /\\/ contained + highlight default link rapidErrorSingleBackslash Error + " +endif +" }}} Error - " Constant values - " Boolean - syn keyword rapidBoolean True False Edge High Low - highlight default link rapidBoolean Boolean - " Float (num) - syn match rapidFloat /\v%(\W|_)@1<=[+-]?\d+\.?\d*%(\s*[eE][+-]?\d+)?/ - highlight default link rapidFloat Float - " character code in string - syn match rapidCharCode /[^\\]\zs\\\d\{1,3}/ contained - highlight default link rapidCharCode SpecialChar - " String. Note: Don't rename group rapidString. Indent depend on this - syn region rapidString start=/"/ end=/"/ contains=rapidCharCode - highlight default link rapidString String - " --- +" Constant values {{{ +" Boolean +syn keyword rapidBoolean TRUE FALSE Edge High Low +highlight default link rapidBoolean Boolean +" Float (num) +syn match rapidFloat /\v%(\W|_)@1<=[+-]?\d+\.?\d*%(\s*[eE][+-]?\d+)?/ +highlight default link rapidFloat Float +" String. Note: Don't rename group rapidString. Indent depend on this +syn region rapidString matchgroup=rapidString start=/"/ skip=/""/ end=/"/ contains=rapidCharCode,rapidEscapedBackSlash,rapidStringDoubleQuote,rapidErrorSingleBackslash,rapidErrorStringTooLong +highlight default link rapidString String +" two adjacent "" in string for one double quote +syn match rapidStringDoubleQuote /""/ contained +highlight default link rapidStringDoubleQuote SpecialChar +" character code in string +syn match rapidCharCode /\\\x\x/ contained +highlight default link rapidCharCode SpecialChar +" escaped \ in string +syn match rapidEscapedBackSlash /\\\\/ contained +highlight default link rapidEscapedBackSlash SpecialChar +" }}} Constant values + +" }}} common highlighting + +if bufname("%") =~ '\c\.cfg$' +" {{{ highlighting for *.cfg - " special chars + " special chars {{{ syn match rapidOperator /:\|[+-]\|\*\|\/\|\\/ syn match rapidOperator /^#/ highlight default link rapidOperator Operator - " --- + " }}} special chars - " sections + " sections {{{ syn match rapidException /^\w\+/ syn match rapidException /CFG\ze_/ highlight default link rapidException Exception - " --- + " }}} sections - " Error + " Error {{{ if get(g:,'rapidShowError',1) - syn match rapidError11 /[^"]\{80}\zs[^"]\+/ containedin=rapidString - highlight default link rapidError11 Error - syn match rapidError12 /-Name "[^"]\{33,}"/ - highlight default link rapidError12 Error + " + " This error must be defined after rapidString + " Any Name longer than 32 chars + syn match rapidErrorNameTooLong /-Name "[^"]\{33,}"/ + highlight default link rapidErrorNameTooLong Error + " endif - " --- -else -" }}} highlighting for *.cfg + " }}} Error -" highlighting for *.mod, *.sys and *.prg + " }}} highlighting for *.cfg +else + " highlighting for *.mod, *.sys and *.prg {{{ -" Comment {{{ + " Comment {{{ " TODO Comment syn match rapidTodoComment contained /\\|\\|\/ highlight default link rapidTodoComment Todo @@ -116,14 +141,14 @@ else " Line comment syn match rapidComment /!.*$/ contains=rapidTodoComment,rapidDebugComment highlight default link rapidComment Comment -" }}} Comment + " }}} Comment -" Header {{{ + " Header {{{ syn match rapidHeader /^%%%/ highlight default link rapidHeader PreProc -" }}} Header + " }}} Header -" Operator {{{ + " Operator {{{ " Boolean operator syn keyword rapidOperator and or xor not div mod " Arithmetic and compare operator @@ -131,26 +156,26 @@ else " conditional argument syn match rapidOperator /?/ highlight default link rapidOperator Operator -" }}} Operator + " }}} Operator -" Type, StorageClass and Typedef {{{ + " Type, StorageClass and Typedef {{{ " anytype (preceded by 'alias|pers|var|const|func' " TODO: still missing are userdefined types which are part of a parameter: - " proc message( mystring msMessagePart1{}, + " PROC message( mystring msMessagePart1{}, " \ myvar msMsg4{}) " TODO testing. Problem: does not highlight any type if it's part of an argument list " syn match rapidAnyType /\v^\s*(global\s+|task\s+|local\s+)?(alias|pers|var|const|func)\s+\w+>/ contains=rapidStorageClass,rapidType,rapidTypeDef " highlight default link rapidAnyType Type syn keyword rapidType aiotrigg bool btnres busstate buttondata byte - syn keyword rapidType cameradev cameratarget cfgdomain clock confdata corrdescr datapos dionum dir dnum + syn keyword rapidType cfgdomain clock confdata corrdescr datapos dionum dir dnum syn keyword rapidType egmframetype egmident egm_minmax egmstate egmstopmode errdomain errnum errstr errtype event_type exec_level extjoint handler_type syn keyword rapidType icondata identno intnum iodev iounit_state jointtarget syn keyword rapidType listitem loaddata loadidnum loadsession mecunit motsetdata syn keyword rapidType num - syn keyword rapidType opcalc opnum orient paridnum paridvalidnum pathrecid pos pose progdisp o_jointtarget o_robtarget + syn keyword rapidType opcalc opnum orient paridnum paridvalidnum pathrecid pnpdata pos pose progdisp o_jointtarget o_robtarget syn keyword rapidType rawbytes restartdata rmqheader rmqmessage rmqslot robjoint robtarget - syn keyword rapidType sensor sensorstate shapedata signalorigin signalai signalao signaldi signaldo signalgi signalgo socketdev socketstatus speeddata stoppointdata string stringdig switch symnum syncident - syn keyword rapidType taskid tasks testsignal tooldata tpnum trapdata triggdata triggios triggiosdnum triggmode triggstrgo tunetype + syn keyword rapidType sensor sensorstate sensorvardata shapedata signalorigin signalai signalao signaldi signaldo signalgi signalgo socketdev socketstatus speeddata stoppointdata string stringdig switch symnum syncident + syn keyword rapidType taskid tasks testsignal tooldata tpnum trapdata triggdata triggios triggiosdnum triggmode triggstrgo tsp_status tunetype syn keyword rapidType uishownum wobjdata wzstationary wztemporary zonedata " SoftMove data types syn keyword rapidType css_offset_dir css_soft_dir cssframe @@ -167,7 +192,7 @@ else " Spot data types syn keyword rapidType gundata spotdata forcedata simdata smeqdata " Continuous Application Platform data types - syn keyword rapidType capdata caplatrackdata capspeeddata captrackdata capweavedata flypointdata processtimes restartblkdata supervtimeouts weavestartdata + syn keyword rapidType capaptrreferencedata capdata caplatrackdata capspeeddata capspeeddata capstopmode captrackdata capweavedata flypointdata processtimes restartblkdata supervtimeouts weavestartdata " Bulls Eye data types syn keyword rapidType be_device be_scan be_tooldesign " Force Control data types @@ -176,63 +201,48 @@ else syn keyword rapidType dadescapp dadescprc daintdata highlight default link rapidType Type " Storage class - syn keyword rapidStorageClass LOCAL TASK GLOBAL VAR PERS CONST ALIAS NOVIEW NOSTEPIN VIEWONLY READONLY SYSMODULE INOUT + syn keyword rapidStorageClass LOCAL TASK VAR PERS CONST ALIAS NOVIEW NOSTEPIN VIEWONLY READONLY SYSMODULE INOUT highlight default link rapidStorageClass StorageClass " Not a typedef but I like to have those highlighted different then types, " structures or strorage classes syn keyword rapidTypeDef MODULE ENDMODULE PROC ERROR UNDO BACKWARD ENDPROC RECORD ENDRECORD TRAP ENDTRAP FUNC ENDFUNC highlight default link rapidTypeDef TypeDef -" }}} Type, StorageClass and Typedef + " }}} Type, StorageClass and Typedef -" Delimiter {{{ + " Delimiter {{{ syn match rapidDelimiter /[\\(){},;|\[\]]/ highlight default link rapidDelimiter Delimiter -" }}} Delimiter + " }}} Delimiter -" Constant values {{{ - " Boolean - syn keyword rapidBoolean True False Edge High Low - highlight default link rapidBoolean Boolean - " Float (num) - syn match rapidFloat /\v\W@1<=[+-]?\d+\.?\d*%(\s*[eE][+-]?\d+)?/ - highlight default link rapidFloat Float - " String. Note: Don't rename group rapidString. Indent depend on this - syn region rapidString start=/"/ end=/"/ contains=rapidCharCode - highlight default link rapidString String - " character code in string - syn match rapidCharCode /[^\\]\zs\\\d\{1,3}/ contained - highlight default link rapidCharCode SpecialChar -" }}} Constant values - -" Statements, keywords et al {{{ + " Statements, keywords et al {{{ " syn keyword rapidStatement " highlight default link rapidStatement Statement " Conditional syn keyword rapidConditional if then elseif else endif test case default endtest highlight default link rapidConditional Conditional " Repeat - syn keyword rapidRepeat DO + syn keyword rapidRepeat do syn match rapidRepeat /\c\v^\s*%(|)%([^!]+)@=/ syn keyword rapidRepeat from to step endfor endwhile highlight default link rapidRepeat Repeat " Label syn keyword rapidLabel goto - syn match rapidLabel /\c\v^\s*\a\w*\:\ze%([^=]|$)/ contains=rapidConditional,rapidOperator + syn match rapidLabel /\c\v^\s*[[:upper:][:lower:]]\k*\:\ze%([^=]|$)/ contains=rapidConditional,rapidOperator highlight default link rapidLabel Label " Keyword - syn keyword rapidKeyword AccSet ActEventBuffer ActUnit Add AliasIO AliasIOReset BitClear BitSet BookErrNo BrakeCheck - syn keyword rapidKeyword CallByVar CancelLoad CheckProgRef CirPathMode Clear ClearIOBuff ClearPath ClearRawBytes ClkReset ClkStart ClkStop Close CloseDir ConfJ ConfL CONNECT CopyFile CopyRawBytes CorrClear CorrCon CorrDiscon CorrWrite + syn keyword rapidKeyword AccSet ActEventBuffer ActUnit Add AliasCamera AliasIO AliasIOReset BitClear BitSet BookErrNo BrakeCheck + syn keyword rapidKeyword CallByVar CancelLoad CheckProgRef CirPathMode Clear ClearIOBuff ClearPath ClearRawBytes ClkReset ClkStart ClkStop Close CloseDir ConfJ ConfL CONNECT CopyFile CopyRawBytes CornerPathWarning CorrClear CorrCon CorrDiscon CorrWrite syn keyword rapidKeyword CSSAct CSSForceOffsetAct CSSForceOffsetDeact CSSOffsetTuneCSSOffsetTune syn keyword rapidKeyword DeactEventBuffer DeactUnit Decr DitherAct DitherDeact DropSensor syn keyword rapidKeyword EGMActJoint EGMActMove EGMActPose EGMGetId EGMReset EGMSetupAI EGMSetupAO EGMSetupGI EGMSetupLTAPP EGMSetupUC EOffsOff EOffsOn EOffsSet EraseModule ErrLog ErrWrite - syn keyword rapidKeyword FricIdInit FricIdEvaluate FricIdSetFricLevels - syn keyword rapidKeyword GetDataVal GetJointData GetSysData GetTrapData GripLoad HollowWristReset IDelete IDisable IEnable IError Incr IndReset InvertDO IOBusStart IOBusState IODisable IOEnable IPers IRMQMessage ISignalAI ISignalAO ISignalDI ISignalDO ISignalGI ISignalGO ISleep ITimer IVarValue IWatch - syn keyword rapidKeyword Load LoadId MatrixSVD MatrixSolve MatrixSolveQR MakeDir ManLoadIdProc MechUnitLoad MotionProcessModeSet MotionSup MToolRotCalib MToolTCPCalib Open OpenDir - syn keyword rapidKeyword PackDNHeader PackRawBytes PathAccLim PathRecStart PathRecStop PathResol PDispOff PDispOn PDispSet ProcerrRecovery PrxActivAndStoreRecord PrxActivRecord PrxDbgStoreRecord PrxDeactRecord PrxResetPos PrxResetRecords PrxSetPosOffset PrxSetRecordSampleTime PrxSetSyncalarm PrxStartRecord PrxStopRecord PrxStoreRecord PrxUseFileRecord PulseDO - syn keyword rapidKeyword ReadAnyBin ReadBlock ReadCfgData ReadErrData ReadRawBytes RemoveAllCyclicBool RemoveCyclicBool RemoveDir RemoveFile RenameFile Reset ResetAxisMoveTime ResetPPMoved ResetRetryCount RestoPath Rewind RMQEmptyQueue RMQFindSlot RMQGetMessage RMQGetMsgData RMQGetMsgHeader RMQReadWait RMQSendMessage RMQSendWait - syn keyword rapidKeyword SafetyControllerSyncRequest Save SaveCfgData SCWrite SenDevice Set SetAllDataVal SetAO SetDataSearch SetDataVal SetDO SetGO SetLeadThrough SetSysData SetupCyclicBool SiConnect SiClose SiGetCyclic SingArea SiSetCyclic SkipWarn SocketAccept SocketBind SocketClose SocketConnect SocketCreate SocketListen SocketReceive SocketReceiveFrom SocketSend SocketSendTo SoftAct SoftDeact SpeedLimAxis SpeedLimCheckPoint SpeedRefresh SpyStart SpyStop StartLoad STCalib STClose STIndGun STIndGunReset SToolRotCalib SToolTCPCalib STOpen StorePath STTune STTuneReset SupSyncSensorOff SupSyncSensorOn SyncMoveOff SyncMoveOn SyncMoveResume SyncMoveSuspend SyncMoveUndo SyncToSensor SystemStopAction + syn keyword rapidKeyword FitCircle FricIdInit FricIdEvaluate FricIdSetFricLevels + syn keyword rapidKeyword GetDataVal GetGroupSignalInfo GetJointData GetSysData GetTorqueMargin GetTrapData GripLoad HollowWristReset IDelete IDisable IEnable IError Incr IndReset InvertDO IOBusStart IOBusState IODisable IOEnable IPers IRMQMessage ISignalAI ISignalAO ISignalDI ISignalDO ISignalGI ISignalGO ISleep ITimer IVarValue IWatch + syn keyword rapidKeyword Load LoadId MakeDir ManLoadIdProc MatrixSolve MatrixSolveQR MatrixSVD MechUnitLoad MotionProcessModeSet MotionSup MToolRotCalib MToolTCPCalib Open OpenDir + syn keyword rapidKeyword PackDNHeader PackRawBytes PathAccLim PathLengthReset PathLengthStart PathLengthStop PathRecStart PathRecStop PathResol PDispOff PDispOn PDispSet ProcerrRecovery PrxActivAndStoreRecord PrxActivRecord PrxDbgStoreRecord PrxDeactRecord PrxResetPos PrxResetRecords PrxSetPosOffset PrxSetRecordSampleTime PrxSetSyncalarm PrxStartRecord PrxStopRecord PrxStoreRecord PrxUseFileRecord PulseDO + syn keyword rapidKeyword ReadAnyBin ReadBlock ReadCfgData ReadErrData ReadRawBytes ReadVarArr RemoveAllCyclicBool RemoveCyclicBool RemoveDir RemoveFile RenameFile Reset ResetAxisDistance ResetAxisMoveTime ResetPPMoved ResetRetryCount ResetTorqueMargin RestoPath Rewind RMQEmptyQueue RMQFindSlot RMQGetMessage RMQGetMsgData RMQGetMsgHeader RMQReadWait RMQSendMessage RMQSendWait + syn keyword rapidKeyword SafetyControllerSyncRequest Save SaveCfgData SCWrite SenDevice Set SetAllDataVal SetAO SetDataSearch SetDataVal SetDO SetGO SetLeadThrough SetSysData SetupCyclicBool SiConnect SiClose SiGetCyclic SingArea SiSetCyclic SkipWarn SocketAccept SocketBind SocketClose SocketConnect SocketCreate SocketListen SocketReceive SocketReceiveFrom SocketSend SocketSendTo SoftAct SoftDeact SoftElbow SpeedLimAxis SpeedLimCheckPoint SpeedRefresh SpyStart SpyStop StartLoad STCalib STClose STIndGun STIndGunReset SToolRotCalib SToolTCPCalib STOpen StorePath STTune STTuneReset SupSyncSensorOff SupSyncSensorOn SyncMoveOff SyncMoveOn SyncMoveResume SyncMoveSuspend SyncMoveUndo SyncToSensor SystemStopAction syn keyword rapidKeyword TestSignDefine TestSignReset TextTabInstall TPErase TPReadDnum TPReadFK TPReadNum TPShow TPWrite TriggCheckIO TriggDataCopy TriggDataReset TriggEquip TriggInt TriggIO TriggRampAO TriggSpeed TriggStopProc TryInt TuneReset TuneServo - syn keyword rapidKeyword UIMsgBox UIMsgWrite UIMsgWriteAbort UIShow UnLoad UnpackRawBytes VelSet WaitAI WaitAO WaitDI WaitDO WaitGI WaitGO WaitLoad WaitRob WaitSensor WaitSyncTask WaitTestAndSet WaitTime WaitUntil WarmStart WITH WorldAccLim Write WriteAnyBin WriteBin WriteBlock WriteCfgData WriteRawBytes WriteStrBin WriteVar WZBoxDef WZCylDef WZDisable WZDOSet WZEnable WZFree WZHomeJointDef WZLimJointDef WZLimSup WZSphDef + syn keyword rapidKeyword UIMsgBox UIMsgWrite UIMsgWriteAbort UIShow UnLoad UnpackRawBytes VelSet WaitAI WaitAO WaitDI WaitDO WaitGI WaitGO WaitLoad WaitRob WaitSensor WaitSyncTask WaitTestAndSet WaitTime WaitUntil WarmStart WITH WorldAccLim Write WriteAnyBin WriteBin WriteBlock WriteCfgData WriteRawBytes WriteStrBin WriteVar WriteVarArr WZBoxDef WZCylDef WZDisable WZDOSet WZEnable WZFree WZHomeJointDef WZLimJointDef WZLimSup WZSphDef " arc instructions syn keyword rapidKeyword ArcRefresh RecoveryMenu RecoveryMenuWR RecoveryPosSet RecoveryPosReset SetWRProcName " conveyor tracking instructions @@ -242,13 +252,13 @@ else " arc Weldguide and MultiPass instructions syn keyword rapidKeyword MPSavePath MPLoadPath MPReadInPath MPOffsEaxOnPath " Paint instructions - syn keyword rapidKeyword SetBrush SetBrushFac + syn keyword rapidKeyword IndexLookup IpsCommand IpsGetParam IpsSetParam PaintCommand PntProdUserLog PntQueueExtraGet PntQueueExtraSet PntQueuePeek SetBrush SetBrushFac " Spot instructions syn keyword rapidKeyword SetForce Calibrate ReCalcTCP IndGunMove IndGunMoveReset OpenHighLift CloseHighLift SwSetIntSpotData SwSetIntForceData SwSetIntGunData SwSetIntSimData SwGetCalibData SwGetFixTipData " dispense instructions - syn keyword rapidKeyword SetTmSignal + syn keyword rapidKeyword SetTmSignal SyncWWObj " Continuous Application Platform instructions - syn keyword rapidKeyword CapAPTrSetup CapCondSetDO CapEquiDist CapLATrSetup CapNoProcess CapRefresh CapWeaveSync ICap InitSuperv IPathPos RemoveSuperv SetupSuperv + syn keyword rapidKeyword CapAPTrSetup CapAPTrSetupAI CapAPTrSetupAO CapAPTrSetupPERS CapCondSetDO CapEquiDist CapNoProcess CapRefresh CAPSetStopMode CapWeaveSync ICap InitSuperv IPathPos RemoveSuperv SetupSuperv " Bulls Eye instructions syn keyword rapidKeyword BECheckTcp BEDebugState BERefPointer BESetupToolJ BETcpExtend BEUpdateTcp " Force Control instructions @@ -257,37 +267,46 @@ else syn keyword rapidKeyword DaActProc DaDeactAllProc DaDeactProc DaDefExtSig DaDefProcData DaDefProcSig DaDefUserData DaGetCurrData DaSetCurrData DaSetupAppBehav DaStartManAction DaGetAppDescr DaGetAppIndex DaGetNumOfProcs DaGetNumOfRob DaGetPrcDescr " Production Manager instructions syn keyword rapidKeyword ExecEngine PMgrGetNextPart PMgrSetNextPart PMgrRunMenu + " Homepos-Running instructions + syn keyword rapidKeyword HR_Exit HR_ExitCycle HR_SavePos HR_SetMoveToStartPos HR_SetTypeDIndex HR_SetTypeIndex highlight default link rapidKeyword Keyword " Exception syn keyword rapidException Exit ErrRaise ExitCycle Raise RaiseToUser Retry Return TryNext syn match rapidException /^\s*Stop\s*[\\;]/me=e-1 highlight default link rapidException Exception -" }}} Statements, keywords et al + " }}} Statements, keywords et al -" special keyword for move command {{{ - " arc instructions + " special keyword for move command {{{ + " uncategorized yet + syn keyword rapidMovement MovePnP + syn keyword rapidMovement EGMMoveC EGMMoveL EGMRunJoint EGMRunPose EGMStop + syn keyword rapidMovement IndAMove IndCMove IndDMove IndRMove + " common instructions + syn keyword rapidMovement MoveAbsJ MoveC MoveExtJ MoveJ MoveL + syn keyword rapidMovement MoveCAO MoveCDO MoveCGO MoveCSync MoveJAO MoveJDO MoveJGO MoveJSync MoveLAO MoveLDO MoveLGO MoveLSync + syn keyword rapidMovement SearchC SearchExtJ SearchL + syn keyword rapidMovement TriggC TriggJ TriggL TriggJIOs TriggLIOs + " Arc instructions syn keyword rapidMovement ArcC ArcC1 ArcC2 ArcCEnd ArcC1End ArcC2End ArcCStart ArcC1Start ArcC2Start syn keyword rapidMovement ArcL ArcL1 ArcL2 ArcLEnd ArcL1End ArcL2End ArcLStart ArcL1Start ArcL2Start ArcMoveExtJ - " arc Weldguide and MultiPass instructions + " Arc Weldguide and MultiPass instructions syn keyword rapidMovement ArcRepL ArcAdaptLStart ArcAdaptL ArcAdaptC ArcAdaptLEnd ArcAdaptCEnd ArcCalcLStart ArcCalcL ArcCalcC ArcCalcLEnd ArcCalcCEnd ArcAdaptRepL syn keyword rapidMovement Break " Continuous Application Platform instructions - syn keyword rapidMovement CapC CapL CSSDeactMoveL ContactL - " dispense instructions + syn keyword rapidMovement CapC CapL CapLATrSetup CSSDeactMoveL ContactL + " Dispense instructions syn keyword rapidMovement DispL DispC - syn keyword rapidMovement EGMMoveC EGMMoveL EGMRunJoint EGMRunPose EGMStop - syn keyword rapidMovement IndAMove IndCMove IndDMove IndRMove - syn keyword rapidMovement MoveAbsJ MoveC MoveExtJ MoveJ MoveL - syn keyword rapidMovement MoveCAO MoveCDO MoveCGO MoveCSync MoveJAO MoveJDO MoveJGO MoveJSync MoveLAO MoveLDO MoveLGO MoveLSync + " Nut instructions" syn keyword rapidMovement NutL NutJ syn keyword rapidMovement PathRecMoveBwd PathRecMoveFwd - syn keyword rapidMovement PaintL PaintC + " Paint instructions" + syn keyword rapidMovement PaintL PaintLDO PaintC syn keyword rapidMovement StartMove StartMoveRetry StepBwdPath StopMove StopMoveReset " Spot instructions syn keyword rapidMovement SpotL SpotJ SpotML SpotMJ CalibL CalibJ MeasureWearL + " Homepos-Running instructions syn keyword rapidMovement SMoveJ SMoveJDO SMoveJGO SMoveJSync SMoveL SMoveLDO SMoveLGO SMoveLSync SSearchL STriggJ STriggL - syn keyword rapidMovement SearchC SearchExtJ SearchL - syn keyword rapidMovement TriggC TriggJ TriggL TriggJIOs TriggLIOs + syn keyword rapidMovement HR_ContMove HR_MoveBack HR_MoveRoutine HR_MoveTo HR_MoveToHome SCSSDeactMoveL " Discrete application platform instructions syn keyword rapidMovement DaProcML DaProcMJ if g:rapidGroupName @@ -295,40 +314,40 @@ else else highlight default link rapidMovement Special endif -" }}} special keyword for move command + " }}} special keyword for move command -" Structure value {{{ - syn match rapidNames /[a-zA-Z_][.a-zA-Z0-9_]*/ + " Structure value {{{ + syn match rapidNames /\v[[:upper:][:lower:]](\k|\.)*/ " highlight default link rapidNames None " rapid structrure values. added to be able to conceal them - syn region rapidConcealableString start=/"/ end=/"/ contained contains=rapidCharCode conceal + syn region rapidConcealableString start=/"/ end=/"/ contained contains=rapidCharCode,rapidEscapedBackSlash,rapidErrorSingleBackslash,rapidErrorStringTooLong conceal highlight default link rapidConcealableString String syn region rapidStructVal matchgroup=rapidDelimiter start=/\[/ end=/\]/ contains=ALLBUT,rapidString keepend extend conceal cchar=* -" }}} Structure value + " }}} Structure value -" BuildInFunction {{{ + " BuildInFunction {{{ " dispense functions - syn keyword rapidBuildInFunction contained GetSignal + syn keyword rapidBuildInFunction contained GetSignal GetSignalDnum " Integrated Vision Platform functions syn keyword rapidBuildInFunction contained CamGetExposure CamGetLoadedJob CamGetName CamNumberOfResults " Continuous Application Platform functions syn keyword rapidBuildInFunction contained CapGetFailSigs syn keyword rapidBuildInFunction contained Abs AbsDnum ACos ACosDnum AInput AOutput ArgName ASin ASinDnum ATan ATanDnum ATan2 ATan2Dnum syn keyword rapidBuildInFunction contained BitAnd BitAndDnum BitCheck BitCheckDnum BitLSh BitLShDnum BitNeg BitNegDnum BitOr BitOrDnum BitRSh BitRShDnum BitXOr BitXOrDnum ByteToStr - syn keyword rapidBuildInFunction contained CalcJointT CalcRobT CalcRotAxFrameZ CalcRotAxisFrame CamGetExposure CamGetLoadedJob CamGetName CamNumberOfResults CDate CJointT ClkRead CorrRead Cos CosDnum CPos CRobT CSpeedOverride CTime CTool CWObj + syn keyword rapidBuildInFunction contained CalcJointT CalcRobT CalcRotAxFrameZ CalcRotAxisFrame CDate CJointT ClkRead CorrRead Cos CosDnum CPos CRobT CrossProd CSpeedOverride CTime CTool CWObj syn keyword rapidBuildInFunction contained DecToHex DefAccFrame DefDFrame DefFrame Dim DInput Distance DnumToNum DnumToStr DotProd DOutput syn keyword rapidBuildInFunction contained EGMGetState EulerZYX EventType ExecHandler ExecLevel Exp syn keyword rapidBuildInFunction contained FileSize FileTime FileTimeDnum FSSize - syn keyword rapidBuildInFunction contained GetMaxNumberOfCyclicBool GetMecUnitName GetModalPayLoadMode GetMotorTorque GetNextCyclicBool GetNextMechUnit GetNextSym GetNumberOfCyclicBool GetServiceInfo GetSignalOrigin GetSysInfo GetTaskName GetTime GInput GInputDnum GOutput GOutputDnum + syn keyword rapidBuildInFunction contained GetAxisDistance GetAxisMoveTime GetMaxNumberOfCyclicBool GetMecUnitName GetModalPayLoadMode GetMotorTorque GetNextCyclicBool GetNextMechUnit GetNextSym GetNumberOfCyclicBool GetServiceInfo GetSignalOrigin GetSysInfo GetTaskName GetTime GetTSPStatus GetUASUserName GInput GInputDnum GOutput GOutputDnum syn keyword rapidBuildInFunction contained HexToDec - syn keyword rapidBuildInFunction contained IndInpos IndSpeed IOUnitState IsCyclicBool IsFile IsLeadThrough IsMechUnitActive IsPers IsStopMoveAct IsStopStateEvent IsSyncMoveOn IsSysId IsVar - syn keyword rapidBuildInFunction contained MaxRobSpeed MirPos ModExist ModTime ModTimeDnum MotionPlannerNo + syn keyword rapidBuildInFunction contained IndInpos IndSpeed IOUnitState IsBrakeCheckActive IsCyclicBool IsFile IsLeadThrough IsMechUnitActive IsPers IsStopMoveAct IsStopStateEvent IsSyncMoveOn IsSysId IsVar + syn keyword rapidBuildInFunction contained Max MaxExtLinearSpeed MaxExtReorientSpeed MaxRobReorientSpeed MaxRobSpeed Min MirPos ModExist ModTime ModTimeDnum MotionPlannerNo syn keyword rapidBuildInFunction contained NonMotionMode NOrient NumToDnum NumToStr syn keyword rapidBuildInFunction contained Offs OpMode OrientZYX ORobT - syn keyword rapidBuildInFunction contained ParIdPosValid ParIdRobValid PathLevel PathRecValidBwd PathRecValidFwd PFRestart PoseInv PoseMult PoseVect Pow PowDnum PPMovedInManMode Present ProgMemFree PrxGetMaxRecordpos + syn keyword rapidBuildInFunction contained ParIdPosValid ParIdRobValid PathLengthGet PathLevel PathRecValidBwd PathRecValidFwd PFRestart PoseInv PoseMult PoseVect Pow PowDnum PPMovedInManMode Present ProgMemFree PrxGetMaxRecordpos syn keyword rapidBuildInFunction contained RawBytesLen ReadBin ReadDir ReadMotor ReadNum ReadStr ReadStrBin ReadVar RelTool RemainingRetries RMQGetSlotName RobName RobOS Round RoundDnum RunMode syn keyword rapidBuildInFunction contained SafetyControllerGetChecksum SafetyControllerGetOpModePinCode SafetyControllerGetSWVersion SafetyControllerGetUserChecksum Sin SinDnum SocketGetStatus SocketPeek Sqrt SqrtDnum STCalcForce STCalcTorque STIsCalib STIsClosed STIsIndGun STIsOpen StrDigCalc StrDigCmp StrFind StrLen StrMap StrMatch StrMemb StrOrder StrPart StrToByte StrToVal - syn keyword rapidBuildInFunction contained Tan TanDnum TaskRunMec TaskRunRob TasksInSync TestAndSet TestDI TestSignRead TextGet TextTabFreeToUse TextTabGet TriggDataValid Trunc TruncDnum Type + syn keyword rapidBuildInFunction contained Tan TanDnum TaskRunMec TaskRunRob TasksInSync TaskIsActive TaskIsExecuting TestAndSet TestDI TestSignRead TextGet TextTabFreeToUse TextTabGet TriggDataValid Trunc TruncDnum Type syn keyword rapidBuildInFunction contained UIAlphaEntry UIClientExist UIDnumEntry UIDnumTune UIListView UIMessageBox UINumEntry UINumTune syn keyword rapidBuildInFunction contained ValidIO ValToStr Vectmagn " Bulls Eye functions @@ -341,21 +360,23 @@ else syn keyword rapidBuildInFunction contained PMgrAtSafe PMgrAtService PMgrAtState PMgrAtStation PMgrNextStation PMgrTaskNumber PMgrTaskName " Spot functions syn keyword rapidBuildInFunction contained SwGetCurrTargetName SwGetCurrSpotName + " Homepos-Running functions + syn keyword rapidBuildInFunction contained HR_RobotInHome HR_GetTypeDIndex HR_GetTypeIndex if g:rapidGroupName highlight default link rapidBuildInFunction BuildInFunction else highlight default link rapidBuildInFunction Function endif -" }}} + " }}} -" Function {{{ - syn match rapidFunction contains=rapidBuildInFunction /\v\c%(<(proc|module)\s+)@1032 chars are not possible in rapid. a234567890123456789012345 - syn match rapidError0 /\w\{33,}/ containedin=rapidFunction,rapidNames,rapidLabel + syn match rapidErrorIdentifierNameTooLong /\k\{33,}/ containedin=rapidFunction,rapidNames,rapidLabel + highlight default link rapidErrorIdentifierNameTooLong Error " - " a string containing a single \ which is not a char code - syn match rapidError1 contained containedin=rapidString /\c\v[^\\]\zs\\\ze[^\\0-9]/ + " a == b + 1 + syn match rapidErrorShouldBeColonEqual /\c\v%(^\s*%(%(TASK\s+|LOCAL\s+)?%(VAR|PERS|CONST)\s+\k+\s+)?\k+%(\k|[.{},*/+-])*\s*)@<=\=/ + highlight default link rapidErrorShouldBeColonEqual Error " - " WaitUntil a==b ok - " || - syn match rapidError4 /\c\v%(^\s*%(Return|WaitUntil)>[^!\\]+[^!<>])@<=%(\=|:)\=/ - syn match rapidError5 /\c\v%(^\s*if>[^!\\]+[^!<>])@<=%(\=|:)\=\ze[^!]*then/ - syn match rapidError6 /\c\v%(^\s*while>[^!\\]+[^!<>])@<=%(\=|:)\=\ze[^!]*do/ + " WaitUntil a==b + syn match rapidErrorShouldBeEqual /\c\v%(^\s*(Return|WaitUntil|while)>[^!\\]+[^!<>])@<=%(\=|:)\=/ + syn match rapidErrorShouldBeEqual /\c\v%(^\s*(if|elseif)>[^!\\]+[^!<>])@<=%(\=|:)\=\ze[^!\\]+/ + highlight default link rapidErrorShouldBeEqual Error " - " WaitUntil a=>b ok - " || - syn match rapidError7 /\c\v%(^\s*%(Return|WaitUntil|if|while)>[^!]+[^!<>])@<=\=[><]/ + " WaitUntil a=>b + syn match rapidErrorShoudBeLessOrGreaterEqual /\c\v%(^\s*%(Return|WaitUntil|if|elseif|while)>[^!]+[^!<>])@<=\=[><]/ + highlight default link rapidErrorShoudBeLessOrGreaterEqual Error " - " WaitUntil a>\s*\\s*\