# HG changeset patch # User Bram Moolenaar # Date 1545165908 -3600 # Node ID 8b334e4cb97f993a7515aee6e300a7be1b42353e # Parent 0154f020f97e0155c4fb10054aaf33b227cc4bf9 Update runtime files. commit https://github.com/vim/vim/commit/9d87a37ee9d87f5bdbc779bc940d5f1e6f055d0a Author: Bram Moolenaar Date: Tue Dec 18 21:41:50 2018 +0100 Update runtime files. diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1,4 +1,4 @@ -*change.txt* For Vim version 8.1. Last change: 2018 May 12 +*change.txt* For Vim version 8.1. Last change: 2018 Dec 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -944,9 +944,9 @@ When the result is a |List| then the ite breaks. Thus each item becomes a line, except that they can contain line breaks themselves. -The whole matched text can be accessed with "submatch(0)". The text matched -with the first pair of () with "submatch(1)". Likewise for further -sub-matches in (). +The |submatch()| function can be used to obtain matched text. The whole +matched text can be accessed with "submatch(0)". The text matched with the +first pair of () with "submatch(1)". Likewise for further sub-matches in (). Be careful: The separation character must not appear in the expression! Consider using a character like "@" or ":". There is no problem if the result diff --git a/runtime/doc/digraph.txt b/runtime/doc/digraph.txt --- a/runtime/doc/digraph.txt +++ b/runtime/doc/digraph.txt @@ -1,4 +1,4 @@ -*digraph.txt* For Vim version 8.1. Last change: 2016 Nov 04 +*digraph.txt* For Vim version 8.1. Last change: 2018 Dec 14 VIM REFERENCE MANUAL by Bram Moolenaar diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt --- a/runtime/doc/editing.txt +++ b/runtime/doc/editing.txt @@ -1,4 +1,4 @@ -*editing.txt* For Vim version 8.1. Last change: 2018 Mar 29 +*editing.txt* For Vim version 8.1. Last change: 2018 Dec 16 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1415,7 +1415,7 @@ cannot be read without the right key. The text in the swap file and the undo file is also encrypted. *E843* However, this is done block-by-block and may reduce the time needed to crack a password. You can disable the swap file, but then a crash will cause you to -lose your work. The undo file can be disabled without much disadvantage. > +lose your work. The undo file can be disabled without too much disadvantage. > :set noundofile :noswapfile edit secrets diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.1. Last change: 2018 Dec 13 +*eval.txt* For Vim version 8.1. Last change: 2018 Dec 18 VIM REFERENCE MANUAL by Bram Moolenaar @@ -2318,7 +2318,7 @@ prompt_setcallback({buf}, {expr}) none s prompt_setinterrupt({buf}, {text}) none set prompt interrupt function prompt_setprompt({buf}, {text}) none set prompt text prop_add({lnum}, {col}, {props}) none add a text property -prop_clear({lnum} [, {lnum_end} [, {bufnr}]]) +prop_clear({lnum} [, {lnum-end} [, {bufnr}]]) none remove all text properties prop_find({props} [, {direction}]) Dict search for a text property @@ -2714,7 +2714,7 @@ assert_fails({cmd} [, {error} [, {msg}]] assert_false({actual} [, {msg}]) *assert_false()* When {actual} is not false an error message is added to - |v:errors|, like with |assert_equal()|. + |v:errors|, like with |assert_equal()|. Also see |assert-return|. A value is false when it is zero. When {actual} is not a number the assert fails. @@ -5058,7 +5058,7 @@ getwininfo([{winid}]) *getwininfo()* getwinpos([{timeout}]) *getwinpos()* The result is a list with two numbers, the result of - getwinposx() and getwinposy() combined: + getwinposx() and getwinposy() combined: [x-pos, y-pos] {timeout} can be used to specify how long to wait in msec for a response from the terminal. When omitted 100 msec is used. @@ -6688,7 +6688,7 @@ prop_add({lnum}, {col}, {props}) "end_lnum" - line number for end of text "end_col" - column for end of text; not used when "length" is present - "bufnr - buffer to add the property to; when + "bufnr" - buffer to add the property to; when omitted the current buffer is used "id" - user defined ID for the property; when omitted zero is used @@ -6699,7 +6699,7 @@ prop_add({lnum}, {col}, {props}) are passed. Either use "length" or "end_col" for a property within one line, or use "end_lnum" and "end_col" for a property that spans more than one line. - When neither "length" or "end_col" are passed the property + When neither "length" nor "end_col" are passed the property will apply to one character. "type" will first be looked up in the buffer the property is @@ -6709,10 +6709,10 @@ prop_add({lnum}, {col}, {props}) See |text-properties| for information about text properties. -prop_clear({lnum} [, {lnum_end} [, {props}]]) *prop_clear()* +prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()* Remove all text properties from line {lnum}. - When {lnum_end} is given, remove all text properties from line - {lnum} to {lnum_end} (inclusive). + When {lnum-end} is given, remove all text properties from line + {lnum} to {lnum-end} (inclusive). When {props} contains a "bufnr" item use this buffer, otherwise use the current buffer. @@ -6772,7 +6772,7 @@ prop_list({lnum} [, {props}]) *prop_ *prop_remove()* *E968* -prop_remove({props} [, {lnum} [, {lnum_end}]]) +prop_remove({props} [, {lnum} [, {lnum_end}]]) Remove a matching text property from line {lnum}. When {lnum_end} is given, remove matching text properties from line {lnum} to {lnum_end} (inclusive). @@ -9046,7 +9046,7 @@ test_option_not_set({name}) *test_opt Only to be used for testing! test_override({name}, {val}) *test_override()* - Overrides certain parts of Vims internal processing to be able + Overrides certain parts of Vim's internal processing to be able to run tests. Only to be used for testing Vim! The override is enabled when {val} is non-zero and removed when {val} is zero. diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -1,4 +1,4 @@ -*help.txt* For Vim version 8.1. Last change: 2017 Oct 28 +*help.txt* For Vim version 8.1. Last change: 2018 Dec 14 VIM - main help file k @@ -113,7 +113,6 @@ Basic editing ~ |scroll.txt| scrolling the text in the window |insert.txt| Insert and Replace mode |change.txt| deleting and replacing text -|indent.txt| automatic indenting for C and other languages |undo.txt| Undo and Redo |repeat.txt| repeating commands, Vim scripts and debugging |visual.txt| using the Visual mode (selecting a text area) @@ -126,14 +125,11 @@ Advanced editing ~ |pattern.txt| regexp patterns and search commands |map.txt| key mapping and abbreviations |tagsrch.txt| tags and special searches -|quickfix.txt| commands for a quick edit-compile-fix cycle |windows.txt| commands for using multiple windows and buffers |tabpage.txt| commands for using multiple tab pages -|syntax.txt| syntax highlighting |spell.txt| spell checking |diff.txt| working with two to four versions of the same file |autocmd.txt| automatically executing commands on an event -|filetype.txt| settings done specifically for a type of file |eval.txt| expression evaluation, conditional commands |channel.txt| Jobs, Channels, inter-process communication |fold.txt| hide (fold) ranges of lines @@ -143,18 +139,27 @@ Special issues ~ |remote.txt| using Vim as a server or client |term.txt| using different terminals and mice |terminal.txt| Terminal window support + +Programming language support ~ +|indent.txt| automatic indenting for C and other languages +|syntax.txt| syntax highlighting +|textprop.txt| Attaching properties to text for highlighting or other +|filetype.txt| settings done specifically for a type of file +|quickfix.txt| commands for a quick edit-compile-fix cycle +|ft_ada.txt| Ada (the programming language) support +|ft_rust.txt| Filetype plugin for Rust +|ft_sql.txt| about the SQL filetype plugin + +Language support ~ |digraph.txt| list of available digraphs |mbyte.txt| multi-byte text support |mlang.txt| non-English language support +|rileft.txt| right-to-left editing mode |arabic.txt| Arabic language support and editing |farsi.txt| Farsi (Persian) editing |hebrew.txt| Hebrew language support and editing |russian.txt| Russian language support and editing -|ft_ada.txt| Ada (the programming language) support -|ft_rust.txt| Filetype plugin for Rust -|ft_sql.txt| about the SQL filetype plugin |hangulin.txt| Hangul (Korean) input mode -|rileft.txt| right-to-left editing mode GUI ~ |gui.txt| Graphical User Interface (GUI) diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1,4 +1,4 @@ -*map.txt* For Vim version 8.1. Last change: 2018 Dec 08 +*map.txt* For Vim version 8.1. Last change: 2018 Dec 18 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1254,7 +1254,7 @@ reported if any are supplied). However, command can take arguments, using the -nargs attribute. Valid cases are: -nargs=0 No arguments are allowed (the default) - -nargs=1 Exactly one argument is required, it includes spaces + -nargs=1 Exactly one argument is required, it includes spaces -nargs=* Any number of arguments are allowed (0, 1, or many), separated by white space -nargs=? 0 or 1 arguments are allowed @@ -1279,7 +1279,7 @@ intended! Calling a function may be an Completion behavior ~ - *:command-completion* *E179* *E180* *E181* + *:command-completion* *E179* *E180* *E181* *:command-complete* By default, the arguments of user defined commands do not undergo completion. However, by specifying one or the other of the following attributes, argument @@ -1407,7 +1407,7 @@ Possible values are: -addr=loaded_buffers Range for loaded buffers -addr=windows Range for windows -addr=tabs Range for tab pages - -addr=other other kind of range + -addr=other other kind of range Special cases ~ diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 8.1. Last change: 2018 May 15 +*options.txt* For Vim version 8.1. Last change: 2018 Dec 18 VIM REFERENCE MANUAL by Bram Moolenaar @@ -4133,11 +4133,12 @@ A jump table for the options with a shor l:Search,m:MoreMsg,M:ModeMsg,n:LineNr, N:CursorLineNr,r:Question,s:StatusLine, S:StatusLineNC,c:VertSplit,t:Title, - v:Visual,w:WarningMsg,W:WildMenu,f:Folded, - F:FoldColumn,A:DiffAdd,C:DiffChange, - D:DiffDelete,T:DiffText,>:SignColumn, - B:SpellBad,P:SpellCap,R:SpellRare, - L:SpellLocal,-:Conceal,+:Pmenu,=:PmenuSel, + v:Visual,V:VisualNOS,w:WarningMsg, + W:WildMenu,f:Folded,F:FoldColumn, + A:DiffAdd,C:DiffChange,D:DiffDelete, + T:DiffText,>:SignColumn,-:Conceal, + B:SpellBad,P:SpellCap,R:SpellRare, + L:SpellLocal,+:Pmenu,=:PmenuSel, x:PmenuSbar,X:PmenuThumb,*:TabLine, #:TabLineSel,_:TabLineFill,!:CursorColumn, .:CursorLine,o:ColorColumn,q:QuickFixLine, @@ -4182,16 +4183,16 @@ A jump table for the options with a shor |hl-DiffDelete| D deleted line in diff mode |hl-DiffText| T inserted text in diff mode |hl-SignColumn| > column used for |signs| + |hl-Conceal| - the placeholders used for concealed characters + (see 'conceallevel') |hl-SpellBad| B misspelled word |spell| |hl-SpellCap| P word that should start with capital |spell| |hl-SpellRare| R rare word |spell| |hl-SpellLocal| L word from other region |spell| - |hl-Conceal| - the placeholders used for concealed characters - (see 'conceallevel') - |hl-Pmenu| + popup menu normal line - |hl-PmenuSel| = popup menu normal line - |hl-PmenuSbar| x popup menu scrollbar - |hl-PmenuThumb| X popup menu scrollbar thumb + |hl-Pmenu| + popup menu normal line + |hl-PmenuSel| = popup menu selected line + |hl-PmenuSbar| x popup menu scrollbar + |hl-PmenuThumb| X popup menu scrollbar thumb The display modes are: r reverse (termcap entry "mr" and "me") diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 8.1. Last change: 2018 Mar 04 +*repeat.txt* For Vim version 8.1. Last change: 2018 Dec 18 VIM REFERENCE MANUAL by Bram Moolenaar @@ -335,7 +335,10 @@ For writing a Vim script, see chapter 41 |+eval| feature} :scr[iptnames][!] {scriptId} *:script* - Edit script {scriptId}. Suggested name is ":script". + Edit script {scriptId}. Although ":scriptnames name" + works, using ":script name" is recommended. + When the current buffer can't be |abandon|ed and the ! + is not present, the command fails. *:fini* *:finish* *E168* :fini[sh] Stop sourcing a script. Can only be used in a Vim diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1,4 +1,4 @@ -*syntax.txt* For Vim version 8.1. Last change: 2018 Apr 30 +*syntax.txt* For Vim version 8.1. Last change: 2018 Dec 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -23,21 +23,22 @@ In the User Manual: 1. Quick start |:syn-qstart| 2. Syntax files |:syn-files| 3. Syntax loading procedure |syntax-loading| -4. Syntax file remarks |:syn-file-remarks| -5. Defining a syntax |:syn-define| -6. :syntax arguments |:syn-arguments| -7. Syntax patterns |:syn-pattern| -8. Syntax clusters |:syn-cluster| -9. Including syntax files |:syn-include| -10. Synchronizing |:syn-sync| -11. Listing syntax items |:syntax| -12. Highlight command |:highlight| -13. Linking groups |:highlight-link| -14. Cleaning up |:syn-clear| -15. Highlighting tags |tag-highlight| -16. Window-local syntax |:ownsyntax| -17. Color xterms |xterm-color| -18. When syntax is slow |:syntime| +4. Converting to HTML |2html.vim| +5. Syntax file remarks |:syn-file-remarks| +6. Defining a syntax |:syn-define| +7. :syntax arguments |:syn-arguments| +8. Syntax patterns |:syn-pattern| +9. Syntax clusters |:syn-cluster| +10. Including syntax files |:syn-include| +11. Synchronizing |:syn-sync| +12. Listing syntax items |:syntax| +13. Highlight command |:highlight| +14. Linking groups |:highlight-link| +15. Cleaning up |:syn-clear| +16. Highlighting tags |tag-highlight| +17. Window-local syntax |:ownsyntax| +18. Color xterms |xterm-color| +19. When syntax is slow |:syntime| {Vi does not have any of these commands} @@ -368,20 +369,9 @@ Upon loading a file, Vim finds the relev syntax. ============================================================================== -4. Syntax file remarks *:syn-file-remarks* - - *b:current_syntax-variable* -Vim stores the name of the syntax that has been loaded in the -"b:current_syntax" variable. You can use this if you want to load other -settings, depending on which syntax is active. Example: > - :au BufReadPost * if b:current_syntax == "csh" - :au BufReadPost * do-some-things - :au BufReadPost * endif - - -2HTML *2html.vim* *convert-to-HTML* - -This is not a syntax file itself, but a script that converts the current +4. Conversion to HTML *2html.vim* *convert-to-HTML* + +2html is not a syntax file itself, but a script that converts the current window into HTML. Vim opens a new window in which it builds the HTML file. After you save the resulting file, you can view it with any browser. The @@ -773,6 +763,18 @@ When 1, generate XHTML 1.0 instead (XML > :let g:html_use_xhtml = 1 < +============================================================================== +5. Syntax file remarks *:syn-file-remarks* + + *b:current_syntax-variable* +Vim stores the name of the syntax that has been loaded in the +"b:current_syntax" variable. You can use this if you want to load other +settings, depending on which syntax is active. Example: > + :au BufReadPost * if b:current_syntax == "csh" + :au BufReadPost * do-some-things + :au BufReadPost * endif + + ABEL *abel.vim* *ft-abel-syntax* @@ -3484,7 +3486,7 @@ The syntax script for zsh allows for syn :let g:zsh_fold_enable = 1 ============================================================================== -5. Defining a syntax *:syn-define* *E410* +6. Defining a syntax *:syn-define* *E410* Vim understands three types of syntax items: @@ -3843,7 +3845,7 @@ DEFINING REGIONS *:syn-region* *:syn-sta The maximum number of syntax groups is 19999. ============================================================================== -6. :syntax arguments *:syn-arguments* +7. :syntax arguments *:syn-arguments* The :syntax commands that define syntax items take a number of arguments. The common ones are explained here. The arguments may be given in any order @@ -4164,7 +4166,7 @@ IMPLICIT CONCEAL *:syn-conceal-impli Show either "syntax conceal on" or "syntax conceal off" (translated). ============================================================================== -7. Syntax patterns *:syn-pattern* *E401* *E402* +8. Syntax patterns *:syn-pattern* *E401* *E402* In the syntax commands, a pattern must be surrounded by two identical characters. This is like it works for the ":s" command. The most common to @@ -4342,7 +4344,7 @@ Note that only matches within a single l cannot be referred to. ============================================================================== -8. Syntax clusters *:syn-cluster* *E400* +9. Syntax clusters *:syn-cluster* *E400* :sy[ntax] cluster {cluster-name} [contains={group-name}..] [add={group-name}..] @@ -4388,7 +4390,7 @@ This also has implications for nested cl The maximum number of clusters is 9767. ============================================================================== -9. Including syntax files *:syn-include* *E397* +10. Including syntax files *:syn-include* *E397* It is often useful for one language's syntax file to include a syntax file for a related language. Depending on the exact relationship, this can be done in @@ -4429,7 +4431,7 @@ two different ways: The maximum number of includes is 999. ============================================================================== -10. Synchronizing *:syn-sync* *E403* *E404* +11. Synchronizing *:syn-sync* *E403* *E404* Vim wants to be able to start redrawing in any position in the document. To make this possible it needs to know the syntax state at the position where @@ -4621,7 +4623,7 @@ You can clear specific sync patterns wit :syntax sync clear {sync-group-name} .. ============================================================================== -11. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list* +12. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list* This command lists all the syntax items: > @@ -4641,7 +4643,7 @@ Note that the ":syntax" command can be a is mostly used, because it looks better. ============================================================================== -12. Highlight command *:highlight* *:hi* *E28* *E411* *E415* +13. Highlight command *:highlight* *:hi* *E28* *E411* *E415* There are three types of highlight groups: - The ones used for specific languages. For these the name starts with the @@ -5134,7 +5136,7 @@ Tooltip Current font, background and fo set. ============================================================================== -13. Linking groups *:hi-link* *:highlight-link* *E412* *E413* +14. Linking groups *:hi-link* *:highlight-link* *E412* *E413* When you want to use the same highlighting for several syntax groups, you can do this more easily by linking the groups into one common highlight @@ -5172,7 +5174,7 @@ Without the "default" in the C syntax fi overruled when the syntax file is loaded. ============================================================================== -14. Cleaning up *:syn-clear* *E391* +15. Cleaning up *:syn-clear* *E391* If you want to clear the syntax stuff for the current buffer, you can use this command: > @@ -5263,7 +5265,7 @@ syntax/syncolor.vim files are loaded: them. ============================================================================== -15. Highlighting tags *tag-highlight* +16. Highlighting tags *tag-highlight* If you want to highlight all the tags in your file, you can use the following mappings. @@ -5298,7 +5300,7 @@ And put these lines in your .vimrc: > autocmd BufRead,BufNewFile *.[ch] endif ============================================================================== -16. Window-local syntax *:ownsyntax* +17. Window-local syntax *:ownsyntax* Normally all windows on a buffer share the same syntax settings. It is possible, however, to set a particular window on a file to have its own @@ -5328,7 +5330,7 @@ is loaded into that window or the file i When splitting the window, the new window will use the original syntax. ============================================================================== -17. Color xterms *xterm-color* *color-xterm* +18. Color xterms *xterm-color* *color-xterm* Most color xterms have only eight colors. If you don't get colors with the default setup, it should work with these lines in your .vimrc: > @@ -5472,7 +5474,7 @@ that Setup / Font / Enable Bold is NOT e ============================================================================== -18. When syntax is slow *:syntime* +19. When syntax is slow *:syntime* This is aimed at authors of a syntax file. diff --git a/runtime/doc/tags b/runtime/doc/tags --- a/runtime/doc/tags +++ b/runtime/doc/tags @@ -1356,6 +1356,7 @@ +terminfo various.txt /*+terminfo* +termresponse various.txt /*+termresponse* +textobjects various.txt /*+textobjects* ++textprop various.txt /*+textprop* +tgetent various.txt /*+tgetent* +timers various.txt /*+timers* +title various.txt /*+title* @@ -2919,6 +2920,7 @@ 90.5 usr_90.txt /*90.5* :scl change.txt /*:scl* :scp change.txt /*:scp* :scr repeat.txt /*:scr* +:script repeat.txt /*:script* :scripte repeat.txt /*:scripte* :scriptencoding repeat.txt /*:scriptencoding* :scriptnames repeat.txt /*:scriptnames* @@ -4653,7 +4655,16 @@ E96 diff.txt /*E96* E960 options.txt /*E960* E961 cmdline.txt /*E961* E962 eval.txt /*E962* +E963 eval.txt /*E963* +E964 eval.txt /*E964* +E965 eval.txt /*E965* +E966 eval.txt /*E966* +E967 textprop.txt /*E967* +E968 eval.txt /*E968* +E969 eval.txt /*E969* E97 diff.txt /*E97* +E970 eval.txt /*E970* +E971 textprop.txt /*E971* E98 diff.txt /*E98* E99 diff.txt /*E99* EX intro.txt /*EX* @@ -8114,7 +8125,18 @@ prompt-buffer channel.txt /*prompt-buffe prompt_setcallback() eval.txt /*prompt_setcallback()* prompt_setinterrupt() eval.txt /*prompt_setinterrupt()* prompt_setprompt() eval.txt /*prompt_setprompt()* +promptbuffer-functions usr_41.txt /*promptbuffer-functions* pronounce intro.txt /*pronounce* +prop_add() eval.txt /*prop_add()* +prop_clear() eval.txt /*prop_clear()* +prop_find() eval.txt /*prop_find()* +prop_list() eval.txt /*prop_list()* +prop_remove() eval.txt /*prop_remove()* +prop_type_add() eval.txt /*prop_type_add()* +prop_type_change() eval.txt /*prop_type_change()* +prop_type_delete() eval.txt /*prop_type_delete()* +prop_type_get() eval.txt /*prop_type_get()* +prop_type_list() eval.txt /*prop_type_list()* psql ft_sql.txt /*psql* ptcap.vim syntax.txt /*ptcap.vim* pterm-mouse options.txt /*pterm-mouse* @@ -8936,6 +8958,7 @@ tag-binary-search tagsrch.txt /*tag-bina tag-blocks motion.txt /*tag-blocks* tag-commands tagsrch.txt /*tag-commands* tag-details tagsrch.txt /*tag-details* +tag-functions usr_41.txt /*tag-functions* tag-highlight syntax.txt /*tag-highlight* tag-matchlist tagsrch.txt /*tag-matchlist* tag-old-static tagsrch.txt /*tag-old-static* @@ -9132,7 +9155,11 @@ tex.vim syntax.txt /*tex.vim* text-functions usr_41.txt /*text-functions* text-objects motion.txt /*text-objects* text-objects-changed version5.txt /*text-objects-changed* +text-prop-functions textprop.txt /*text-prop-functions* +text-prop-intro textprop.txt /*text-prop-intro* +text-properties textprop.txt /*text-properties* textlock eval.txt /*textlock* +textprop.txt textprop.txt /*textprop.txt* tf.vim syntax.txt /*tf.vim* this_session-variable eval.txt /*this_session-variable* throw-catch eval.txt /*throw-catch* diff --git a/runtime/doc/textprop.txt b/runtime/doc/textprop.txt --- a/runtime/doc/textprop.txt +++ b/runtime/doc/textprop.txt @@ -1,4 +1,4 @@ -*textprop.txt* For Vim version 8.1. Last change: 2018 Dec 13 +*textprop.txt* For Vim version 8.1. Last change: 2018 Dec 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -72,8 +72,8 @@ Suppose line 11 in a buffer has this tex To highlight the numbers: > call prop_type_add('number', {'highlight': 'Constant'}) - call prop_add(11, 12, {'length': 3, 'type': 'number}) - call prop_add(11, 32, {'length': 4, 'type': 'number}) + call prop_add(11, 12, {'length': 3, 'type': 'number'}) + call prop_add(11, 32, {'length': 4, 'type': 'number'}) Setting "start_incl" and "end_incl" is useful when white space surrounds the text, e.g. for a function name. Using false is useful when the text starts @@ -86,7 +86,7 @@ and/or ends with a specific character, s ^^^^^^ property with start_incl and end_incl not set Nevertheless, when text is inserted or deleted the text may need to be parsed -and the text properties updated. But this can be done asynchrnously. +and the text properties updated. But this can be done asynchronously. ============================================================================== 2. Functions *text-prop-functions* diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt --- a/runtime/doc/todo.txt +++ b/runtime/doc/todo.txt @@ -1,4 +1,4 @@ -*todo.txt* For Vim version 8.1. Last change: 2018 Dec 09 +*todo.txt* For Vim version 8.1. Last change: 2018 Dec 17 VIM REFERENCE MANUAL by Bram Moolenaar @@ -56,8 +56,6 @@ Prompt buffer: Terminal debugger: - Make prompt-buffer variant work better. -- If breakpoints are deleted with "delete" in gdb the response is not parsed - properly and the breakpoints in Vim are not removed. - Add option to not open the program window. It's not used when attaching to an already running program. (M. Kelly) - When only gdb window exists, on "quit" edit another buffer. @@ -67,7 +65,7 @@ Terminal debugger: - Add support for lldb? #3565 - Could we do something similar for debugging Vim scripts? At least see the script while stepping through it. Simple version would use an extra window. - More complete solution would actually run Vim in a Terminal an control it + More complete solution would actually run Vim in a Terminal and control it with another Vim instance. Terminal emulator window: @@ -111,9 +109,6 @@ Problem with Visual yank when 'linebreak Patch with tests, but it's not clear how it is supposed to work. (tommm, 2018 Nov 17) -Patch to add configure flags to skip rtl, farsi and arabic support. -(Diego Carrión, #1867) - Key mapping times out when using a timer in Gvim. (Michael Henry, 2018 Sep 9, #3417) @@ -121,6 +116,17 @@ Does not build with MinGW out of the box - _stat64 is not defined, need to use "struct stat" in vim.h - WINVER conflict, should use 0x0600 by default? +Signs: +- Patch to define and manipulate signs with functions. Adds sign groups and + priority. (Yegappan Lakshmanan, #3652) +- Avoid that "sign unplace id" does a redraw right away, esp. when there is + a sequence of these commands. (Andy Stewart, 2018 Mar 16) +- Patch to right-align signs. (James Kolb (email james), 2013 Sep 23) +- Patch from Christian Brabandt to make the "buffer" argument for ":sign + place" optional. (2013 Jul 12) + +Rename get_tv_ functions to tv_get_. + Crash in terminal with long multi-byte sequence. (2018 Nov 17, #3619) Dominique cannot reproduce. Update Nov 18. Suggested solution by Yasuhiro Matsumoto, 2018 Nov 18. @@ -143,10 +149,7 @@ Win32 key codes are messy. Mike William mappings no longer work. Create a new terminal for the better solution? Patch to fix that appending makes items to be "recognized". -(Yegappan, 2018 Nov 23). Reported by Daniel Hahler, #3633. - -Patch to define and manipulate signs with functions. Adds sign groups and -priority. (Yegappan Lakshmanan, #3652) +(Yegappan, 2018 Nov 23, #3683). Reported by Daniel Hahler, #3633. Improve fallback for menu translations, to avoid having to create lots of files that source the actual file. E.g. menu_da_de -> menu_da @@ -173,6 +176,21 @@ Problem with :tlmenu: Detach item added C syntax: {} inside () causes following {} to be highlighted as error. (Michalis Giannakidis, 2006 Jun 1) +Patch to fix function object in Python3. (Ozaki Kiichi, #3681) + +Patch on #3690 to fix that "wincmd p" does not always behave properly. +(Christian Brabandt, 2018 Dec 17) + +"gn" selects two matches instead of one when the pattern contains "\zs" and +spans more than one line. (#3695) + +Patch: When using %v in 'errorformat', assume the number is the screen column +not bytes, also handle multi-byte charactes. (Yegappan Lakshmanan, #3700) + +Patch to add FOR_ALL_FRAMES. (Yegappan, 2018 Dec 11, #3686) + +Patch for MinGW build with static libraries. (Ken Takata, 2018 Dec 16) + More warnings from static analysis: https://lgtm.com/projects/g/vim/vim/alerts/?mode=list @@ -184,6 +202,8 @@ 7 Make 'scrolloff' a global-local opti Patch for ConPTY support, #3474: What is the status? +nvo-mode mapping works on Windows, not on Linux. (#3678) + Pasting foo} causes Vim to behave weird. (John Little, 2018 Jun 17) Related to bracketed paste. I cannot reproduce it. @@ -194,15 +214,12 @@ Suggested patch by Hirohito Higashi, 201 Using CTRL-L to add a character to the search string that contains \v, punctiuation is repeated. (Smylers, 2018 Nov 17, #3621) +Using CTRL-L during search only picks up the base character, not a combining +character. (Rick, 2018 Dec 11, #3682) + ":mksession" cannot handle a very long 'runtimepath'. (Timothy Madden, 21 Sep 2018, #3466) Patch from Christian, 2018 Oct 30 (with comments). -Patch to add functions for signs. (Yegappan Lakshmanan, 2018 Nov 24) -obsolete: Patch to add functions for signs. (Christian Brabandt, 2013 Jan 27) - -Patch in pull request #2967: Allow white space in sign text. (Ben Jackson) -Test fails in AppVeyor. - ml_get error: (Israel Chauca Fuentes, 2018 Oct 17, #3550). Patch to convert temp file name. (Yasuhiro Matsumoto, #3520) @@ -223,8 +240,8 @@ Patch to implement 'diffref' option. (#3 Patch to fix that bracketed paste remains after Vim exits. (2018 Oct 30, #3579) -Patch for lnext/lprev work in specific cases. (Yegappan Lakshmanan, 2018 Dec -4, #3633) +Make ":interactive !cmd" stop termcap mode, also when used in an autocommand. +(#3692) cursorline highlighting not removed after yanking in Visual mode. (Matéo Zanibelli, 2018 Oct 30, #3578) @@ -342,11 +359,6 @@ Tests failing for "make testgui" with GT - Test_setbufvar_options() - Test_exit_callback_interval() -Get a "No Name" buffer when 'hidden' is set and opening a new window from the -quickfix list. (bfrg, 2018 Jan 22, #2574) -Tracked down by Jason Franklin, 2018 Oct 30. -Suggested patch by Yegappan, Nov 1. - When using CTRL-W CR in the quickfix window, the jumplist in the opened window is cleared, to avoid going back to the list of errors buffer (would have two windows with it). Can we just remove the jump list entries for the quickfix @@ -477,9 +489,6 @@ confusing error message. (Wang Shidong, Add the debug command line history to viminfo. -Avoid that "sign unplace id" does a redraw right away, esp. when there is a -sequence of these commands. (Andy Stewart, 2018 Mar 16) - Add Makefiles to the runtime/spell directory tree, since nobody uses Aap. Will have to explain the manual steps (downloading the .aff and .dic files, applying the diff, etc. @@ -1560,8 +1569,6 @@ possible. (Christian Brabandt, 2014 Mar Updated spec ftplugin. (Matěj Cepl, 2013 Oct 16) -Patch to right-align signs. (James Kolb (email james), 2013 Sep 23) - Patch to handle integer overflow. (Aaron Burrow, 2013 Dec 12) Patch to add "ntab" item in 'listchars' to repeat first character. (Nathaniel @@ -1629,9 +1636,6 @@ Two highlighting bugs. (ZyX, 2013 Aug 18 Patch to support 'u' in interactive substitute. (Christian Brabandt, 2012 Sep 28) With tests: Oct 9. -Patch from Christian Brabandt to make the "buffer" argument for ":sign place" -optional. (2013 Jul 12) - Dialog is too big on Linux too. (David Fishburn, 2013 Sep 2) Patch to make fold updates much faster. (Christian Brabandt, 2012 Dec) @@ -5817,7 +5821,6 @@ 8 Add breakpoints for assigning to a v 7 Store the history from debug mode in viminfo. 7 Make the debug mode history available with histget() et al. - Various improvements: 7 Add plugins for formatting? Should be able to make a choice depending on the language of a file (English/Korean/Japanese/etc.). diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -1,4 +1,4 @@ -*usr_41.txt* For Vim version 8.1. Last change: 2018 Apr 11 +*usr_41.txt* For Vim version 8.1. Last change: 2018 Dec 18 VIM USER MANUAL - by Bram Moolenaar @@ -1059,7 +1059,7 @@ Various: *various-functions* py3eval() evaluate Python expression (|+python3|) pyeval() evaluate Python expression (|+python|) pyxeval() evaluate |python_x| expression - debugbreak() interrupt a program being debugged + debugbreak() interrupt a program being debugged ============================================================================== *41.7* Defining a function diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -1,4 +1,4 @@ -*various.txt* For Vim version 8.1. Last change: 2018 Mar 29 +*various.txt* For Vim version 8.1. Last change: 2018 Dec 13 VIM REFERENCE MANUAL by Bram Moolenaar @@ -448,6 +448,7 @@ m *+terminal* Support for terminal win N *+termresponse* support for |t_RV| and |v:termresponse| B *+termguicolors* 24-bit color in xterm-compatible terminals support N *+textobjects* |text-objects| selection +N *+textprop* |text-properties| *+tgetent* non-Unix only: able to use external termcap N *+timers* the |timer_start()| function N *+title* Setting the window 'title' and 'icon' diff --git a/runtime/indent/falcon.vim b/runtime/indent/falcon.vim --- a/runtime/indent/falcon.vim +++ b/runtime/indent/falcon.vim @@ -368,7 +368,7 @@ function FalconGetIndent(...) return indent('.') endif else - call cursor(clnum, vcol) + call cursor(clnum, 0) " FIXME: column was vcol end endif diff --git a/runtime/indent/matlab.vim b/runtime/indent/matlab.vim --- a/runtime/indent/matlab.vim +++ b/runtime/indent/matlab.vim @@ -1,74 +1,121 @@ -" Matlab indent file -" Language: Matlab -" Maintainer: Christophe Poucet -" Last Change: 6 January, 2001 +" Vim indent file +" Language: MATLAB +" Maintainer: Axel Forsman +" Previous maintainer: Christophe Poucet -" Only load this indent file when no other was loaded. -if exists("b:did_indent") - finish -endif +" Only load if no other indent file is loaded +if exists('b:did_indent') | finish | endif let b:did_indent = 1 -" Some preliminary setting -setlocal indentkeys=!,o,O=end,=case,=else,=elseif,=otherwise,=catch - - -setlocal indentexpr=GetMatlabIndent(v:lnum) - -" Only define the function once. -if exists("*GetMatlabIndent") - finish -endif +setlocal indentexpr=GetMatlabIndent() +setlocal indentkeys=!,o,O,e,0=end,0=elseif,0=case,0=otherwise,0=catch,0=function,0=elsei -function GetMatlabIndent(lnum) - " Give up if this line is explicitly joined. - if getline(a:lnum - 1) =~ '\\$' - return -1 - endif +" The value of the Function indenting format in +" MATLAB Editor/Debugger Language Preferences. +" The possible values are 0 for Classic, 1 for Indent nested functions +" and 2 for Indent all functions (default). +let b:MATLAB_function_indent = get(g:, 'MATLAB_function_indent', 2) +" The previous value of b:changedtick +let b:MATLAB_lasttick = -1 +" The previously indented line +let b:MATLAB_lastline = -1 +" Whether the line above was a line continuation +let b:MATLAB_waslc = 0 +let b:MATLAB_bracketlevel = 0 - " Search backwards for the first non-empty line. - let plnum = a:lnum - 1 - while plnum > 0 && getline(plnum) =~ '^\s*$' - let plnum = plnum - 1 - endwhile +" Only define the function once +if exists("*GetMatlabIndent") | finish | endif - if plnum == 0 - " This is the first non-empty line, use zero indent. - return 0 - endif - - let curind = indent(plnum) +let s:keepcpo = &cpo +set cpo&vim - " If the current line is a stop-block statement... - if getline(v:lnum) =~ '^\s*\(end\|else\|elseif\|case\|otherwise\|catch\)\>' - " See if this line does not follow the line right after an openblock - if getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>' - " See if the user has already dedented - elseif indent(v:lnum) > curind - shiftwidth() - " If not, recommend one dedent - let curind = curind - shiftwidth() - else - " Otherwise, trust the user - return -1 - endif -" endif +let s:end = '\\%([^(]*)\)\@!' " Array indexing heuristic +let s:open_pat = 'for\|if\|parfor\|spmd\|switch\|try\|while\|classdef\|properties\|methods\|events\|enumeration' +let s:dedent_pat = '\C^\s*\zs\<\%(end\|else\|elseif\|catch\|\(case\|otherwise\|function\)\)\>' +let s:start_pat = '\C\<\%(function\|' . s:open_pat . '\)\>' +let s:bracket_pair_pat = '\(\[\|{\)\|\(\]\|}\)' +let s:zflag = has('patch-7.4.984') ? 'z' : '' + +" Returns whether a comment or string envelops the specified column. +function! s:IsCommentOrString(lnum, col) + return synIDattr(synID(a:lnum, a:col, 1), "name") =~# 'matlabComment\|matlabMultilineComment\|matlabString' +endfunction - " If the previous line opened a block - elseif getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>' - " See if the user has already indented - if indent(v:lnum) < curind + shiftwidth() - "If not, recommend indent - let curind = curind + shiftwidth() - else - " Otherwise, trust the user - return -1 - endif - endif +" Returns whether the specified line continues on the next line. +function! s:IsLineContinuation(lnum) + let l = getline(a:lnum) | let c = -3 + while 1 + let c = match(l, '\.\{3}', c + 3) + if c == -1 | return 0 + elseif !s:IsCommentOrString(a:lnum, c) | return 1 | endif + endwhile +endfunction - - - " If we got to here, it means that the user takes the standardversion, so we return it - return curind +function! s:SubmatchCount(lnum, pattern, ...) + let endcol = a:0 >= 1 ? a:1 : 1 / 0 | let x = [0, 0, 0, 0] + call cursor(a:lnum, 1) + while 1 + let [lnum, c, submatch] = searchpos(a:pattern, 'cpe' . s:zflag, a:lnum) + if !submatch || c >= endcol | break | endif + if !s:IsCommentOrString(lnum, c) | let x[submatch - 2] += 1 | endif + if cursor(0, c + 1) == -1 || col('.') == c | break | endif + endwhile + return x endfunction -" vim:sw=2 +function! s:GetOpenCloseCount(lnum, pattern, ...) + let counts = call('s:SubmatchCount', [a:lnum, a:pattern] + a:000) + return counts[0] - counts[1] +endfunction + +function! GetMatlabIndent() + let prevlnum = prevnonblank(v:lnum - 1) + + if b:MATLAB_lasttick != b:changedtick || b:MATLAB_lastline != prevlnum + " Recalculate bracket count (only have to check same block and line above) + let b:MATLAB_bracketlevel = 0 + let previndent = indent(prevlnum) | let l = prevlnum + while 1 + let l = prevnonblank(l - 1) | let indent = indent(l) + if l <= 0 || previndent < indent | break | endif + let b:MATLAB_bracketlevel += s:GetOpenCloseCount(l, s:bracket_pair_pat) + if previndent != indent | break | endif + endwhile + + let b:MATLAB_waslc = s:IsLineContinuation(prevlnum - 1) + endif + " If line above was blank it can impossibly have been a LC + let above_lc = b:MATLAB_lasttick == b:changedtick && prevlnum != v:lnum - 1 && b:MATLAB_lastline == prevlnum ? 0 : s:IsLineContinuation(v:lnum - 1) + + let pair_pat = '\C\<\(' . s:open_pat . '\|' + \ . (b:MATLAB_function_indent == 1 ? '^\@= 1 ? 'function\|' : '') + \ . '\|\%(^\s*\)\@<=\%(else\|elseif\|case\|otherwise\|catch\)\)\>' + \ . '\|\S\s*\zs\(' . s:end . '\)' + let [open, close, b_open, b_close] = prevlnum ? s:SubmatchCount(prevlnum, + \ pair_pat . '\|' . s:bracket_pair_pat) : [0, 0, 0, 0] + let curbracketlevel = b:MATLAB_bracketlevel + b_open - b_close + + call cursor(v:lnum, 1) + let submatch = search(s:dedent_pat, 'cp' . s:zflag, v:lnum) + if submatch && !s:IsCommentOrString(v:lnum, col('.')) + " Align end, et cetera with start of block + let [lnum, col] = searchpairpos(s:start_pat, '', '\C' . s:end, 'bW', 's:IsCommentOrString(line("."), col("."))') + let result = lnum ? indent(lnum) + shiftwidth() * (s:GetOpenCloseCount(lnum, pair_pat, col) + submatch == 2) : 0 + else + " Count how many blocks the previous line opens/closes + " Line continuations/brackets indent once per statement + let result = indent(prevlnum) + shiftwidth() * (open - close + \ + (b:MATLAB_bracketlevel ? -!curbracketlevel : !!curbracketlevel) + \ + (curbracketlevel <= 0) * (above_lc - b:MATLAB_waslc)) + endif + + let b:MATLAB_waslc = above_lc + let b:MATLAB_bracketlevel = curbracketlevel + let b:MATLAB_lasttick = b:changedtick + let b:MATLAB_lastline = v:lnum + return result +endfunction + +let &cpo = s:keepcpo +unlet s:keepcpo diff --git a/runtime/indent/testdir/matlab.in b/runtime/indent/testdir/matlab.in --- a/runtime/indent/testdir/matlab.in +++ b/runtime/indent/testdir/matlab.in @@ -15,3 +15,66 @@ catch exception statements end % END_INDENT + +% START_INDENT +if true, ... +if true +disp hello +end +end +% END_INDENT + +% START_INDENT +switch a +case expr +if true, foo; end +disp hello +otherwise +disp bar +end +% END_INDENT + +% START_INDENT +if true +A(1:end - 1) +disp foo +end +% END_INDENT + +% START_INDENT +A = [{ +} +] ... +disp foo +disp bar +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 0 +function foo +disp foo +function nested +disp bar +end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 1 +function foo +disp foo +function nested +disp bar +end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 2 +function foo +disp foo +function nested +disp bar +end +end +% END_INDENT diff --git a/runtime/indent/testdir/matlab.ok b/runtime/indent/testdir/matlab.ok --- a/runtime/indent/testdir/matlab.ok +++ b/runtime/indent/testdir/matlab.ok @@ -15,3 +15,66 @@ catch exception statements end % END_INDENT + +% START_INDENT +if true, ... + if true + disp hello + end +end +% END_INDENT + +% START_INDENT +switch a + case expr + if true, foo; end + disp hello + otherwise + disp bar +end +% END_INDENT + +% START_INDENT +if true + A(1:end - 1) + disp foo +end +% END_INDENT + +% START_INDENT +A = [{ + } + ] ... + disp foo +disp bar +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 0 +function foo +disp foo + function nested + disp bar + end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 1 +function foo +disp foo + function nested + disp bar + end +end +% END_INDENT + +% START_INDENT +% INDENT_EXE let b:MATLAB_function_indent = 2 +function foo + disp foo + function nested + disp bar + end +end +% END_INDENT diff --git a/runtime/indent/testdir/runtest.vim b/runtime/indent/testdir/runtest.vim --- a/runtime/indent/testdir/runtest.vim +++ b/runtime/indent/testdir/runtest.vim @@ -8,6 +8,7 @@ if 1 set nocp filetype indent on set nowrapscan +set report=9999 au! SwapExists * call HandleSwapExists() func HandleSwapExists() diff --git a/runtime/indent/testdir/tcl.in b/runtime/indent/testdir/tcl.in --- a/runtime/indent/testdir/tcl.in +++ b/runtime/indent/testdir/tcl.in @@ -1,4 +1,4 @@ -# vim: set filetype=tcl shiftwidth=4 tabstop=4: +# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab : # START_INDENT proc abc {} { diff --git a/runtime/indent/testdir/tcl.ok b/runtime/indent/testdir/tcl.ok --- a/runtime/indent/testdir/tcl.ok +++ b/runtime/indent/testdir/tcl.ok @@ -1,19 +1,19 @@ -# vim: set filetype=tcl shiftwidth=4 tabstop=4: +# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab : # START_INDENT proc abc {} { - set a 5 - if {[some_cmd]==1} { - foreach i [list {1 2 3}] { - # Does this comment affect anything? - puts $i - } - } + set a 5 + if {[some_cmd]==1} { + foreach i [list {1 2 3}] { + # Does this comment affect anything? + puts $i + } + } } command_with_a_long_time -arg1 "First" \ - -arg2 "Second" \ - -arg3 "Third" + -arg2 "Second" \ + -arg3 "Third" puts "Move indent back after line continuation is complete" # END_INDENT diff --git a/runtime/indent/testdir/xml.in b/runtime/indent/testdir/xml.in --- a/runtime/indent/testdir/xml.in +++ b/runtime/indent/testdir/xml.in @@ -1,4 +1,4 @@ - + diff --git a/runtime/indent/testdir/xml.ok b/runtime/indent/testdir/xml.ok --- a/runtime/indent/testdir/xml.ok +++ b/runtime/indent/testdir/xml.ok @@ -1,32 +1,32 @@ - + - - - - - - + + + + + + - - - + + + - - - - - - + + + + + + diff --git a/runtime/indent/xml.vim b/runtime/indent/xml.vim --- a/runtime/indent/xml.vim +++ b/runtime/indent/xml.vim @@ -1,15 +1,21 @@ -" Language: xml -" Repository: https://github.com/chrisbra/vim-xml-ftplugin -" Maintainer: Christian Brabandt -" Previous Maintainer: Johannes Zellner -" Last Change: 20181022 - Do not overwrite indentkeys setting -" https://github.com/chrisbra/vim-xml-ftplugin/issues/1 -" 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200 -" Notes: 1) does not indent pure non-xml code (e.g. embedded scripts) -" 2) will be confused by unbalanced tags in comments -" or CDATA sections. -" 2009-05-26 patch by Nikolai Weibull -" TODO: implement pre-like tags, see xml_indent_open / xml_indent_close +" Language: xml +" Repository: https://github.com/chrisbra/vim-xml-ftplugin +" Last Changed: Dec 07th, 2018 +" Maintainer: Christian Brabandt +" Previous Maintainer: Johannes Zellner +" Last Change: +" 20181116 - Fix indentation when tags start with a colon or an underscore +" https://github.com/vim/vim/pull/926 +" 20181022 - Do not overwrite indentkeys setting +" https://github.com/chrisbra/vim-xml-ftplugin/issues/1 +" 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200 +" +" Notes: +" 1) does not indent pure non-xml code (e.g. embedded scripts) +" 2) will be confused by unbalanced tags in comments +" or CDATA sections. +" 2009-05-26 patch by Nikolai Weibull +" TODO: implement pre-like tags, see xml_indent_open / xml_indent_close " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -20,11 +26,12 @@ let s:keepcpo= &cpo set cpo&vim " [-- local settings (must come before aborting the script) --] +" Attention: Parameter use_syntax_check is used by the docbk.vim indent script setlocal indentexpr=XmlIndentGet(v:lnum,1) setlocal indentkeys=o,O,*,<>>,<<>,/,{,},!^F if !exists('b:xml_indent_open') - let b:xml_indent_open = '.\{-}<\a' + let b:xml_indent_open = '.\{-}<[:A-Z_a-z]' " pre tag, e.g.
" let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!' endif @@ -40,7 +47,7 @@ unlet s:keepcpo " [-- finish, if the function already exists --] if exists('*XmlIndentGet') - finish + finish endif let s:keepcpo= &cpo @@ -53,13 +60,13 @@ endfun " [-- check if it's xml --] fun! XmlIndentSynCheck(lnum) - if '' != &syntax - let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name') - let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name') - if '' != syn1 && syn1 !~ 'xml' && '' != syn2 && syn2 !~ 'xml' - " don't indent pure non-xml code - return 0 - endif + if &syntax != '' + let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name') + let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name') + if syn1 != '' && syn1 !~ 'xml' && syn2 != '' && syn2 !~ 'xml' + " don't indent pure non-xml code + return 0 + endif endif return 1 endfun @@ -68,41 +75,72 @@ endfun fun! XmlIndentSum(lnum, style, add) let line = getline(a:lnum) if a:style == match(line, '^\s*XmlIndentWithPattern(line, b:xml_indent_open) - \ - XmlIndentWithPattern(line, b:xml_indent_close) - \ - XmlIndentWithPattern(line, '.\{-}/>'))) + a:add + return (shiftwidth() * + \ (XmlIndentWithPattern(line, b:xml_indent_open) + \ - XmlIndentWithPattern(line, b:xml_indent_close) + \ - XmlIndentWithPattern(line, '.\{-}/>'))) + a:add else - return a:add + return a:add endif endfun +" Main indent function fun! XmlIndentGet(lnum, use_syntax_check) " Find a non-empty line above the current line. - let lnum = prevnonblank(a:lnum - 1) + let plnum = prevnonblank(a:lnum - 1) + " Find previous line with a tag (regardless whether open or closed) + let ptag = search('.\{-}<[/:A-Z_a-z]', 'bnw') " Hit the start of the file, use zero indent. - if lnum == 0 - return 0 + if plnum == 0 + return 0 endif + let syn_name = '' if a:use_syntax_check - let check_lnum = XmlIndentSynCheck(lnum) - let check_alnum = XmlIndentSynCheck(a:lnum) - if 0 == check_lnum || 0 == check_alnum - return indent(a:lnum) - elseif -1 == check_lnum || -1 == check_alnum - return -1 - endif + let check_lnum = XmlIndentSynCheck(plnum) + let check_alnum = XmlIndentSynCheck(a:lnum) + if check_lnum == 0 || check_alnum == 0 + return indent(a:lnum) + endif + let syn_name = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name') + endif + + if syn_name =~ 'Comment' + return XmlIndentComment(a:lnum) endif - let ind = XmlIndentSum(lnum, -1, indent(lnum)) + " Get indent from previous tag line + let ind = XmlIndentSum(ptag, -1, indent(ptag)) + " Determine indent from current line let ind = XmlIndentSum(a:lnum, 0, ind) - return ind endfun +" return indent for a commented line, +" the middle part might be indented on additional level +func! XmlIndentComment(lnum) + let ptagopen = search(b:xml_indent_open, 'bnw') + let ptagclose = search(b:xml_indent_close, 'bnw') + if getline(a:lnum) =~ '' + " end of comment, same as start of comment + return indent(search('