diff --git a/runtime/autoload/bitbake.vim b/runtime/autoload/bitbake.vim new file mode 100644 index 0000000000..bb3fc5c0e2 --- /dev/null +++ b/runtime/autoload/bitbake.vim @@ -0,0 +1,95 @@ +" Support for bitbake indenting, see runtime/indent/bitbake.vim + +function s:is_bb_python_func_def(lnum) + let stack = synstack(a:lnum, 1) + if len(stack) == 0 + return 0 + endif + + return synIDattr(stack[0], "name") == "bbPyFuncDef" +endfunction + +function bitbake#Indent(lnum) + if !has('syntax_items') + return -1 + endif + + let stack = synstack(a:lnum, 1) + if len(stack) == 0 + return -1 + endif + + let name = synIDattr(stack[0], "name") + + " TODO: support different styles of indentation for assignments. For now, + " we only support like this: + " VAR = " \ + " value1 \ + " value2 \ + " " + " + " i.e. each value indented by shiftwidth(), with the final quote " completely unindented. + if name == "bbVarValue" + " Quote handling is tricky. kernel.bbclass has this line for instance: + " EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" " HOSTCPP="${BUILD_CPP}"" + " Instead of trying to handle crazy cases like that, just assume that a + " double-quote on a line by itself (following an assignment) means the + " user is closing the assignment, and de-dent. + if getline(a:lnum) =~ '^\s*"$' + return 0 + endif + + let prevstack = synstack(a:lnum - 1, 1) + if len(prevstack) == 0 + return -1 + endif + + let prevname = synIDattr(prevstack[0], "name") + + " Only indent if there was actually a continuation character on + " the previous line, to avoid misleading indentation. + let prevlinelastchar = synIDattr(synID(a:lnum - 1, col([a:lnum - 1, "$"]) - 1, 1), "name") + let prev_continued = prevlinelastchar == "bbContinue" + + " Did the previous line introduce an assignment? + if index(["bbVarDef", "bbVarFlagDef"], prevname) != -1 + if prev_continued + return shiftwidth() + endif + endif + + if !prev_continued + return 0 + endif + + " Autoindent can take it from here + return -1 + endif + + if index(["bbPyDefRegion", "bbPyFuncRegion"], name) != -1 + let ret = python#GetIndent(a:lnum, function('s:is_bb_python_func_def')) + " Should normally always be indented by at least one shiftwidth; but allow + " return of -1 (defer to autoindent) or -2 (force indent to 0) + if ret == 0 + return shiftwidth() + elseif ret == -2 + return 0 + endif + return ret + endif + + " TODO: GetShIndent doesn't detect tasks prepended with 'fakeroot' + " Need to submit a patch upstream to Vim to provide an extension point. + " Unlike the Python indenter, the Sh indenter is way too large to copy and + " modify here. + if name == "bbShFuncRegion" + return GetShIndent() + endif + + " TODO: + " + heuristics for de-denting out of a bbPyDefRegion? e.g. when the user + " types an obvious BB keyword like addhandler or addtask, or starts + " writing a shell task. Maybe too hard to implement... + + return -1 +endfunction diff --git a/runtime/autoload/python.vim b/runtime/autoload/python.vim new file mode 100644 index 0000000000..7e7bca6fb6 --- /dev/null +++ b/runtime/autoload/python.vim @@ -0,0 +1,228 @@ +" Support for Python indenting, see runtime/indent/python.vim + +let s:keepcpo= &cpo +set cpo&vim + +" See if the specified line is already user-dedented from the expected value. +function s:Dedented(lnum, expected) + return indent(a:lnum) <= a:expected - shiftwidth() +endfunction + +let s:maxoff = 50 " maximum number of lines to look backwards for () + +" Some other filetypes which embed Python have slightly different indent +" rules (e.g. bitbake). Those filetypes can pass an extra funcref to this +" function which is evaluated below. +function python#GetIndent(lnum, ...) + let ExtraFunc = a:0 > 0 ? a:1 : 0 + + " If this line is explicitly joined: If the previous line was also joined, + " line it up with that one, otherwise add two 'shiftwidth' + if getline(a:lnum - 1) =~ '\\$' + if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$' + return indent(a:lnum - 1) + endif + return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:pyindent_continue) : (shiftwidth() * 2)) + endif + + " If the start of the line is in a string don't change the indent. + if has('syntax_items') + \ && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$" + return -1 + endif + + " Search backwards for the previous non-empty line. + let plnum = prevnonblank(v:lnum - 1) + + if plnum == 0 + " This is the first non-empty line, use zero indent. + return 0 + endif + + call cursor(plnum, 1) + + " Identing inside parentheses can be very slow, regardless of the searchpair() + " timeout, so let the user disable this feature if he doesn't need it + let disable_parentheses_indenting = get(g:, "pyindent_disable_parentheses_indenting", 0) + + if disable_parentheses_indenting == 1 + let plindent = indent(plnum) + let plnumstart = plnum + else + " searchpair() can be slow sometimes, limit the time to 150 msec or what is + " put in g:pyindent_searchpair_timeout + let searchpair_stopline = 0 + let searchpair_timeout = get(g:, 'pyindent_searchpair_timeout', 150) + + " If the previous line is inside parenthesis, use the indent of the starting + " line. + " Trick: use the non-existing "dummy" variable to break out of the loop when + " going too far back. + let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW', + \ "line('.') < " . (plnum - s:maxoff) . " ? dummy :" + \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" + \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", + \ searchpair_stopline, searchpair_timeout) + if parlnum > 0 + if a:0 > 0 && ExtraFunc(parlnum) + " We may have found the opening brace of a bitbake Python task, e.g. 'python do_task {' + " If so, ignore it here - it will be handled later. + let parlnum = 0 + let plindent = indent(plnum) + let plnumstart = plnum + else + let plindent = indent(parlnum) + let plnumstart = parlnum + endif + else + let plindent = indent(plnum) + let plnumstart = plnum + endif + + " When inside parenthesis: If at the first line below the parenthesis add + " two 'shiftwidth', otherwise same as previous line. + " i = (a + " + b + " + c) + call cursor(a:lnum, 1) + let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW', + \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" + \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" + \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", + \ searchpair_stopline, searchpair_timeout) + if p > 0 + if a:0 > 0 && ExtraFunc(p) + " Currently only used by bitbake + " Handle first non-empty line inside a bitbake Python task + if p == plnum + return shiftwidth() + endif + + " Handle the user actually trying to close a bitbake Python task + let line = getline(a:lnum) + if line =~ '^\s*}' + return -2 + endif + + " Otherwise ignore the brace + let p = 0 + else + if p == plnum + " When the start is inside parenthesis, only indent one 'shiftwidth'. + let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW', + \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" + \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" + \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", + \ searchpair_stopline, searchpair_timeout) + if pp > 0 + return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth()) + endif + return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (shiftwidth() * 2)) + endif + if plnumstart == p + return indent(plnum) + endif + return plindent + endif + endif + endif + + + " Get the line and remove a trailing comment. + " Use syntax highlighting attributes when possible. + let pline = getline(plnum) + let pline_len = strlen(pline) + if has('syntax_items') + " If the last character in the line is a comment, do a binary search for + " the start of the comment. synID() is slow, a linear search would take + " too long on a long line. + if synIDattr(synID(plnum, pline_len, 1), "name") =~ "\\(Comment\\|Todo\\)$" + let min = 1 + let max = pline_len + while min < max + let col = (min + max) / 2 + if synIDattr(synID(plnum, col, 1), "name") =~ "\\(Comment\\|Todo\\)$" + let max = col + else + let min = col + 1 + endif + endwhile + let pline = strpart(pline, 0, min - 1) + endif + else + let col = 0 + while col < pline_len + if pline[col] == '#' + let pline = strpart(pline, 0, col) + break + endif + let col = col + 1 + endwhile + endif + + " If the previous line ended with a colon, indent this line + if pline =~ ':\s*$' + return plindent + shiftwidth() + endif + + " If the previous line was a stop-execution statement... + if getline(plnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>' + " See if the user has already dedented + if s:Dedented(a:lnum, indent(plnum)) + " If so, trust the user + return -1 + endif + " If not, recommend one dedent + return indent(plnum) - shiftwidth() + endif + + " If the current line begins with a keyword that lines up with "try" + if getline(a:lnum) =~ '^\s*\(except\|finally\)\>' + let lnum = a:lnum - 1 + while lnum >= 1 + if getline(lnum) =~ '^\s*\(try\|except\)\>' + let ind = indent(lnum) + if ind >= indent(a:lnum) + return -1 " indent is already less than this + endif + return ind " line up with previous try or except + endif + let lnum = lnum - 1 + endwhile + return -1 " no matching "try"! + endif + + " If the current line begins with a header keyword, dedent + if getline(a:lnum) =~ '^\s*\(elif\|else\)\>' + + " Unless the previous line was a one-liner + if getline(plnumstart) =~ '^\s*\(for\|if\|elif\|try\)\>' + return plindent + endif + + " Or the user has already dedented + if s:Dedented(a:lnum, plindent) + return -1 + endif + + return plindent - shiftwidth() + endif + + " When after a () construct we probably want to go back to the start line. + " a = (b + " + c) + " here + if parlnum > 0 + " ...unless the user has already dedented + if s:Dedented(a:lnum, plindent) + return -1 + else + return plindent + endif + endif + + return -1 +endfunction + +let &cpo = s:keepcpo +unlet s:keepcpo diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index df5a636070..668c738e0a 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1885,7 +1885,9 @@ exists({expr}) The result is a Number, which is |TRUE| if {expr} is To check for a supported command always check the return value to be 2. :2match The |:2match| command. - :3match The |:3match| command. + :3match The |:3match| command (but you + probably should not use it, it is + reserved for internal usage) #event autocommand defined for this event #event#pattern autocommand defined for this event and pattern (the pattern is taken @@ -4905,8 +4907,10 @@ matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]]) message will appear and the match will not be added. An ID is specified as a positive integer (zero excluded). IDs 1, 2 and 3 are reserved for |:match|, |:2match| and |:3match|, - respectively. If the {id} argument is not specified or -1, - |matchadd()| automatically chooses a free ID. + respectively. 3 is reserved for use by the + |matchparen| plugin. + If the {id} argument is not specified or -1, |matchadd()| + automatically chooses a free ID. The optional {dict} argument allows for further custom values. Currently this is used to specify a match specific @@ -6397,7 +6401,7 @@ searchcount([{options}]) *searchcount()* " to 1) let result = searchcount() < - The function is useful to add the count to |statusline|: > + The function is useful to add the count to 'statusline': > function! LastSearchCount() abort let result = searchcount(#{recompute: 0}) if empty(result) diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt index 6972fe0768..335faf266e 100644 --- a/runtime/doc/ft_sql.txt +++ b/runtime/doc/ft_sql.txt @@ -502,7 +502,7 @@ documentation. Assuming you have followed the dbext-tutorial you can press t to display a list of tables. There is a delay while dbext is creating the table list. After the list is displayed press . This will remove both the -popup window and the table name already chosen when the list became active. > +popup window and the table name already chosen when the list became active. 4.3.1 Table Completion: *sql-completion-tables* @@ -510,7 +510,7 @@ Press t to display a list of tables from within the database you have connected via the dbext plugin. NOTE: All of the SQL completion popups support typing a prefix before pressing the key map. This will limit the contents of the popup window to just items -beginning with those characters. > +beginning with those characters. 4.3.2 Column Completion: *sql-completion-columns* @@ -583,13 +583,13 @@ popup a list of columns for the customer table. It does this by looking back to the beginning of the select statement and finding a list of the tables specified in the FROM clause. In this case it notes that in the string "customer c", "c" is an alias for the customer table. The optional "AS" -keyword is also supported, "customer AS c". > +keyword is also supported, "customer AS c". 4.3.3 Procedure Completion: *sql-completion-procedures* Similar to the table list, p, will display a list of stored -procedures stored within the database. > +procedures stored within the database. 4.3.4 View Completion: *sql-completion-views* diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index 27f1fed751..6b0899334b 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -374,10 +374,10 @@ CTRL-G CTRL-J cursor one line down, insert start column *i_CTRL-G_CTRL-J* move window one page right *i_* CTRL-O execute one command, return to Insert mode *i_CTRL-O* CTRL-\ CTRL-O like CTRL-O but don't move the cursor *i_CTRL-\_CTRL-O* -CTRL-G u break undo sequence, start new change *i_CTRL-G_u* -CTRL-G U don't break undo with next left/right cursor *i_CTRL-G_U* - movement, if the cursor stays within the - same the line +CTRL-G u close undo sequence, start new change *i_CTRL-G_u* +CTRL-G U don't start a new undo block with the next *i_CTRL-G_U* + left/right cursor movement, if the cursor + stays within the same line ----------------------------------------------------------------------- The CTRL-O command sometimes has a side effect: If the cursor was beyond the @@ -411,8 +411,8 @@ that, with CTRL-O u. Another example: > :inoremap u -This breaks undo at each line break. It also expands abbreviations before -this. +This starts a new undo block at each line break. It also expands +abbreviations before this. An example for using CTRL-G U: > @@ -426,9 +426,9 @@ An example for using CTRL-G U: > inoremap repeat('U', col('$') - col('.')) inoremap ( ()U -This makes it possible to use the cursor keys in Insert mode, without breaking -the undo sequence and therefore using |.| (redo) will work as expected. -Also entering a text like (with the "(" mapping from above): +This makes it possible to use the cursor keys in Insert mode, without starting +a new undo block and therefore using |.| (redo) will work as expected. Also +entering a text like (with the "(" mapping from above): Lorem ipsum (dolor diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 7e94167e07..1e1f4e46af 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -610,19 +610,20 @@ two bytes 0xc3 0xa1. You don't want the 0xc3 byte to be mapped then or otherwise it would be impossible to type the รก character. ** *mapleader* -To define a mapping which uses the "mapleader" variable, the special string -"" can be used. It is replaced with the string value of "mapleader". -If "mapleader" is not set or empty, a backslash is used instead. Example: > - :map A oanother line +To define a mapping which uses the "g:mapleader" variable, the special string +"" can be used. It is replaced with the string value of +"g:mapleader". If "g:mapleader" is not set or empty, a backslash is used +instead. Example: > + map A oanother line Works like: > - :map \A oanother line -But after: > - :let mapleader = "," + map \A oanother line +But after: + let mapleader = "," It works like: > - :map ,A oanother line + map ,A oanother line -Note that the value of "mapleader" is used at the moment the mapping is -defined. Changing "mapleader" after that has no effect for already defined +Note that the value of "g:mapleader" is used at the moment the mapping is +defined. Changing "g:mapleader" after that has no effect for already defined mappings. ** *maplocalleader* diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 0f1c2051a6..68723e4889 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3571,7 +3571,7 @@ A jump table for the options with a short description can be found at |Q_op|. help. (Note that previously setting the global option to the empty value did this, which is now deprecated.) When the first character is ":", the command is invoked as a Vim - command prefixed with [count]. + Ex command with [count] added as an argument if it is not zero. When "man" or "man -s" is used, Vim will automatically translate a [count] for the "K" command to a section number. See |option-backslash| about including spaces and backslashes. diff --git a/runtime/doc/pi_netrw.txt b/runtime/doc/pi_netrw.txt index 6f7b53722c..1eaa76264f 100644 --- a/runtime/doc/pi_netrw.txt +++ b/runtime/doc/pi_netrw.txt @@ -3917,7 +3917,7 @@ netrw: * Installed |g:netrw_clipboard| setting * Installed option bypass for |'guioptions'| a/A settings - * Changed popup_beval() to |popup_atcursor|() + * Changed popup_beval() to |popup_atcursor()| in netrw#ErrorMsg (lacygoill). Apparently popup_beval doesn't reliably close the popup when the mouse is moved. diff --git a/runtime/doc/undo.txt b/runtime/doc/undo.txt index 67f24103cd..98ab60c7e7 100644 --- a/runtime/doc/undo.txt +++ b/runtime/doc/undo.txt @@ -108,13 +108,13 @@ change again. But you can do something like this: > After this a "u" command will undo the delete command and the previous change. - *undo-break* -To do the opposite, break a change into two undo blocks, in Insert mode use -CTRL-G u. This is useful if you want an insert command to be undoable in + *undo-break* *undo-close-block* +To do the opposite, use a new undo block for the next change, in Insert mode +use CTRL-G u. This is useful if you want an insert command to be undoable in parts. E.g., for each sentence. |i_CTRL-G_u| -Setting the value of 'undolevels' also breaks undo. Even when the new value -is equal to the old value: > +Setting the value of 'undolevels' also closes the undo block. Even when the +new value is equal to the old value: > let &undolevels = &undolevels ============================================================================== diff --git a/runtime/ftplugin/bitbake.vim b/runtime/ftplugin/bitbake.vim new file mode 100644 index 0000000000..99fe334627 --- /dev/null +++ b/runtime/ftplugin/bitbake.vim @@ -0,0 +1,16 @@ +" Vim filetype plugin file +" Language: Bitbake +" Maintainer: Gregory Anders +" Repository: https://github.com/openembedded/bitbake +" Latest Revision: 2022-07-23 + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal commentstring=#%s +setlocal comments=:# +setlocal suffixesadd=.bb,.bbclass + +let b:undo_ftplugin = "setl cms< com< sua<" diff --git a/runtime/ftplugin/expect.vim b/runtime/ftplugin/expect.vim new file mode 100644 index 0000000000..a4c6af96ce --- /dev/null +++ b/runtime/ftplugin/expect.vim @@ -0,0 +1,24 @@ +" Vim filetype plugin file +" Language: Expect +" Maintainer: Doug Kearns +" Last Change: 2022 Jul 16 + +if exists("b:did_ftplugin") + finish +endif + +" Syntax is similar to Tcl +runtime! ftplugin/tcl.vim + +let s:cpo_save = &cpo +set cpo&vim + +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "Expect Command Files (*.exp)\t*.exp\n" .. + \ "All Files (*.*)\t*.*\n" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8 diff --git a/runtime/ftplugin/html.vim b/runtime/ftplugin/html.vim index 3179aa2e88..94cb62653f 100644 --- a/runtime/ftplugin/html.vim +++ b/runtime/ftplugin/html.vim @@ -1,16 +1,14 @@ " Vim filetype plugin file -" Language: html -" -" This runtime file is looking for a new maintainer. -" -" Former maintainer: Dan Sharp -" Last Changed: 20 Jan 2009 +" Language: HTML +" Maintainer: Doug Kearns +" Previous Maintainer: Dan Sharp +" Last Changed: 2022 Jul 20 -if exists("b:did_ftplugin") | finish | endif +if exists("b:did_ftplugin") + finish +endif let b:did_ftplugin = 1 -" Make sure the continuation lines below do not cause problems in -" compatibility mode. let s:save_cpo = &cpo set cpo-=C @@ -18,36 +16,40 @@ setlocal matchpairs+=<:> setlocal commentstring= setlocal comments=s: -if exists("g:ft_html_autocomment") && (g:ft_html_autocomment == 1) - setlocal formatoptions-=t formatoptions+=croql +let b:undo_ftplugin = "setlocal comments< commentstring< matchpairs<" + +if get(g:, "ft_html_autocomment", 0) + setlocal formatoptions-=t formatoptions+=croql + let b:undo_ftplugin ..= " | setlocal formatoptions<" endif if exists('&omnifunc') setlocal omnifunc=htmlcomplete#CompleteTags call htmlcomplete#DetectOmniFlavor() + let b:undo_ftplugin ..= " | setlocal omnifunc<" endif -" HTML: thanks to Johannes Zellner and Benji Fisher. -if exists("loaded_matchit") - let b:match_ignorecase = 1 - let b:match_words = '<:>,' . - \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . - \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' . - \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' +" HTML: thanks to Johannes Zellner and Benji Fisher. +if exists("loaded_matchit") && !exists("b:match_words") + let b:match_ignorecase = 1 + let b:match_words = ',' .. + \ '<:>,' .. + \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .. + \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .. + \ '<\@<=\([^/!][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' + let b:html_set_match_words = 1 + let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:html_set_match_words" endif " Change the :browse e filter to primarily show HTML-related files. -if has("gui_win32") - let b:browsefilter="HTML Files (*.html,*.htm)\t*.htm;*.html\n" . - \ "JavaScript Files (*.js)\t*.js\n" . - \ "Cascading StyleSheets (*.css)\t*.css\n" . - \ "All Files (*.*)\t*.*\n" +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "HTML Files (*.html *.htm)\t*.htm;*.html\n" .. + \ "JavaScript Files (*.js)\t*.js\n" .. + \ "Cascading StyleSheets (*.css)\t*.css\n" .. + \ "All Files (*.*)\t*.*\n" + let b:html_set_browsefilter = 1 + let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter" endif -" Undo the stuff we changed. -let b:undo_ftplugin = "setlocal commentstring< matchpairs< omnifunc< comments< formatoptions<" . - \ " | unlet! b:match_ignorecase b:match_skip b:match_words b:browsefilter" - -" Restore the saved compatibility options. let &cpo = s:save_cpo unlet s:save_cpo diff --git a/runtime/indent/bitbake.vim b/runtime/indent/bitbake.vim new file mode 100644 index 0000000000..f45ba74816 --- /dev/null +++ b/runtime/indent/bitbake.vim @@ -0,0 +1,22 @@ +" Vim indent file +" Language: BitBake +" Copyright: Copyright (C) 2019 Agilent Technologies, Inc. +" Maintainer: Chris Laplante +" License: You may redistribute this under the same terms as Vim itself + +if exists("b:did_indent") + finish +endif + +runtime! indent/sh.vim + +setlocal indentexpr=bitbake#Indent(v:lnum) +setlocal autoindent +setlocal nolisp +setlocal shiftwidth=4 +setlocal expandtab +setlocal indentkeys+=<:>,=elif,=except,0=\" + +let b:undo_indent .= ' inde< ai< lisp< sw< et< indk<' + +let b:did_indent = 1 diff --git a/runtime/indent/expect.vim b/runtime/indent/expect.vim new file mode 100644 index 0000000000..f2a1f05917 --- /dev/null +++ b/runtime/indent/expect.vim @@ -0,0 +1,11 @@ +" Vim indent file +" Language: Expect +" Maintainer: Doug Kearns +" Last Change: 2022 Jul 16 + +if exists("b:did_indent") + finish +endif + +" Syntax is similar to Tcl +runtime! indent/tcl.vim diff --git a/runtime/indent/python.vim b/runtime/indent/python.vim index 668122993e..8c3d0b0670 100644 --- a/runtime/indent/python.vim +++ b/runtime/indent/python.vim @@ -14,7 +14,7 @@ let b:did_indent = 1 setlocal nolisp " Make sure lisp indenting doesn't supersede us setlocal autoindent " indentexpr isn't much help otherwise -setlocal indentexpr=GetPythonIndent(v:lnum) +setlocal indentexpr=python#GetIndent(v:lnum) setlocal indentkeys+=<:>,=elif,=except let b:undo_indent = "setl ai< inde< indk< lisp<" @@ -23,206 +23,11 @@ let b:undo_indent = "setl ai< inde< indk< lisp<" if exists("*GetPythonIndent") finish endif -let s:keepcpo= &cpo -set cpo&vim - -" Come here when loading the script the first time. - -let s:maxoff = 50 " maximum number of lines to look backwards for () - -" See if the specified line is already user-dedented from the expected value. -function s:Dedented(lnum, expected) - return indent(a:lnum) <= a:expected - shiftwidth() -endfunction +" Keep this for backward compatibility, new scripts should use +" python#GetIndent() function GetPythonIndent(lnum) - - " If this line is explicitly joined: If the previous line was also joined, - " line it up with that one, otherwise add two 'shiftwidth' - if getline(a:lnum - 1) =~ '\\$' - if a:lnum > 1 && getline(a:lnum - 2) =~ '\\$' - return indent(a:lnum - 1) - endif - return indent(a:lnum - 1) + (exists("g:pyindent_continue") ? eval(g:pyindent_continue) : (shiftwidth() * 2)) - endif - - " If the start of the line is in a string don't change the indent. - if has('syntax_items') - \ && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$" - return -1 - endif - - " Search backwards for the previous non-empty line. - let plnum = prevnonblank(v:lnum - 1) - - if plnum == 0 - " This is the first non-empty line, use zero indent. - return 0 - endif - - call cursor(plnum, 1) - - " Identing inside parentheses can be very slow, regardless of the searchpair() - " timeout, so let the user disable this feature if he doesn't need it - let disable_parentheses_indenting = get(g:, "pyindent_disable_parentheses_indenting", 0) - - if disable_parentheses_indenting == 1 - let plindent = indent(plnum) - let plnumstart = plnum - else - " searchpair() can be slow sometimes, limit the time to 150 msec or what is - " put in g:pyindent_searchpair_timeout - let searchpair_stopline = 0 - let searchpair_timeout = get(g:, 'pyindent_searchpair_timeout', 150) - - " If the previous line is inside parenthesis, use the indent of the starting - " line. - " Trick: use the non-existing "dummy" variable to break out of the loop when - " going too far back. - let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW', - \ "line('.') < " . (plnum - s:maxoff) . " ? dummy :" - \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" - \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", - \ searchpair_stopline, searchpair_timeout) - if parlnum > 0 - let plindent = indent(parlnum) - let plnumstart = parlnum - else - let plindent = indent(plnum) - let plnumstart = plnum - endif - - " When inside parenthesis: If at the first line below the parenthesis add - " two 'shiftwidth', otherwise same as previous line. - " i = (a - " + b - " + c) - call cursor(a:lnum, 1) - let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW', - \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" - \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" - \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", - \ searchpair_stopline, searchpair_timeout) - if p > 0 - if p == plnum - " When the start is inside parenthesis, only indent one 'shiftwidth'. - let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW', - \ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :" - \ . " synIDattr(synID(line('.'), col('.'), 1), 'name')" - \ . " =~ '\\(Comment\\|Todo\\|String\\)$'", - \ searchpair_stopline, searchpair_timeout) - if pp > 0 - return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth()) - endif - return indent(plnum) + (exists("g:pyindent_open_paren") ? eval(g:pyindent_open_paren) : (shiftwidth() * 2)) - endif - if plnumstart == p - return indent(plnum) - endif - return plindent - endif - - endif - - - " Get the line and remove a trailing comment. - " Use syntax highlighting attributes when possible. - let pline = getline(plnum) - let pline_len = strlen(pline) - if has('syntax_items') - " If the last character in the line is a comment, do a binary search for - " the start of the comment. synID() is slow, a linear search would take - " too long on a long line. - if synIDattr(synID(plnum, pline_len, 1), "name") =~ "\\(Comment\\|Todo\\)$" - let min = 1 - let max = pline_len - while min < max - let col = (min + max) / 2 - if synIDattr(synID(plnum, col, 1), "name") =~ "\\(Comment\\|Todo\\)$" - let max = col - else - let min = col + 1 - endif - endwhile - let pline = strpart(pline, 0, min - 1) - endif - else - let col = 0 - while col < pline_len - if pline[col] == '#' - let pline = strpart(pline, 0, col) - break - endif - let col = col + 1 - endwhile - endif - - " If the previous line ended with a colon, indent this line - if pline =~ ':\s*$' - return plindent + shiftwidth() - endif - - " If the previous line was a stop-execution statement... - if getline(plnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>' - " See if the user has already dedented - if s:Dedented(a:lnum, indent(plnum)) - " If so, trust the user - return -1 - endif - " If not, recommend one dedent - return indent(plnum) - shiftwidth() - endif - - " If the current line begins with a keyword that lines up with "try" - if getline(a:lnum) =~ '^\s*\(except\|finally\)\>' - let lnum = a:lnum - 1 - while lnum >= 1 - if getline(lnum) =~ '^\s*\(try\|except\)\>' - let ind = indent(lnum) - if ind >= indent(a:lnum) - return -1 " indent is already less than this - endif - return ind " line up with previous try or except - endif - let lnum = lnum - 1 - endwhile - return -1 " no matching "try"! - endif - - " If the current line begins with a header keyword, dedent - if getline(a:lnum) =~ '^\s*\(elif\|else\)\>' - - " Unless the previous line was a one-liner - if getline(plnumstart) =~ '^\s*\(for\|if\|elif\|try\)\>' - return plindent - endif - - " Or the user has already dedented - if s:Dedented(a:lnum, plindent) - return -1 - endif - - return plindent - shiftwidth() - endif - - " When after a () construct we probably want to go back to the start line. - " a = (b - " + c) - " here - if parlnum > 0 - " ...unless the user has already dedented - if s:Dedented(a:lnum, plindent) - return -1 - else - return plindent - endif - endif - - return -1 - + return python#GetIndent(a:lnum) endfunction -let &cpo = s:keepcpo -unlet s:keepcpo - " vim:sw=2 diff --git a/runtime/indent/testdir/bitbake.in b/runtime/indent/testdir/bitbake.in new file mode 100644 index 0000000000..afd19be182 --- /dev/null +++ b/runtime/indent/testdir/bitbake.in @@ -0,0 +1,19 @@ +# vim: set filetype=bitbake : + +# START_INDENT +FOO = " \ + bar \ + baz \ + qux \ + " + +do_configure() { +oe_conf +} + +python do_task() { +def foo(x): +if y: +print(x) +} +# END_INDENT diff --git a/runtime/indent/testdir/bitbake.ok b/runtime/indent/testdir/bitbake.ok new file mode 100644 index 0000000000..1bc5a18c6f --- /dev/null +++ b/runtime/indent/testdir/bitbake.ok @@ -0,0 +1,19 @@ +# vim: set filetype=bitbake : + +# START_INDENT +FOO = " \ + bar \ + baz \ + qux \ +" + +do_configure() { + oe_conf +} + +python do_task() { + def foo(x): + if y: + print(x) +} +# END_INDENT diff --git a/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim b/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim index 6175d1d9a6..04b48b9ce8 100644 --- a/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim +++ b/runtime/pack/dist/opt/shellmenu/plugin/shellmenu.vim @@ -7,88 +7,98 @@ " Attached is a Vim script file for turning gvim into a shell script editor. " It may also be used as an example how to use menus in Vim. " -" Written by: Lennart Schultz +" Maintainer: Ada (Haowen) Yu +" Original author: Lennart Schultz (mail unreachable) -imenu Stmts.for for in do doneki kk0elli -imenu Stmts.case case in ) ;; esacbki k0elli -imenu Stmts.if if then fiki kk0elli -imenu Stmts.if-else if then else fiki kki kk0elli -imenu Stmts.elif elif then ki kk0elli -imenu Stmts.while while do doneki kk0elli -imenu Stmts.break break -imenu Stmts.continue continue -imenu Stmts.function () { }ki k0i -imenu Stmts.return return -imenu Stmts.return-true return 0 -imenu Stmts.return-false return 1 -imenu Stmts.exit exit -imenu Stmts.shift shift -imenu Stmts.trap trap -imenu Test.existence [ -e ]hi -imenu Test.existence - file [ -f ]hi -imenu Test.existence - file (not empty) [ -s ]hi -imenu Test.existence - directory [ -d ]hi -imenu Test.existence - executable [ -x ]hi -imenu Test.existence - readable [ -r ]hi -imenu Test.existence - writable [ -w ]hi -imenu Test.String is empty [ x = "x$" ]hhi -imenu Test.String is not empty [ x != "x$" ]hhi -imenu Test.Strings is equal [ "" = "" ]hhhhhhhi -imenu Test.Strings is not equal [ "" != "" ]hhhhhhhhi -imenu Test.Values is greater than [ -gt ]hhhhhhi -imenu Test.Values is greater equal [ -ge ]hhhhhhi -imenu Test.Values is equal [ -eq ]hhhhhhi -imenu Test.Values is not equal [ -ne ]hhhhhhi -imenu Test.Values is less than [ -lt ]hhhhhhi -imenu Test.Values is less equal [ -le ]hhhhhhi -imenu ParmSub.Substitute word if parm not set ${:-}hhi -imenu ParmSub.Set parm to word if not set ${:=}hhi -imenu ParmSub.Substitute word if parm set else nothing ${:+}hhi -imenu ParmSub.If parm not set print word and exit ${:?}hhi -imenu SpShVars.Number of positional parameters ${#} -imenu SpShVars.All positional parameters (quoted spaces) ${*} -imenu SpShVars.All positional parameters (unquoted spaces) ${@} -imenu SpShVars.Flags set ${-} -imenu SpShVars.Return code of last command ${?} -imenu SpShVars.Process number of this shell ${$} -imenu SpShVars.Process number of last background command ${!} -imenu Environ.HOME ${HOME} -imenu Environ.PATH ${PATH} -imenu Environ.CDPATH ${CDPATH} -imenu Environ.MAIL ${MAIL} -imenu Environ.MAILCHECK ${MAILCHECK} -imenu Environ.PS1 ${PS1} -imenu Environ.PS2 ${PS2} -imenu Environ.IFS ${IFS} -imenu Environ.SHACCT ${SHACCT} -imenu Environ.SHELL ${SHELL} -imenu Environ.LC_CTYPE ${LC_CTYPE} -imenu Environ.LC_MESSAGES ${LC_MESSAGES} -imenu Builtins.cd cd -imenu Builtins.echo echo -imenu Builtins.eval eval -imenu Builtins.exec exec -imenu Builtins.export export -imenu Builtins.getopts getopts -imenu Builtins.hash hash -imenu Builtins.newgrp newgrp -imenu Builtins.pwd pwd -imenu Builtins.read read -imenu Builtins.readonly readonly -imenu Builtins.return return -imenu Builtins.times times -imenu Builtins.type type -imenu Builtins.umask umask -imenu Builtins.wait wait -imenu Set.set set -imenu Set.unset unset -imenu Set.mark modified or modified variables set -a -imenu Set.exit when command returns non-zero exit code set -e -imenu Set.Disable file name generation set -f -imenu Set.remember function commands set -h -imenu Set.All keyword arguments are placed in the environment set -k -imenu Set.Read commands but do not execute them set -n -imenu Set.Exit after reading and executing one command set -t -imenu Set.Treat unset variables as an error when substituting set -u -imenu Set.Print shell input lines as they are read set -v -imenu Set.Print commands and their arguments as they are executed set -x +" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise +" would not be recognized. See ":help 'cpoptions'". +let s:cpo_save = &cpo +set cpo&vim + +imenu ShellMenu.Statements.for for in dodoneki kk0elli +imenu ShellMenu.Statements.case case in) ;;esacbki k0elli +imenu ShellMenu.Statements.if if thenfiki kk0elli +imenu ShellMenu.Statements.if-else if thenelsefiki kki kk0elli +imenu ShellMenu.Statements.elif elif thenki kk0elli +imenu ShellMenu.Statements.while while dodoneki kk0elli +imenu ShellMenu.Statements.break break +imenu ShellMenu.Statements.continue continue +imenu ShellMenu.Statements.function () {}ki k0i +imenu ShellMenu.Statements.return return +imenu ShellMenu.Statements.return-true return 0 +imenu ShellMenu.Statements.return-false return 1 +imenu ShellMenu.Statements.exit exit +imenu ShellMenu.Statements.shift shift +imenu ShellMenu.Statements.trap trap +imenu ShellMenu.Test.Existence [ -e ]hi +imenu ShellMenu.Test.Existence\ -\ file [ -f ]hi +imenu ShellMenu.Test.Existence\ -\ file\ (not\ empty) [ -s ]hi +imenu ShellMenu.Test.Existence\ -\ directory [ -d ]hi +imenu ShellMenu.Test.Existence\ -\ executable [ -x ]hi +imenu ShellMenu.Test.Existence\ -\ readable [ -r ]hi +imenu ShellMenu.Test.Existence\ -\ writable [ -w ]hi +imenu ShellMenu.Test.String\ is\ empty [ x = "x$" ]hhi +imenu ShellMenu.Test.String\ is\ not\ empty [ x != "x$" ]hhi +imenu ShellMenu.Test.Strings\ are\ equal [ "" = "" ]hhhhhhhi +imenu ShellMenu.Test.Strings\ are\ not\ equal [ "" != "" ]hhhhhhhhi +imenu ShellMenu.Test.Value\ is\ greater\ than [ -gt ]hhhhhhi +imenu ShellMenu.Test.Value\ is\ greater\ equal [ -ge ]hhhhhhi +imenu ShellMenu.Test.Values\ are\ equal [ -eq ]hhhhhhi +imenu ShellMenu.Test.Values\ are\ not\ equal [ -ne ]hhhhhhi +imenu ShellMenu.Test.Value\ is\ less\ than [ -lt ]hhhhhhi +imenu ShellMenu.Test.Value\ is\ less\ equal [ -le ]hhhhhhi +imenu ShellMenu.ParmSub.Substitute\ word\ if\ parm\ not\ set ${:-}hhi +imenu ShellMenu.ParmSub.Set\ parm\ to\ word\ if\ not\ set ${:=}hhi +imenu ShellMenu.ParmSub.Substitute\ word\ if\ parm\ set\ else\ nothing ${:+}hhi +imenu ShellMenu.ParmSub.If\ parm\ not\ set\ print\ word\ and\ exit ${:?}hhi +imenu ShellMenu.SpShVars.Number\ of\ positional\ parameters ${#} +imenu ShellMenu.SpShVars.All\ positional\ parameters\ (quoted\ spaces) ${*} +imenu ShellMenu.SpShVars.All\ positional\ parameters\ (unquoted\ spaces) ${@} +imenu ShellMenu.SpShVars.Flags\ set ${-} +imenu ShellMenu.SpShVars.Return\ code\ of\ last\ command ${?} +imenu ShellMenu.SpShVars.Process\ number\ of\ this\ shell ${$} +imenu ShellMenu.SpShVars.Process\ number\ of\ last\ background\ command ${!} +imenu ShellMenu.Environ.HOME ${HOME} +imenu ShellMenu.Environ.PATH ${PATH} +imenu ShellMenu.Environ.CDPATH ${CDPATH} +imenu ShellMenu.Environ.MAIL ${MAIL} +imenu ShellMenu.Environ.MAILCHECK ${MAILCHECK} +imenu ShellMenu.Environ.PS1 ${PS1} +imenu ShellMenu.Environ.PS2 ${PS2} +imenu ShellMenu.Environ.IFS ${IFS} +imenu ShellMenu.Environ.SHACCT ${SHACCT} +imenu ShellMenu.Environ.SHELL ${SHELL} +imenu ShellMenu.Environ.LC_CTYPE ${LC_CTYPE} +imenu ShellMenu.Environ.LC_MESSAGES ${LC_MESSAGES} +imenu ShellMenu.Builtins.cd cd +imenu ShellMenu.Builtins.echo echo +imenu ShellMenu.Builtins.eval eval +imenu ShellMenu.Builtins.exec exec +imenu ShellMenu.Builtins.export export +imenu ShellMenu.Builtins.getopts getopts +imenu ShellMenu.Builtins.hash hash +imenu ShellMenu.Builtins.newgrp newgrp +imenu ShellMenu.Builtins.pwd pwd +imenu ShellMenu.Builtins.read read +imenu ShellMenu.Builtins.readonly readonly +imenu ShellMenu.Builtins.return return +imenu ShellMenu.Builtins.times times +imenu ShellMenu.Builtins.type type +imenu ShellMenu.Builtins.umask umask +imenu ShellMenu.Builtins.wait wait +imenu ShellMenu.Set.set set +imenu ShellMenu.Set.unset unset +imenu ShellMenu.Set.Mark\ created\ or\ modified\ variables\ for\ export set -a +imenu ShellMenu.Set.Exit\ when\ command\ returns\ non-zero\ status set -e +imenu ShellMenu.Set.Disable\ file\ name\ expansion set -f +imenu ShellMenu.Set.Locate\ and\ remember\ commands\ when\ being\ looked\ up set -h +imenu ShellMenu.Set.All\ assignment\ statements\ are\ placed\ in\ the\ environment\ for\ a\ command set -k +imenu ShellMenu.Set.Read\ commands\ but\ do\ not\ execute\ them set -n +imenu ShellMenu.Set.Exit\ after\ reading\ and\ executing\ one\ command set -t +imenu ShellMenu.Set.Treat\ unset\ variables\ as\ an\ error\ when\ substituting set -u +imenu ShellMenu.Set.Print\ shell\ input\ lines\ as\ they\ are\ read set -v +imenu ShellMenu.Set.Print\ commands\ and\ their\ arguments\ as\ they\ are\ executed set -x + +" Restore the previous value of 'cpoptions'. +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/synmenu.vim b/runtime/synmenu.vim index d1e4becb2b..ba9e6a198d 100644 --- a/runtime/synmenu.vim +++ b/runtime/synmenu.vim @@ -18,6 +18,10 @@ fun! SetSyn(name) else let name = a:name endif + if a:name == "whitespace" + " do not replace the filetype but add whitespace on top + let name = &ft .. ".whitespace" + endif if !exists("s:syntax_menu_synonly") exe "set ft=" . name if exists("g:syntax_manual") diff --git a/runtime/syntax/bitbake.vim b/runtime/syntax/bitbake.vim new file mode 100644 index 0000000000..30f34474ad --- /dev/null +++ b/runtime/syntax/bitbake.vim @@ -0,0 +1,126 @@ +" Vim syntax file +" Language: BitBake bb/bbclasses/inc +" Author: Chris Larson +" Ricardo Salveti +" Copyright: Copyright (C) 2004 Chris Larson +" Copyright (C) 2008 Ricardo Salveti +" +" This file is licensed under the MIT license, see COPYING.MIT in +" this source distribution for the terms. +" +" Syntax highlighting for bb, bbclasses and inc files. +" +" It's an entirely new type, just has specific syntax in shell and python code + +if v:version < 600 + finish +endif +if exists("b:current_syntax") + finish +endif + +syn include @python syntax/python.vim +unlet! b:current_syntax + +" BitBake syntax + +" Matching case +syn case match + +" Indicates the error when nothing is matched +syn match bbUnmatched "." + +" Comments +syn cluster bbCommentGroup contains=bbTodo,@Spell +syn keyword bbTodo COMBAK FIXME TODO XXX contained +syn match bbComment "#.*$" contains=@bbCommentGroup + +" String helpers +syn match bbQuote +['"]+ contained +syn match bbDelimiter "[(){}=]" contained +syn match bbArrayBrackets "[\[\]]" contained + +" BitBake strings +syn match bbContinue "\\$" +syn region bbString matchgroup=bbQuote start=+"+ skip=+\\$+ end=+"+ contained contains=bbTodo,bbContinue,bbVarDeref,bbVarPyValue,@Spell +syn region bbString matchgroup=bbQuote start=+'+ skip=+\\$+ end=+'+ contained contains=bbTodo,bbContinue,bbVarDeref,bbVarPyValue,@Spell + +" Vars definition +syn match bbExport "^export" nextgroup=bbIdentifier skipwhite +syn keyword bbExportFlag export contained nextgroup=bbIdentifier skipwhite +syn match bbIdentifier "[a-zA-Z0-9\-_\.\/\+]\+" display contained +syn match bbVarDeref "${[a-zA-Z0-9\-_:\.\/\+]\+}" contained +syn match bbVarEq "\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)" contained nextgroup=bbVarValue +syn match bbVarDef "^\(export\s*\)\?\([a-zA-Z0-9\-_\.\/\+][${}a-zA-Z0-9\-_:\.\/\+]*\)\s*\(:=\|+=\|=+\|\.=\|=\.\|?=\|??=\|=\)\@=" contains=bbExportFlag,bbIdentifier,bbOverrideOperator,bbVarDeref nextgroup=bbVarEq +syn match bbVarValue ".*$" contained contains=bbString,bbVarDeref,bbVarPyValue +syn region bbVarPyValue start=+${@+ skip=+\\$+ end=+}+ contained contains=@python + +" Vars metadata flags +syn match bbVarFlagDef "^\([a-zA-Z0-9\-_\.]\+\)\(\[[a-zA-Z0-9\-_\.+]\+\]\)\@=" contains=bbIdentifier nextgroup=bbVarFlagFlag +syn region bbVarFlagFlag matchgroup=bbArrayBrackets start="\[" end="\]\s*\(:=\|=\|.=\|=.|+=\|=+\|?=\)\@=" contained contains=bbIdentifier nextgroup=bbVarEq + +" Includes and requires +syn keyword bbInclude inherit include require contained +syn match bbIncludeRest ".*$" contained contains=bbString,bbVarDeref +syn match bbIncludeLine "^\(inherit\|include\|require\)\s\+" contains=bbInclude nextgroup=bbIncludeRest + +" Add taks and similar +syn keyword bbStatement addtask deltask addhandler after before EXPORT_FUNCTIONS contained +syn match bbStatementRest ".*$" skipwhite contained contains=bbStatement +syn match bbStatementLine "^\(addtask\|deltask\|addhandler\|after\|before\|EXPORT_FUNCTIONS\)\s\+" contains=bbStatement nextgroup=bbStatementRest + +" OE Important Functions +syn keyword bbOEFunctions do_fetch do_unpack do_patch do_configure do_compile do_stage do_install do_package contained + +" Generic Functions +syn match bbFunction "\h[0-9A-Za-z_\-\.]*" display contained contains=bbOEFunctions + +syn keyword bbOverrideOperator append prepend remove contained + +" BitBake shell metadata +syn include @shell syntax/sh.vim +unlet! b:current_syntax + +syn keyword bbShFakeRootFlag fakeroot contained +syn match bbShFuncDef "^\(fakeroot\s*\)\?\([\.0-9A-Za-z_:${}\-\.]\+\)\(python\)\@ -" Previous Maintainer: Claudio Fleiner -" Repository: https://notabug.org/jorgesumle/vim-html-syntax -" Last Change: 2021 Mar 02 -" Included patch #7900 to fix comments -" Included patch #7916 to fix a few more things -" +" Language: HTML +" Maintainer: Doug Kearns +" Previous Maintainers: Jorge Maldonado Ventura +" Claudio Fleiner +" Last Change: 2022 Jul 20 " Please check :help html.vim for some comments and a description of the options @@ -23,6 +20,9 @@ set cpo&vim syntax spell toplevel +syn include @htmlXml syntax/xml.vim +unlet b:current_syntax + syn case ignore " mark illegal characters @@ -30,13 +30,13 @@ syn match htmlError "[<>&]" " tags -syn region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc -syn region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,javaScriptExpression,@htmlPreproc -syn match htmlValue contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1 contains=javaScriptExpression,@htmlPreproc -syn region htmlEndTag start=++ contains=htmlTagN,htmlTagError -syn region htmlTag start=+<[^/]+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster -syn match htmlTagN contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster -syn match htmlTagN contained +][^ \t>]*"hs=s+1 contains=javaScriptExpression,@htmlPreproc +syn region htmlEndTag start=++ contains=htmlTagN,htmlTagError +syn region htmlTag start=+<[^/]+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster +syn match htmlTagN contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster +syn match htmlTagN contained +]<"ms=s+1 @@ -47,13 +47,13 @@ syn keyword htmlTagName contained cite code dd dfn dir div dl dt font syn keyword htmlTagName contained form hr html img syn keyword htmlTagName contained input isindex kbd li link map menu syn keyword htmlTagName contained meta ol option param pre p samp span -syn keyword htmlTagName contained select small sub sup +syn keyword htmlTagName contained select small strike sub sup syn keyword htmlTagName contained table td textarea th tr tt ul var xmp -syn match htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\|head\|body\|title\)\>" +syn match htmlTagName contained "\<\%(b\|i\|u\|h[1-6]\|em\|strong\|head\|body\|title\)\>" " new html 4.0 tags -syn keyword htmlTagName contained abbr acronym bdo button col label -syn keyword htmlTagName contained colgroup fieldset iframe ins legend +syn keyword htmlTagName contained abbr acronym bdo button col colgroup +syn keyword htmlTagName contained del fieldset iframe ins label legend syn keyword htmlTagName contained object optgroup q s tbody tfoot thead " new html 5 tags @@ -65,6 +65,15 @@ syn keyword htmlTagName contained progress rb rp rt rtc ruby section syn keyword htmlTagName contained slot source summary template time track syn keyword htmlTagName contained video wbr +" svg and math tags +syn keyword htmlMathTagName contained math +syn keyword htmlSvgTagName contained svg + +syn region htmlMath start="" end="" contains=@htmlXml transparent keepend +syn region htmlSvg start="" end="" contains=@htmlXml transparent keepend + +syn cluster xmlTagHook add=htmlMathTagName,htmlSvgTagName + " legal arg names syn keyword htmlArg contained action syn keyword htmlArg contained align alink alt archive background bgcolor @@ -77,7 +86,7 @@ syn keyword htmlArg contained marginwidth maxlength method name prompt syn keyword htmlArg contained rel rev rows rowspan scrolling selected shape syn keyword htmlArg contained size src start target text type url syn keyword htmlArg contained usemap ismap valign value vlink vspace width wrap -syn match htmlArg contained "\<\(http-equiv\|href\|title\)="me=e-1 +syn match htmlArg contained "\<\%(http-equiv\|href\|title\)="me=e-1 " aria attributes exe 'syn match htmlArg contained "\" +syn keyword htmlArg contained frameborder noresize pagex pagey above below +syn keyword htmlArg contained left top visibility clip id noshade +syn match htmlArg contained "\" " Microsoft extensions syn keyword htmlTagName contained marquee " html 4.0 arg names -syn match htmlArg contained "\<\(accept-charset\|label\)\>" +syn match htmlArg contained "\<\%(accept-charset\|label\)\>" syn keyword htmlArg contained abbr accept accesskey axis char charoff charset syn keyword htmlArg contained cite classid codetype compact data datetime syn keyword htmlArg contained declare defer dir disabled for frame @@ -113,51 +122,57 @@ syn keyword htmlArg contained rules scheme scope span standby style syn keyword htmlArg contained summary tabindex valuetype version " html 5 arg names -syn keyword htmlArg contained allowfullscreen async autocomplete autofocus -syn keyword htmlArg contained autoplay challenge contenteditable contextmenu -syn keyword htmlArg contained controls crossorigin default dirname download -syn keyword htmlArg contained draggable dropzone form formaction formenctype -syn keyword htmlArg contained formmethod formnovalidate formtarget hidden -syn keyword htmlArg contained high icon inputmode keytype kind list loop low -syn keyword htmlArg contained max min minlength muted nonce novalidate open -syn keyword htmlArg contained optimum pattern placeholder poster preload -syn keyword htmlArg contained radiogroup required reversed sandbox spellcheck -syn keyword htmlArg contained sizes srcset srcdoc srclang step title translate -syn keyword htmlArg contained typemustmatch +syn keyword htmlArg contained allow autocapitalize as blocking decoding +syn keyword htmlArg contained enterkeyhint imagesizes imagesrcset inert +syn keyword htmlArg contained integrity is itemid itemprop itemref itemscope +syn keyword htmlArg contained itemtype loading nomodule ping playsinline +syn keyword htmlArg contained referrerpolicy slot allowfullscreen async +syn keyword htmlArg contained autocomplete autofocus autoplay challenge +syn keyword htmlArg contained contenteditable contextmenu controls crossorigin +syn keyword htmlArg contained default dirname download draggable dropzone form +syn keyword htmlArg contained formaction formenctype formmethod formnovalidate +syn keyword htmlArg contained formtarget hidden high icon inputmode keytype +syn keyword htmlArg contained kind list loop low max min minlength muted nonce +syn keyword htmlArg contained novalidate open optimum pattern placeholder +syn keyword htmlArg contained poster preload radiogroup required reversed +syn keyword htmlArg contained sandbox spellcheck sizes srcset srcdoc srclang +syn keyword htmlArg contained step title translate typemustmatch +syn match htmlArg contained "\+ contains=@Spell + syn region htmlComment start=+ " Idem 8.2.4.43,44: Except and are parser errors " Idem 8.2.4.52: dash-dash-bang (--!>) is error ignored by parser, also closes comment - syn region htmlComment matchgroup=htmlComment start=+ is all right syn match htmlCommentNested contained "\@!" syn match htmlCommentError contained "[^>+ keepend +syn region htmlComment start=++ keepend " server-parsed commands syn region htmlPreProc start=++ contains=htmlPreStmt,htmlPreError,htmlPreAttr -syn match htmlPreStmt contained "\)" + syn match htmlCssStyleComment contained "\%(\)" syn region htmlCssDefinition matchgroup=htmlArg start='style="' keepend matchgroup=htmlString end='"' contains=css.*Attr,css.*Prop,cssComment,cssLength,cssColor,cssURL,cssImportant,cssError,cssString,@htmlPreproc hi def link htmlStyleArg htmlString endif @@ -258,68 +273,70 @@ if main_syntax == "html" endif " The default highlighting. -hi def link htmlTag Function -hi def link htmlEndTag Identifier -hi def link htmlArg Type -hi def link htmlTagName htmlStatement -hi def link htmlSpecialTagName Exception -hi def link htmlValue String -hi def link htmlSpecialChar Special +hi def link htmlTag Function +hi def link htmlEndTag Identifier +hi def link htmlArg Type +hi def link htmlTagName htmlStatement +hi def link htmlSpecialTagName Exception +hi def link htmlMathTagName htmlTagName +hi def link htmlSvgTagName htmlTagName +hi def link htmlValue String +hi def link htmlSpecialChar Special if !exists("html_no_rendering") - hi def link htmlH1 Title - hi def link htmlH2 htmlH1 - hi def link htmlH3 htmlH2 - hi def link htmlH4 htmlH3 - hi def link htmlH5 htmlH4 - hi def link htmlH6 htmlH5 - hi def link htmlHead PreProc - hi def link htmlTitle Title - hi def link htmlBoldItalicUnderline htmlBoldUnderlineItalic - hi def link htmlUnderlineBold htmlBoldUnderline - hi def link htmlUnderlineItalicBold htmlBoldUnderlineItalic - hi def link htmlUnderlineBoldItalic htmlBoldUnderlineItalic - hi def link htmlItalicUnderline htmlUnderlineItalic - hi def link htmlItalicBold htmlBoldItalic - hi def link htmlItalicBoldUnderline htmlBoldUnderlineItalic - hi def link htmlItalicUnderlineBold htmlBoldUnderlineItalic - hi def link htmlLink Underlined - hi def link htmlLeadingSpace None + hi def link htmlH1 Title + hi def link htmlH2 htmlH1 + hi def link htmlH3 htmlH2 + hi def link htmlH4 htmlH3 + hi def link htmlH5 htmlH4 + hi def link htmlH6 htmlH5 + hi def link htmlHead PreProc + hi def link htmlTitle Title + hi def link htmlBoldItalicUnderline htmlBoldUnderlineItalic + hi def link htmlUnderlineBold htmlBoldUnderline + hi def link htmlUnderlineItalicBold htmlBoldUnderlineItalic + hi def link htmlUnderlineBoldItalic htmlBoldUnderlineItalic + hi def link htmlItalicUnderline htmlUnderlineItalic + hi def link htmlItalicBold htmlBoldItalic + hi def link htmlItalicBoldUnderline htmlBoldUnderlineItalic + hi def link htmlItalicUnderlineBold htmlBoldUnderlineItalic + hi def link htmlLink Underlined + hi def link htmlLeadingSpace None if !exists("html_my_rendering") - hi def htmlBold term=bold cterm=bold gui=bold - hi def htmlBoldUnderline term=bold,underline cterm=bold,underline gui=bold,underline - hi def htmlBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic + hi def htmlBold term=bold cterm=bold gui=bold + hi def htmlBoldUnderline term=bold,underline cterm=bold,underline gui=bold,underline + hi def htmlBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline - hi def htmlUnderline term=underline cterm=underline gui=underline - hi def htmlUnderlineItalic term=italic,underline cterm=italic,underline gui=italic,underline - hi def htmlItalic term=italic cterm=italic gui=italic + hi def htmlUnderline term=underline cterm=underline gui=underline + hi def htmlUnderlineItalic term=italic,underline cterm=italic,underline gui=italic,underline + hi def htmlItalic term=italic cterm=italic gui=italic if v:version > 800 || v:version == 800 && has("patch1038") - hi def htmlStrike term=strikethrough cterm=strikethrough gui=strikethrough + hi def htmlStrike term=strikethrough cterm=strikethrough gui=strikethrough else - hi def htmlStrike term=underline cterm=underline gui=underline + hi def htmlStrike term=underline cterm=underline gui=underline endif endif endif -hi def link htmlPreStmt PreProc -hi def link htmlPreError Error -hi def link htmlPreProc PreProc -hi def link htmlPreAttr String +hi def link htmlPreStmt PreProc +hi def link htmlPreError Error +hi def link htmlPreProc PreProc +hi def link htmlPreAttr String hi def link htmlPreProcAttrName PreProc hi def link htmlPreProcAttrError Error -hi def link htmlString String -hi def link htmlStatement Statement -hi def link htmlComment Comment -hi def link htmlCommentNested htmlError -hi def link htmlCommentError htmlError -hi def link htmlTagError htmlError -hi def link htmlEvent javaScript -hi def link htmlError Error +hi def link htmlString String +hi def link htmlStatement Statement +hi def link htmlComment Comment +hi def link htmlCommentNested htmlError +hi def link htmlCommentError htmlError +hi def link htmlTagError htmlError +hi def link htmlEvent javaScript +hi def link htmlError Error -hi def link javaScript Special +hi def link javaScript Special hi def link javaScriptExpression javaScript hi def link htmlCssStyleComment Comment -hi def link htmlCssDefinition Special +hi def link htmlCssDefinition Special let b:current_syntax = "html" diff --git a/runtime/syntax/make.vim b/runtime/syntax/make.vim index d0d7f1523b..68f7ee21ea 100644 --- a/runtime/syntax/make.vim +++ b/runtime/syntax/make.vim @@ -3,7 +3,7 @@ " Maintainer: Roland Hieber , " Previous Maintainer: Claudio Fleiner " URL: https://github.com/vim/vim/blob/master/runtime/syntax/make.vim -" Last Change: 2020 May 03 +" Last Change: 2020 Oct 16 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -45,19 +45,19 @@ syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:$"me=e-1 syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:[^=]"me=e-2 syn region makeTarget transparent matchgroup=makeTarget - \ start="^[~A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}[^:=]"rs=e-1 - \ end=";"re=e-1,me=e-1 end="[^\\]$" + \ start="^[~A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*&\?:\?:\{1,2}[^:=]"rs=e-1 + \ end="[^\\]$" \ keepend contains=makeIdent,makeSpecTarget,makeNextLine,makeComment,makeDString \ skipnl nextGroup=makeCommands -syn match makeTarget "^[~A-Za-z0-9_./$()%*@-][A-Za-z0-9_./\t $()%*@-]*::\=\s*$" +syn match makeTarget "^[~A-Za-z0-9_./$()%*@-][A-Za-z0-9_./\t $()%*@-]*&\?::\=\s*$" \ contains=makeIdent,makeSpecTarget,makeComment \ skipnl nextgroup=makeCommands,makeCommandError syn region makeSpecTarget transparent matchgroup=makeSpecTarget - \ start="^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\)\>\s*:\{1,2}[^:=]"rs=e-1 + \ start="^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\|ONESHELL\)\>\s*:\{1,2}[^:=]"rs=e-1 \ end="[^\\]$" keepend \ contains=makeIdent,makeSpecTarget,makeNextLine,makeComment skipnl nextGroup=makeCommands -syn match makeSpecTarget "^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\)\>\s*::\=\s*$" +syn match makeSpecTarget "^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\|ONESHELL\)\>\s*::\=\s*$" \ contains=makeIdent,makeComment \ skipnl nextgroup=makeCommands,makeCommandError