diff options
27 files changed, 380 insertions, 252 deletions
diff --git a/runtime/autoload/ccomplete.vim b/runtime/autoload/ccomplete.vim index f804710b3c..64e00797c7 100644 --- a/runtime/autoload/ccomplete.vim +++ b/runtime/autoload/ccomplete.vim @@ -1,7 +1,7 @@ " Vim completion script " Language: C " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2005 Dec 18 +" Last Change: 2006 Jan 29 " This function is used for the 'omnifunc' option. @@ -55,7 +55,7 @@ function! ccomplete#Complete(findstart, base) " Only one part, no "." or "->": complete from tags file. " When local completion is wanted CTRL-N would have been used. - return map(taglist('^' . base), 'v:val["name"]') + return map(taglist('^' . base), 's:Tag2item(v:val)') endif " Find the variable items[0]. @@ -106,7 +106,7 @@ function! ccomplete#Complete(findstart, base) " type, add a "." or "->". if len(res) == 1 && res[0]['match'] == items[-1] && len(s:SearchMembers(res, [''])) > 0 " If there is a '*' before the name use "->". - if match(res[0]['tagline'], '\*\s*' . res[0]['match']) > 0 + if match(res[0]['tagline'], '\*\s*' . res[0]['match'] . '\>') > 0 let res[0]['match'] .= '->' else let res[0]['match'] .= '.' @@ -116,6 +116,25 @@ function! ccomplete#Complete(findstart, base) return map(res, 'v:val["match"]') endfunc +" +" Turn the tag info "val" into an item for completion. +" "val" is is an item in the list returned by taglist(). +function! s:Tag2item(val) + if has_key(a:val, "kind") && a:val["kind"] == 'v' + if len(s:SearchMembers([{'match': a:val["name"], 'dict': a:val}], [''])) > 0 + " If there is a '*' before the name use "->". This assumes the command + " is a search pattern! + if match(a:val['cmd'], '\*\s*' . a:val['name'] . '\>') > 0 + return a:val["name"] . '->' + else + return a:val["name"] . '.' + endif + endif + endif + return a:val["name"] +endfunction + + " Find composing type in "lead" and match items[0] with it. " Repeat this recursively for items[1], if it's there. " Return the list of matches. @@ -236,18 +255,34 @@ endfunction function! s:SearchMembers(matches, items) let res = [] for i in range(len(a:matches)) - let line = a:matches[i]['tagline'] - let e = matchend(line, '\ttypename:') - if e > 0 - " Use typename field - let name = matchstr(line, '[^\t]*', e) + let typename = '' + if has_key(a:matches[i], 'dict') + "if a:matches[i].dict['name'] == "gui" + "echomsg string(a:matches[i].dict) + "endif + if has_key(a:matches[i].dict, 'typename') + let typename = a:matches[i].dict['typename'] + endif + let line = "\t" . a:matches[i].dict['cmd'] + else + let line = a:matches[i]['tagline'] + let e = matchend(line, '\ttypename:') + if e > 0 + " Use typename field + let typename = matchstr(line, '[^\t]*', e) + endif + endif + if typename != '' call extend(res, s:StructMembers(name, a:items)) else " Use the search command (the declaration itself). let s = match(line, '\t\zs/^') if s > 0 - let e = match(line, a:matches[i]['match'], s) + let e = match(line, '\<' . a:matches[i]['match'] . '\>', s) if e > 0 + "if a:matches[i].dict['name'] == "gui" + "echomsg strpart(line, s, e - s) + "endif call extend(res, s:Nextitem(strpart(line, s, e - s), a:items)) endif endif diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c953db315a..d119e127d0 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.0aa. Last change: 2006 Jan 24 +*eval.txt* For Vim version 7.0aa. Last change: 2006 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2374,6 +2374,8 @@ filter({expr}, {string}) *filter()* :let l = filter(copy(mylist), '& =~ "KEEP"') < Returns {expr}, the List or Dictionary that was filtered. + When an error is encountered while evaluating {string} no + further items in {expr} are processed. finddir({name}[, {path}[, {count}]]) *finddir()* @@ -2700,7 +2702,8 @@ getloclist({nr}) *getloclist()* Returns a list with all the entries in the location list for window {nr}. When {nr} is zero the current window is used. For a location list window, the displayed location list is - returned. Otherwise, same as getqflist(). + returned. For an invalid window number {nr}, an empty list is + returned. Otherwise, same as getqflist(). getqflist() *getqflist()* Returns a list with all the current quickfix errors. Each @@ -3263,6 +3266,8 @@ map({expr}, {string}) *map()* :let tlist = map(copy(mylist), ' & . "\t"') < Returns {expr}, the List or Dictionary that was filtered. + When an error is encountered while evaluating {string} no + further items in {expr} are processed. maparg({name}[, {mode}]) *maparg()* @@ -3982,7 +3987,8 @@ setline({lnum}, {line}) *setline()* setloclist({nr}, {list} [, {action}]) *setloclist()* Create or replace or add to the location list for window {nr}. When {nr} is zero the current window is used. For a location - list window, the displayed location list is modified. + list window, the displayed location list is modified. For an + invalid window number {nr}, -1 is returned. Otherwise, same as setqflist(). setqflist({list} [, {action}]) *setqflist()* @@ -4411,16 +4417,16 @@ taglist({expr}) *taglist()* Returns a list of tags matching the regular expression {expr}. Each list item is a dictionary with at least the following entries: - name name of the tag. - filename name of the file where the tag is + name Name of the tag. + filename Name of the file where the tag is defined. cmd Ex command used to locate the tag in the file. - kind type of the tag. The value for this + kind Type of the tag. The value for this entry depends on the language specific kind values generated by the ctags tool. - static a file specific tag. Refer to + static A file specific tag. Refer to |static-tag| for more information. The "kind" entry is only available when using Exuberant ctags generated tags file. More entries may be present, depending diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 0a28038dc2..92d85e41f6 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1,4 +1,4 @@ -*insert.txt* For Vim version 7.0aa. Last change: 2006 Jan 08 +*insert.txt* For Vim version 7.0aa. Last change: 2006 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -871,8 +871,8 @@ CTRL-X CTRL-V Guess what kind of item is in front of the cursor and User defined completion *compl-function* Completion is done by a function that can be defined by the user with the -'completefunc' option. See the 'completefunc' help for how the function -is called and an example. +'completefunc' option. See below for how the function is called and an +example |complete-functions|. *i_CTRL-X_CTRL-U* CTRL-X CTRL-U Guess what kind of item is in front of the cursor and @@ -890,7 +890,7 @@ Omni completion *compl-omni* Completion is done by a function that can be defined by the user with the 'omnifunc' option. This is to be used for filetype-specific completion. -See the 'completefunc' help for how the function is called and an example. +See below for how the function is called and an example |complete-functions|. For remarks about specific filetypes see |compl-omni-filetypes|. *i_CTRL-X_CTRL-O* @@ -952,6 +952,94 @@ CTRL-P Find previous match for words that start with the other contexts unless a double CTRL-X is used. +FUNCTIONS FOR FINDING COMPLETIONS *complete-functions* + +This applies to 'completefunc' and 'omnifunc'. + +The function will be invoked with two arguments. First the function is called +to find the start of the text to be completed. Secondly the function is +called to actually find the matches. + +On the first invocation the arguments are: + a:findstart 1 + a:base empty + +The function must return the column of where the completion starts. It must +be a number between zero and the cursor column "col('.')". This involves +looking at the characters just before the cursor and including those +characters that could be part of the completed item. The text between this +column and the cursor column will be replaced with the matches. Return -1 if +no completion can be done. + +On the second invocation the arguments are: + a:findstart 0 + a:base the text with which matches should match, what was + located in the first call (can be empty) + +The function must return a List with the matching words. These matches +usually include the "a:base" text. When there are no matches return an empty +List. When one of the items in the list cannot be used as a string (e.g., a +Dictionary) then an error message is given and further items in the list are +not used. + +When searching for matches takes some time call |complete_add()| to add each +match to the total list. These matches should then not appear in the returned +list! Call |complete_check()| now and then to allow the user to press a key +while still searching for matches. Stop searching when it returns non-zero. + +The function may move the cursor, it is restored afterwards. This option +cannot be set from a |modeline| or in the |sandbox|, for security reasons. + +An example that completes the names of the months: > + fun! CompleteMonths(findstart, base) + if a:findstart + " locate the start of the word + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\a' + let start -= 1 + endwhile + return start + else + " find months matching with "a:base" + let res = [] + for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") + if m =~ '^' . a:base + call add(res, m) + endif + endfor + return res + endif + endfun + set completefunc=CompleteMonths +< +The same, but now pretending searching for matches is slow: > + fun! CompleteMonths(findstart, base) + if a:findstart + " locate the start of the word + let line = getline('.') + let start = col('.') - 1 + while start > 0 && line[start - 1] =~ '\a' + let start -= 1 + endwhile + return start + else + " find months matching with "a:base" + for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") + if m =~ '^' . a:base + call complete_add(m) + endif + sleep 300m " simulate searching for next match + if complete_check() + break + endif + endfor + return [] + endif + endfun + set completefunc=CompleteMonths +< + INSERT COMPLETION POPUP MENU *ins-completion-menu* *popupmenu-completion* Vim can display the matches in a simplistic popup menu. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4c04f09dd5..df29077b7a 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 7.0aa. Last change: 2006 Jan 23 +*options.txt* For Vim version 7.0aa. Last change: 2006 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1183,6 +1183,7 @@ A jump table for the options with a short description can be found at |Q_op|. autocommands. {not available when compiled without the |+autocmd| feature} quickfix quickfix buffer, contains list of errors |:cwindow| + or list of locations |:lwindow| help help buffer (you are not supposed to set this manually) @@ -1191,8 +1192,9 @@ A jump table for the options with a short description can be found at |Q_op|. Be careful with changing this option, it can have many side effects! - A "quickfix" buffer is only used for the error list. This value is - set by the |:cwindow| command and you are not supposed to change it. + A "quickfix" buffer is only used for the error list and the location + list. This value is set by the |:cwindow| and |:lwindow| commands and + you are not supposed to change it. "nofile" and "nowrite" buffers are similar: both: The buffer is not to be written to disk, ":w" doesn't @@ -1611,90 +1613,9 @@ A jump table for the options with a short description can be found at |Q_op|. or +insert_expand feature} This option specifies a function to be used for Insert mode completion with CTRL-X CTRL-U. |i_CTRL-X_CTRL-U| + See |complete-functions| for an explanation of how the function is + invoked and what it should return. - The function will be invoked with two arguments. First the function - is called to find the start of the text to be completed. Secondly the - function is called to actually find the matches. - - On the first invocation the arguments are: - a:findstart 1 - a:base empty - - The function must return the column of where the completion starts. - It must be a number between zero and the cursor column "col('.')". - This involves looking at the characters just before the cursor and - including those characters that could be part of the completed item. - The text between this column and the cursor column will be replaced - with the matches. Return -1 if no completion can be done. - - On the second invocation the arguments are: - a:findstart 0 - a:base the text with which matches should match, what was - located in the first call (can be empty) - - The function must return a List with the matching words. These - matches usually include the "a:base" text. When there are no matches - return an empty List. - - When searching for matches takes some time call |complete_add()| to - add each match to the total list. These matches should then not - appear in the returned list! Call |complete_check()| now and then to - allow the user to press a key while still searching for matches. Stop - searching when it returns non-zero. - - The function may move the cursor, it is restored afterwards. - This option cannot be set from a |modeline| or in the |sandbox|, for - security reasons. - - An example that completes the names of the months: > - fun! CompleteMonths(findstart, base) - if a:findstart - " locate the start of the word - let line = getline('.') - let start = col('.') - 1 - while start > 0 && line[start - 1] =~ '\a' - let start -= 1 - endwhile - return start - else - " find months matching with "a:base" - let res = [] - for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base - call add(res, m) - endif - endfor - return res - endif - endfun - set completefunc=CompleteMonths -< - The same, but now pretending searching for matches is slow: > - fun! CompleteMonths(findstart, base) - if a:findstart - " locate the start of the word - let line = getline('.') - let start = col('.') - 1 - while start > 0 && line[start - 1] =~ '\a' - let start -= 1 - endwhile - return start - else - " find months matching with "a:base" - for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") - if m =~ '^' . a:base - call complete_add(m) - endif - sleep 300m " simulate searching for next match - if complete_check() - break - endif - endfor - return [] - endif - endfun - set completefunc=CompleteMonths -< *'completeopt'* *'cot'* 'completeopt' 'cot' string (default: "menu") @@ -4681,7 +4602,8 @@ A jump table for the options with a short description can be found at |Q_op|. or +insert_expand feature} This option specifies a function to be used for Insert mode omni completion with CTRL-X CTRL-O. |i_CTRL-X_CTRL-O| - For the use of the function see 'completefunc'. + See |complete-functions| for an explanation of how the function is + invoked and what it should return. *'operatorfunc'* *'opfunc'* @@ -5802,11 +5724,12 @@ A jump table for the options with a short description can be found at |Q_op|. global {not in Vi} When on, a <Tab> in front of a line inserts blanks according to - 'shiftwidth'. 'tabstop' is used in other places. A <BS> will delete - a 'shiftwidth' worth of space at the start of the line. - When off a <Tab> always inserts blanks according to 'tabstop'. - 'shiftwidth' is only used for shifting text left or right - |shift-left-right|. + 'shiftwidth'. 'tabstop' or 'softtabstop' is used in other places. A + <BS> will delete a 'shiftwidth' worth of space at the start of the + line. + When off a <Tab> always inserts blanks according to 'tabstop' or + 'softtabstop'. 'shiftwidth' is only used for shifting text left or + right |shift-left-right|. What gets inserted (a Tab or spaces) depends on the 'expandtab' option. Also see |ins-expandtab|. When 'expandtab' is not set, the number of spaces is minimized by using <Tab>s. diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index b4b3f813fa..bdda74fc65 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim version 7.0aa. Last change: 2006 Jan 26 +*quickfix.txt* For Vim version 7.0aa. Last change: 2006 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -43,13 +43,18 @@ easy way to do this is with the |:make| command (see below). The compiler (see |errorformat| below). *location-list* *E776* -A location list is a window-local quickfix list. Each window can have a -separate location list. A location list can be associated with only one -window. When a window with a location list is split, the new window gets a -copy of the location list. When there are no references to a location list, -the location list is destroyed. +A location list is similar to a quickfix list and contains a list of positions +in files. A location list is associated with a window and each window can +have a separate location list. A location list can be associated with only +one window. The location list is independent of the quickfix list. -The following quickfix commands can be used: +When a window with a location list is split, the new window gets a copy of the +location list. When there are no references to a location list, the location +list is destroyed. + +The following quickfix commands can be used. The location list commands are +similar to the quickfix commands, replacing the 'c' prefix in the quickfix +command with 'l'. *:cc* :cc[!] [nr] Display error [nr]. If [nr] is omitted, the same @@ -265,7 +270,7 @@ on) is executed. See |QuickFixCmdPre| and |QuickFixCmdPost| for details. current window. Works only when the location list for the current window is present. You can have more than one location window opened at a time. Otherwise, it - acts the same same as ":copen". + acts the same as ":copen". *:ccl* *:cclose* :ccl[ose] Close the quickfix window. @@ -308,9 +313,9 @@ When the quickfix window has been filled, two autocommand events are triggered. First the 'filetype' option is set to "qf", which triggers the FileType event. Then the BufReadPost event is triggered. This can be used to perform some action on the listed errors. Example: > - au BufReadPost quickfix setlocal nomodifiable - \ | silent g/^/s//\=line(".")." "/ - \ | setlocal modifiable + au BufReadPost quickfix setlocal modifiable + \ | silent exe 'g/^/s//\=line(".")." "/' + \ | setlocal nomodifiable This prepends the line number to each line. Note the use of "\=" in the substitute string of the ":s" command, which is used to evaluate an expression. @@ -323,17 +328,26 @@ window to a file and use ":cfile" to have it parsed and used as the new error list. *location-list-window* -The location list window displays the entries in a location list. When -opening a location list window, it is created just below the current window -and displays the location list for the current window. The location list -window is similar to the quickfix window, except that you can have more than -one location list window opened at a time. - -When an entry is selected from the location list window, the file is opened in -the window with the corresponding location list. If the window is not found, -but the file is opened in another window, then cursor is moved to that window. -Otherwise a new window is opened. The new window gets a copy of the location -list. +The location list window displays the entries in a location list. When you +open a location list window, it is created below the current window and +displays the location list for the current window. The location list window +is similar to the quickfix window, except that you can have more than one +location list window open at a time. + +When you select a file from the location list window, the following steps are +used to find a window to edit the file: + +1. If a window with the location list displayed in the location list window is + present, then the file is opened in that window. +2. If the above step fails and if the file is already opened in another + window, then that window is used. +3. If the above step fails then an existing window showing a buffer with + 'buftype' not set is used. +4. If the above step fails, then the file is edited in a new window. + +In all of the above cases, if the location list for the selected window is not +yet set, then it is set to the location list displayed in the location list +window. ============================================================================= 3. Using more than one list of errors *quickfix-error-lists* diff --git a/runtime/doc/tags b/runtime/doc/tags index 4ad56bb993..76446809f7 100644 --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -5398,7 +5398,6 @@ hebrew hebrew.txt /*hebrew* hebrew.txt hebrew.txt /*hebrew.txt* help various.txt /*help* help-context help.txt /*help-context* -help-tags tags 1 help-translated various.txt /*help-translated* help-xterm-window various.txt /*help-xterm-window* help.txt help.txt /*help.txt* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt index 8d49c5f4f2..efec6ca1e7 100644 --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 7.0aa. Last change: 2006 Jan 26 +*todo.txt* For Vim version 7.0aa. Last change: 2006 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -30,13 +30,27 @@ be worked on, but only if you sponsor Vim development. See |sponsor|. *known-bugs* -------------------- Known bugs and current work ----------------------- +Truncating error message keeps one char too many, causes an empty line. + +Variant of ":helpgrep" that uses a location list? How about: + :lhelpgrep (use local list in help window, not current window) + :lgrep + :lvimgrep + :lmake + ccomplete / omnicomplete: +- Also add . or -> when completing struct members. use s:Tag2item() - When an option is set: In completion mode and the user types (identifier) characters, advance to the first match instead of removing the popup menu. If there is no match remove the selection. (Yegappan Lakshmanan) + Keep the current list of all matches. Use the text typed (or completed) so + far to make a second list with only matching entries. - Complete the longest common match instead of the first match? - For all kinds of completions? Configurable? -- Window resize when poup is displayed. + Do this when "longest" is in 'completeopt'. + Pressing CTRL-N or CTRL-P will get the whole match, as before. + Need to postpone inserting anything until all matches have been found. + Then add a completion item with the longest common string (after what was + typed), if there is one. - When completing something that is a structure, add the "." or "->" right away. How to figure out if it's a pointer or not? - When a typedef or struct is local to a file only use it in that file? @@ -52,11 +66,10 @@ ccomplete / omnicomplete: a specific selection (e.g, methods vs variables). - Provide a function to popup the menu, so that an insert mode mapping can start it (with a specific selection). -- !_TAG_FILE_FORMAT and it's ilk are listed in the global completions - Can't reproduce it right now... spelling: - Also use the spelling dictionary for dictionary completion. + When 'dictionary' is empty and/or when "kspell" is in 'complete'. - Use runtime/cleanadd script to cleanup .add files. When to invoke it? After deleting a word with "zw" and some timestamp difference perhaps? Store it as spell/cleanadd.vim. @@ -3781,6 +3794,8 @@ Far future and "big" extensions: are reflected in each Vim immediately. Could work with local files but also over the internet. See http://www.codingmonkeys.de/subethaedit/. +When using "do" or ":diffget" in a buffer with changes in every line an extra +empty line would appear. vim:tw=78:sw=4:sts=4:ts=8:ft=help:norl: vim: set fo+=n : diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt index 763ecb8216..a5db46dfff 100644 --- a/runtime/doc/version7.txt +++ b/runtime/doc/version7.txt @@ -1,4 +1,4 @@ -*version7.txt* For Vim version 7.0aa. Last change: 2006 Jan 26 +*version7.txt* For Vim version 7.0aa. Last change: 2006 Jan 28 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1624,4 +1624,9 @@ The command line was cleared to often when 'showmode' was set and ":silent normal vy" was used. Don't clear the command line unless the mode was actually displayed. Added the "mode_displayed" variable. +The "load session" toolbar item could not handle a space or other special +characters in v:this_session. + +":set sta ts=8 sw=4 sts=2" deleted 4 spaces halfway a line instead of 2. + vim:tw=78:ts=8:ft=help:norl: diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt index 6912808c04..8e38965101 100644 --- a/runtime/doc/windows.txt +++ b/runtime/doc/windows.txt @@ -1,4 +1,4 @@ -*windows.txt* For Vim version 7.0aa. Last change: 2006 Jan 19 +*windows.txt* For Vim version 7.0aa. Last change: 2006 Jan 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -992,9 +992,11 @@ list of buffers. |unlisted-buffer| Split window and edit buffer for {filename} from the buffer list. This will also edit a buffer that is not in the buffer list, without setting the 'buflisted' flag. + Note: If what you want to do is split the buffer, make a copy + under another name, you can do it this way: > + :w foobar | sp # - *:bn* *:bnext* *E87* -:[N]bn[ext][!] [N] +:[N]bn[ext][!] [N] *:bn* *:bnext* *E87* Go to [N]th next buffer in buffer list. [N] defaults to one. Wraps around the end of the buffer list. See |:buffer-!| for [!]. @@ -1089,9 +1091,10 @@ purposes. A few options can be set to change the behavior of a buffer: A few useful kinds of a buffer: -quickfix Used to contain the error list. See |:cwindow|. This command - sets the 'buftype' option to "quickfix". You are not supposed - to change this! 'swapfile' is off. +quickfix Used to contain the error list or the location list. See + |:cwindow| and |:lwindow|. This command sets the 'buftype' + option to "quickfix". You are not supposed to change this! + 'swapfile' is off. help Contains a help file. Will only be created with the |:help| command. The flag that indicates a help buffer is internal diff --git a/runtime/indent/vhdl.vim b/runtime/indent/vhdl.vim index a476d6dedc..bad838a077 100644 --- a/runtime/indent/vhdl.vim +++ b/runtime/indent/vhdl.vim @@ -1,9 +1,9 @@ -" VHDL indent file ('93 syntax) +" VHDL indent ('93 syntax) " Language: VHDL " Maintainer: Gerald Lai <laigera+vim?gmail.com> -" Credits: N. J. Heo & Janez Stangelj -" Version: 1.1 -" Last Change: 2006 Jan 25 +" Version: 1.2 +" Last Change: 2006 Jan 26 +" URL: http://www.vim.org/scripts/script.php?script_id=1450 " only load this indent file when no other was loaded if exists("b:did_indent") @@ -78,6 +78,17 @@ function GetVHDLindent() " backup default let ind2 = ind + " indent: special; kill string so it would not affect other filters + " keywords: "report" + string + " where: anywhere in current or previous line + let s0 = s:NC.'\<report\>\s*".*"' + if curs =~? s0 + let curs = "" + endif + if prevs =~? s0 + let prevs = "" + endif + " indent: previous line's comment position, otherwise follow next non-comment line if possible " keyword: "--" " where: start of current line @@ -124,9 +135,9 @@ function GetVHDLindent() endif " indent: align conditional/select statement - " keywords: "<=" without ";" ending - " where: anywhere in previous line - if prevs =~ s:NC.'<=[^;]*'.s:ES + " keywords: variable + "<=" without ";" ending + " where: start of previous line + if prevs =~? '^\s*\S\+\s*<=[^;]*'.s:ES return matchend(prevs, '<=\s*\ze.') endif @@ -156,13 +167,13 @@ function GetVHDLindent() let t = indent(pn) if ps !~ '^\s*--' && t < ind " make sure one of these is true + " keywords: variable + "<=" without ";" ending + " where: start of previous non-comment line " keywords: "generic", "map", "port" " where: anywhere in previous non-comment line " keyword: "(" " where: start of previous non-comment line - " keywords: "<=" without ";" ending - " where: anywhere in previous non-comment line - if m < 3 && ps !~ s:NC.'<=[^;]*'.s:ES + if m < 3 && ps !~? '^\s*\S\+\s*<=[^;]*'.s:ES if ps =~? s:NC.'\<\%(generic\|map\|port\)\>' || ps =~ '^\s*(' let ind = t endif @@ -236,38 +247,38 @@ function GetVHDLindent() return 0 endif - " indent: follow indent of previous opening statement + " indent: maintain indent of previous opening statement " keyword: "is" " where: start of current line " find previous opening statement of " keywords: "architecture", "block", "configuration", "entity", "function", "package", "procedure", "process", "type" if curs =~? '^\s*\<is\>' && prevs =~? s:NC.s:NE.'\<\%(architecture\|block\|configuration\|entity\|function\|package\|procedure\|process\|type\)\>' - return indent(prevn) + return ind2 endif - " indent: follow indent of previous opening statement + " indent: maintain indent of previous opening statement " keyword: "then" " where: start of current line " find previous opening statement of " keywords: "elsif", "if" if curs =~? '^\s*\<then\>' && (prevs =~? s:NC.'\<elsif\>' || prevs =~? s:NC.s:NE.'\<if\>') - return indent(prevn) + return ind2 endif - " indent: follow indent of previous opening statement + " indent: maintain indent of previous opening statement " keyword: "generate" " where: start of current line " find previous opening statement of " keywords: "for", "if" - if curs =~? '^\s*\<generate\>' && (prevs =~? s:NC.'\<for\>' || prevs =~? s:NC.s:NE.'\<if\>') - return indent(prevn) + if curs =~? '^\s*\<generate\>' && (prevs =~? s:NC.s:NE.'\%(\<wait\s\+\)\@<!\<for\>' || prevs =~? |