vim-patch:63b74a8362b1

Update runtime files.
63b74a8362
This commit is contained in:
Justin M. Keyes 2019-08-01 22:45:59 +02:00
parent 41fe644124
commit 2cdbbe50a4
14 changed files with 312 additions and 113 deletions

View File

@ -1,7 +1,7 @@
" Vim functions for file type detection
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2019 Jan 18
" Last Change: 2019 Mar 08
" These functions are moved here from runtime/filetype.vim to make startup
" faster.

View File

@ -1028,10 +1028,11 @@ tag command action in Command-line editing mode ~
command-line from history.
|c_CTRL-Q| CTRL-Q same as CTRL-V, unless it's used for terminal
control flow
|c_CTRL-R| CTRL-R {0-9a-z"%#*:= CTRL-F CTRL-P CTRL-W CTRL-A}
|c_CTRL-R| CTRL-R {regname}
insert the contents of a register or object
under the cursor as if typed
|c_CTRL-R_CTRL-R| CTRL-R CTRL-R {0-9a-z"%#*:= CTRL-F CTRL-P CTRL-W CTRL-A}
|c_CTRL-R_CTRL-R| CTRL-R CTRL-R {regname}
|c_CTRL-R_CTRL-O| CTRL-R CTRL-O {regname}
insert the contents of a register or object
under the cursor literally
CTRL-S (used for terminal control flow)

View File

@ -1810,7 +1810,15 @@ A jump table for the options with a short description can be found at |Q_op|.
The default value is for C programs. For C++ this value would be
useful, to include const type declarations: >
^\(#\s*define\|[a-z]*\s*const\s*[a-z]*\)
< You can also use "\ze" just before the name and continue the pattern
to check what is following. E.g. for Javascript, if a function is
defined with "func_name = function(args)": >
^\s*\ze\i\+\s*=\s*function(
< If the function is defined with "func_name : function() {...": >
^\s*\ze\i\+\s*[:]\s*(*function\s*(
< When using the ":set" command, you need to double the backslashes!
To avoid that use `:let` with a single quote string: >
let &l:define = '^\s*\ze\k\+\s*=\s*function('
*'delcombine'* *'deco'* *'nodelcombine'* *'nodeco'*
'delcombine' 'deco' boolean (default off)
@ -5974,7 +5982,9 @@ A jump table for the options with a short description can be found at |Q_op|.
pages.
split If included, split the current window before loading
a buffer for a |quickfix| command that display errors.
Otherwise: do not split, use current window.
Otherwise: do not split, use current window (when used
in the quickfix window: the previously used window or
split if there is no other window).
vsplit Just like "split" but split vertically.
newtab Like "split", but open a new tab page. Overrules
"split" when both are present.

View File

@ -523,8 +523,7 @@ only supported by new versions of ctags (such as Exuberant ctags).
be any identifier. It cannot contain a <Tab>.
{TAB} One <Tab> character. Note: previous versions allowed any
white space here. This has been abandoned to allow spaces in
{tagfile}. It can be re-enabled by including the
|+tag_any_white| feature at compile time. *tag-any-white*
{tagfile}.
{tagfile} The file that contains the definition of {tagname}. It can
have an absolute or relative path. It may contain environment
variables and wildcards (although the use of wildcards is

View File

@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2019 Feb 07
" Last Change: 2019 Mar 19
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@ -1613,6 +1613,10 @@ au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl
" Systemd unit files
au BufNewFile,BufRead */systemd/*.{automount,mount,path,service,socket,swap,target,timer} setf systemd
" Systemd overrides
au BufNewFile,BufRead /etc/systemd/system/*.d/*.conf setf systemd
" Systemd temp files
au BufNewFile,BufRead /etc/systemd/system/*.d/.#* setf systemd
" Synopsys Design Constraints
au BufNewFile,BufRead *.sdc setf sdc

View File

@ -1,7 +1,8 @@
" Vim filetype plugin file
" Language: cobol
" Author: Tim Pope <vimNOSPAM@tpope.info>
" Last Update: By ZyX: use shiftwidth()
" Maintainer: Ankit Jain <ajatkj@yahoo.co.in>
" (formerly Tim Pope <vimNOSPAM@tpope.info>)
" Last Update: By Ankit Jain (changed maintainer) on 22.03.2019
" Insert mode mappings: <C-T> <C-D> <Tab>
" Normal mode mappings: < > << >> [[ ]] [] ][

View File

@ -3,7 +3,7 @@
" Maintainer: Tom Picton <tom@tompicton.co.uk>
" Previous Maintainer: James Sully <sullyj3@gmail.com>
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
" Last Change: Sun, 15 April 2018
" Last Change: Sun 17 Mar 2019
" https://github.com/tpict/vim-ftplugin-python
if exists("b:did_ftplugin") | finish | endif
@ -37,9 +37,10 @@ setlocal suffixesadd=.py
setlocal comments=b:#,fb:-
setlocal commentstring=#\ %s
setlocal omnifunc=pythoncomplete#Complete
if has('python3')
setlocal omnifunc=python3complete#Complete
setlocal omnifunc=python3complete#Complete
elseif has('python')
setlocal omnifunc=pythoncomplete#Complete
endif
set wildignore+=*.pyc
@ -53,32 +54,34 @@ let b:prev='\v^\s*(class\|def\|async def)>'
let b:next_end='\v\S\n*(%$\|^(\s*\n*)*(class\|def\|async def)\|^\S)'
let b:prev_end='\v\S\n*(^(\s*\n*)*(class\|def\|async def)\|^\S)'
execute "nnoremap <silent> <buffer> ]] :call <SID>Python_jump('n', '". b:next_toplevel."', 'W', v:count1)<cr>"
execute "nnoremap <silent> <buffer> [[ :call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
execute "nnoremap <silent> <buffer> ][ :call <SID>Python_jump('n', '". b:next_endtoplevel."', 'W', 0, v:count1)<cr>"
execute "nnoremap <silent> <buffer> [] :call <SID>Python_jump('n', '". b:prev_endtoplevel."', 'Wb', 0, v:count1)<cr>"
execute "nnoremap <silent> <buffer> ]m :call <SID>Python_jump('n', '". b:next."', 'W', v:count1)<cr>"
execute "nnoremap <silent> <buffer> [m :call <SID>Python_jump('n', '". b:prev."', 'Wb', v:count1)<cr>"
execute "nnoremap <silent> <buffer> ]M :call <SID>Python_jump('n', '". b:next_end."', 'W', 0, v:count1)<cr>"
execute "nnoremap <silent> <buffer> [M :call <SID>Python_jump('n', '". b:prev_end."', 'Wb', 0, v:count1)<cr>"
if !exists('g:no_plugin_maps') && !exists('g:no_python_maps')
execute "nnoremap <silent> <buffer> ]] :call <SID>Python_jump('n', '". b:next_toplevel."', 'W', v:count1)<cr>"
execute "nnoremap <silent> <buffer> [[ :call <SID>Python_jump('n', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
execute "nnoremap <silent> <buffer> ][ :call <SID>Python_jump('n', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>"
execute "nnoremap <silent> <buffer> [] :call <SID>Python_jump('n', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>"
execute "nnoremap <silent> <buffer> ]m :call <SID>Python_jump('n', '". b:next."', 'W', v:count1)<cr>"
execute "nnoremap <silent> <buffer> [m :call <SID>Python_jump('n', '". b:prev."', 'Wb', v:count1)<cr>"
execute "nnoremap <silent> <buffer> ]M :call <SID>Python_jump('n', '". b:next_end."', 'W', v:count1, 0)<cr>"
execute "nnoremap <silent> <buffer> [M :call <SID>Python_jump('n', '". b:prev_end."', 'Wb', v:count1, 0)<cr>"
execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W', v:count1)<cr>"
execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
execute "onoremap <silent> <buffer> ][ :call <SID>Python_jump('o', '". b:next_endtoplevel."', 'W', 0, v:count1)<cr>"
execute "onoremap <silent> <buffer> [] :call <SID>Python_jump('o', '". b:prev_endtoplevel."', 'Wb', 0, v:count1)<cr>"
execute "onoremap <silent> <buffer> ]m :call <SID>Python_jump('o', '". b:next."', 'W', v:count1)<cr>"
execute "onoremap <silent> <buffer> [m :call <SID>Python_jump('o', '". b:prev."', 'Wb', v:count1)<cr>"
execute "onoremap <silent> <buffer> ]M :call <SID>Python_jump('o', '". b:next_end."', 'W', 0, v:count1)<cr>"
execute "onoremap <silent> <buffer> [M :call <SID>Python_jump('o', '". b:prev_end."', 'Wb', 0, v:count1)<cr>"
execute "onoremap <silent> <buffer> ]] :call <SID>Python_jump('o', '". b:next_toplevel."', 'W', v:count1)<cr>"
execute "onoremap <silent> <buffer> [[ :call <SID>Python_jump('o', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
execute "onoremap <silent> <buffer> ][ :call <SID>Python_jump('o', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>"
execute "onoremap <silent> <buffer> [] :call <SID>Python_jump('o', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>"
execute "onoremap <silent> <buffer> ]m :call <SID>Python_jump('o', '". b:next."', 'W', v:count1)<cr>"
execute "onoremap <silent> <buffer> [m :call <SID>Python_jump('o', '". b:prev."', 'Wb', v:count1)<cr>"
execute "onoremap <silent> <buffer> ]M :call <SID>Python_jump('o', '". b:next_end."', 'W', v:count1, 0)<cr>"
execute "onoremap <silent> <buffer> [M :call <SID>Python_jump('o', '". b:prev_end."', 'Wb', v:count1, 0)<cr>"
execute "xnoremap <silent> <buffer> ]] :call <SID>Python_jump('x', '". b:next_toplevel."', 'W', v:count1)<cr>"
execute "xnoremap <silent> <buffer> [[ :call <SID>Python_jump('x', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
execute "xnoremap <silent> <buffer> ][ :call <SID>Python_jump('x', '". b:next_endtoplevel."', 'W', 0, v:count1)<cr>"
execute "xnoremap <silent> <buffer> [] :call <SID>Python_jump('x', '". b:prev_endtoplevel."', 'Wb', 0, v:count1)<cr>"
execute "xnoremap <silent> <buffer> ]m :call <SID>Python_jump('x', '". b:next."', 'W', v:count1)<cr>"
execute "xnoremap <silent> <buffer> [m :call <SID>Python_jump('x', '". b:prev."', 'Wb', v:count1)<cr>"
execute "xnoremap <silent> <buffer> ]M :call <SID>Python_jump('x', '". b:next_end."', 'W', 0, v:count1)<cr>"
execute "xnoremap <silent> <buffer> [M :call <SID>Python_jump('x', '". b:prev_end."', 'Wb', 0, v:count1)<cr>"
execute "xnoremap <silent> <buffer> ]] :call <SID>Python_jump('x', '". b:next_toplevel."', 'W', v:count1)<cr>"
execute "xnoremap <silent> <buffer> [[ :call <SID>Python_jump('x', '". b:prev_toplevel."', 'Wb', v:count1)<cr>"
execute "xnoremap <silent> <buffer> ][ :call <SID>Python_jump('x', '". b:next_endtoplevel."', 'W', v:count1, 0)<cr>"
execute "xnoremap <silent> <buffer> [] :call <SID>Python_jump('x', '". b:prev_endtoplevel."', 'Wb', v:count1, 0)<cr>"
execute "xnoremap <silent> <buffer> ]m :call <SID>Python_jump('x', '". b:next."', 'W', v:count1)<cr>"
execute "xnoremap <silent> <buffer> [m :call <SID>Python_jump('x', '". b:prev."', 'Wb', v:count1)<cr>"
execute "xnoremap <silent> <buffer> ]M :call <SID>Python_jump('x', '". b:next_end."', 'W', v:count1, 0)<cr>"
execute "xnoremap <silent> <buffer> [M :call <SID>Python_jump('x', '". b:prev_end."', 'Wb', v:count1, 0)<cr>"
endif
if !exists('*<SID>Python_jump')
fun! <SID>Python_jump(mode, motion, flags, count, ...) range
@ -123,10 +126,80 @@ if !exists('g:pydoc_executable')
let g:pydoc_executable = 0
endif
endif
" Windows-specific pydoc setup
if has('win32') || has('win64')
if executable('python')
" available as Tools\scripts\pydoc.py
let g:pydoc_executable = 1
else
let g:pydoc_executable = 0
endif
endif
" If "pydoc" was found use it for keywordprg.
if g:pydoc_executable
setlocal keywordprg=pydoc
if has('win32') || has('win64')
setlocal keywordprg=python\ -m\ pydoc\
else
setlocal keywordprg=pydoc
endif
endif
" Script for filetype switching to undo the local stuff we may have changed
let b:undo_ftplugin = 'setlocal cinkeys<'
\ . '|setlocal comments<'
\ . '|setlocal commentstring<'
\ . '|setlocal expandtab<'
\ . '|setlocal include<'
\ . '|setlocal includeexpr<'
\ . '|setlocal indentkeys<'
\ . '|setlocal keywordprg<'
\ . '|setlocal omnifunc<'
\ . '|setlocal shiftwidth<'
\ . '|setlocal softtabstop<'
\ . '|setlocal suffixesadd<'
\ . '|setlocal tabstop<'
\ . '|silent! nunmap <buffer> [M'
\ . '|silent! nunmap <buffer> [['
\ . '|silent! nunmap <buffer> []'
\ . '|silent! nunmap <buffer> [m'
\ . '|silent! nunmap <buffer> ]M'
\ . '|silent! nunmap <buffer> ]['
\ . '|silent! nunmap <buffer> ]]'
\ . '|silent! nunmap <buffer> ]m'
\ . '|silent! ounmap <buffer> [M'
\ . '|silent! ounmap <buffer> [['
\ . '|silent! ounmap <buffer> []'
\ . '|silent! ounmap <buffer> [m'
\ . '|silent! ounmap <buffer> ]M'
\ . '|silent! ounmap <buffer> ]['
\ . '|silent! ounmap <buffer> ]]'
\ . '|silent! ounmap <buffer> ]m'
\ . '|silent! xunmap <buffer> [M'
\ . '|silent! xunmap <buffer> [['
\ . '|silent! xunmap <buffer> []'
\ . '|silent! xunmap <buffer> [m'
\ . '|silent! xunmap <buffer> ]M'
\ . '|silent! xunmap <buffer> ]['
\ . '|silent! xunmap <buffer> ]]'
\ . '|silent! xunmap <buffer> ]m'
\ . '|unlet! b:browsefilter'
\ . '|unlet! b:child_match'
\ . '|unlet! b:child_sub'
\ . '|unlet! b:grandparent_match'
\ . '|unlet! b:grandparent_sub'
\ . '|unlet! b:next'
\ . '|unlet! b:next_end'
\ . '|unlet! b:next_endtoplevel'
\ . '|unlet! b:next_toplevel'
\ . '|unlet! b:parent_match'
\ . '|unlet! b:parent_sub'
\ . '|unlet! b:prev'
\ . '|unlet! b:prev_end'
\ . '|unlet! b:prev_endtoplevel'
\ . '|unlet! b:prev_toplevel'
\ . '|unlet! b:undo_ftplugin'
let &cpo = s:keepcpo
unlet s:keepcpo

View File

@ -1,7 +1,12 @@
" Vim indent file
" Language: cobol
" Author: Tim Pope <vimNOSPAM@tpope.info>
" Maintainer: Ankit Jain <ajatkj@yahoo.co.in>
" (formerly Tim Pope <vimNOSPAM@tpope.info>)
" $Id: cobol.vim,v 1.1 2007/05/05 18:08:19 vimboss Exp $
" Last Update: By Ankit Jain on 22.03.2019
" Ankit Jain 22.03.2019 Changes & fixes:
" Allow chars in 1st 6 columns
" #C22032019
if exists("b:did_indent")
finish
@ -66,7 +71,9 @@ function! GetCobolIndent(lnum) abort
let ashft = minshft + 1
let bshft = ashft + 4
" (Obsolete) numbered lines
if getline(a:lnum) =~? '^\s*\d\{6\}\%($\|[ */$CD-]\)'
" #C22032019: Columns 1-6 could have alphabets as well as numbers
"if getline(a:lnum) =~? '^\s*\d\{6\}\%($\|[ */$CD-]\)'
if getline(a:lnum) =~? '^\s*[a-zA-Z0-9]\{6\}\%($\|[ */$CD-]\)'
return 0
endif
let cline = s:stripped(a:lnum)

View File

@ -2,7 +2,7 @@
" Header: "{{{
" Maintainer: Bram Moolenaar
" Original Author: Andy Wokula <anwoku@yahoo.de>
" Last Change: 2018 Mar 28
" Last Change: 2019 Mar 20
" Version: 1.0
" Description: HTML indent script with cached state for faster indenting on a
" range of lines.
@ -902,12 +902,19 @@ func! s:InsideTag(foundHtmlString)
"{{{
if a:foundHtmlString
" Inside an attribute string.
" Align with the previous line or use an external function.
" Align with the opening quote or use an external function.
let lnum = v:lnum - 1
if lnum > 1
if exists('b:html_indent_tag_string_func')
return b:html_indent_tag_string_func(lnum)
endif
" If there is a double quote in the previous line, indent with the
" character after it.
if getline(lnum) =~ '"'
call cursor(lnum, 0)
normal f"
return virtcol('.')
endif
return indent(lnum)
endif
endif

View File

@ -7,6 +7,8 @@
" License: Vim (see :h license)
" Repository: https://github.com/chrisbra/vim-sh-indent
" Changelog:
" 20190316 - Make use of searchpairpos for nested if sections
" fixes #11
" 20190201 - Better check for closing if sections
" 20180724 - make check for zsh syntax more rigid (needs word-boundaries)
" 20180326 - better support for line continuation
@ -115,7 +117,7 @@ function! GetShIndent()
" Current line is a endif line, so get indent from start of "if condition" line
" TODO: should we do the same for other "end" lines?
if curline =~ '^\s*\%(fi\)\s*\%(#.*\)\=$'
let previous_line = search('if.\{-\};\s*then\s*\%(#.*\)\=$', 'bnW')
let previous_line = searchpair('\<if\>', '', '\<fi\>', 'bnW')
if previous_line > 0
let ind = indent(previous_line)
endif

View File

@ -9,17 +9,17 @@
</div>
<div
class="foo bar">
class="foo bar">
text
</div>
<div class="foo bar"
data="something">
data="something">
text
</div>
<div class="foo
bar">
bar">
text
</div>

View File

@ -10,11 +10,11 @@
<!-- text comment -->
<!--
text comment
text comment
-->
</tag1>
<!--
text comment
text comment
end coment -->
</tag0>
<!-- END_INDENT -->

View File

@ -1,9 +1,11 @@
" Language: xml
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
" Last Changed: Jan 28, 2019
" Last Changed: Feb 04, 2019
" Maintainer: Christian Brabandt <cb@256bit.org>
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
" Last Change:
" 20190204 - correctly handle wrap tags
" https://github.com/chrisbra/vim-xml-ftplugin/issues/5
" 20190128 - Make sure to find previous tag
" https://github.com/chrisbra/vim-xml-ftplugin/issues/4
" 20181116 - Fix indentation when tags start with a colon or an underscore
@ -74,13 +76,20 @@ fun! <SID>XmlIndentSynCheck(lnum)
endfun
" [-- return the sum of indents of a:lnum --]
fun! <SID>XmlIndentSum(lnum, style, add)
let line = getline(a:lnum)
if a:style == match(line, '^\s*</')
fun! <SID>XmlIndentSum(line, style, add)
if <SID>IsXMLContinuation(a:line) && a:style == 0
" no complete tag, add one additional indent level
" but only for the current line
return a:add + shiftwidth()
elseif <SID>HasNoTagEnd(a:line)
" no complete tag, return initial indent
return a:add
endif
if a:style == match(a:line, '^\s*</')
return (shiftwidth() *
\ (<SID>XmlIndentWithPattern(line, b:xml_indent_open)
\ - <SID>XmlIndentWithPattern(line, b:xml_indent_close)
\ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add
\ (<SID>XmlIndentWithPattern(a:line, b:xml_indent_open)
\ - <SID>XmlIndentWithPattern(a:line, b:xml_indent_close)
\ - <SID>XmlIndentWithPattern(a:line, '.\{-}/>'))) + a:add
else
return a:add
endif
@ -89,19 +98,24 @@ endfun
" Main indent function
fun! XmlIndentGet(lnum, use_syntax_check)
" Find a non-empty line above the current line.
let plnum = prevnonblank(a:lnum - 1)
" Hit the start of the file, use zero indent.
if plnum == 0
if prevnonblank(a:lnum - 1) == 0
" Hit the start of the file, use zero indent.
return 0
endif
" Find previous line with a tag (regardless whether open or closed,
" but always start restrict the match to a line before the current one
" Note: xml declaration: <?xml version="1.0"?>
" won't be found, as it is not a legal tag name
let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. line('.').'l\)'
let ptag = search(ptag_pattern, 'bnw')
let ptag = search(ptag_pattern, 'bnW')
" no previous tag
if ptag == 0
return 0
endif
let syn_name = ''
if a:use_syntax_check
let check_lnum = <SID>XmlIndentSynCheck(plnum)
let check_lnum = <SID>XmlIndentSynCheck(ptag)
let check_alnum = <SID>XmlIndentSynCheck(a:lnum)
if check_lnum == 0 || check_alnum == 0
return indent(a:lnum)
@ -113,18 +127,31 @@ fun! XmlIndentGet(lnum, use_syntax_check)
return <SID>XmlIndentComment(a:lnum)
endif
let pline = getline(ptag)
let pind = indent(ptag)
" Get indent from previous tag line
let ind = <SID>XmlIndentSum(ptag, -1, indent(ptag))
let ind = <SID>XmlIndentSum(pline, -1, pind)
let t_ind = ind
" Determine indent from current line
let ind = <SID>XmlIndentSum(a:lnum, 0, ind)
let ind = <SID>XmlIndentSum(getline(a:lnum), 0, ind)
return ind
endfun
func! <SID>IsXMLContinuation(line)
" Checks, whether or not the line matches a start-of-tag
return a:line !~ '^\s*<'
endfunc
func! <SID>HasNoTagEnd(line)
" Checks whether or not the line matches '>' (so finishes a tag)
return a:line !~ '>\s*$'
endfunc
" return indent for a commented line,
" the middle part might be indented on additional level
func! <SID>XmlIndentComment(lnum)
let ptagopen = search(b:xml_indent_open, 'bnw')
let ptagclose = search(b:xml_indent_close, 'bnw')
let ptagopen = search(b:xml_indent_open, 'bnW')
let ptagclose = search(b:xml_indent_close, 'bnW')
if getline(a:lnum) =~ '<!--'
" if previous tag was a closing tag, do not add
" one additional level of indent
@ -136,10 +163,10 @@ func! <SID>XmlIndentComment(lnum)
endif
elseif getline(a:lnum) =~ '-->'
" end of comment, same as start of comment
return indent(search('<!--', 'bnw'))
return indent(search('<!--', 'bnW'))
else
" middle part of comment, add one additional level
return indent(search('<!--', 'bnw')) + shiftwidth()
return indent(search('<!--', 'bnW')) + shiftwidth()
endif
endfunc

View File

@ -1,10 +1,23 @@
" Vim syntax file
" Language: COBOL
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" Maintainer: Ankit Jain <ajatkj@yahoo.co.in>
" (formerly Tim Pope <vimNOSPAM@tpope.info>)
" (formerly Davyd Ondrejko <vondraco@columbus.rr.com>)
" (formerly Sitaram Chamarty <sitaram@diac.com> and
" James Mitchell <james_mitchell@acm.org>)
" Last Change: 2015 Feb 13
" Last Change: 2019 Mar 22
" Ankit Jain 22.03.2019 Changes & fixes:
" 1. Include inline comments
" 2. Use comment highlight for bad lines
" 3. Change certain 'keywords' to 'matches'
" for additional highlighting
" 4. Different highlighting for COPY, GO TO &
" CALL lines
" 5. Fix for COMP keyword
" 6. Fix for PROCEDURE DIVISION highlighting
" 7. Highlight EXIT PROGRAM like STOP RUN
" 8. Highlight X & A in PIC clause
" Tag: #C22032019
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@ -12,7 +25,11 @@ if exists("b:current_syntax")
endif
" MOST important - else most of the keywords wont work!
setlocal isk=@,48-57,-
setlocal isk=@,48-57,-,_
if !exists('g:cobol_inline_comment')
let g:cobol_inline_comment=0
endif
syn case ignore
@ -29,7 +46,10 @@ syn match cobolComment "[/*C].*$" contained
syn match cobolCompiler "$.*$" contained
syn match cobolLine ".*$" contained contains=cobolReserved,@cobolLine
syn match cobolDivision "[A-Z][A-Z0-9-]*[A-Z0-9]\s\+DIVISION\."he=e-1 contained contains=cobolDivisionName
"#C22032019: Fix for PROCEDURE DIVISION USING highlighting, removed . from the
"end of the regex
"syn match cobolDivision \"[A-Z][A-Z0-9-]*[A-Z0-9]\s\+DIVISION\."he=e-1 contained contains=cobolDivisionName
syn match cobolDivision "[A-Z][A-Z0-9-]*[A-Z0-9]\s\+DIVISION" contained contains=cobolDivisionName
syn keyword cobolDivisionName contained IDENTIFICATION ENVIRONMENT DATA PROCEDURE
syn match cobolSection "[A-Z][A-Z0-9-]*[A-Z0-9]\s\+SECTION\."he=e-1 contained contains=cobolSectionName
syn keyword cobolSectionName contained CONFIGURATION INPUT-OUTPUT FILE WORKING-STORAGE LOCAL-STORAGE LINKAGE
@ -38,10 +58,12 @@ syn keyword cobolParagraphName contained PROGRAM-ID SOURCE-COMPUTER OBJECT-COMP
"syn match cobolKeys "^\a\{1,6\}" contains=cobolReserved
"#C22032019: Remove BY, REPLACING, PROGRAM, TO, IN from 'keyword' group and add
"to 'match' group or other 'keyword' group
syn keyword cobolReserved contained ACCEPT ACCESS ADD ADDRESS ADVANCING AFTER ALPHABET ALPHABETIC
syn keyword cobolReserved contained ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED ALS
syn keyword cobolReserved contained ALTERNATE AND ANY ARE AREA AREAS ASCENDING ASSIGN AT AUTHOR BEFORE BINARY
syn keyword cobolReserved contained BLANK BLOCK BOTTOM BY CANCEL CBLL CD CF CH CHARACTER CHARACTERS CLASS
syn keyword cobolReserved contained BLANK BLOCK BOTTOM CANCEL CBLL CD CF CH CHARACTER CHARACTERS CLASS
syn keyword cobolReserved contained CLOCK-UNITS CLOSE COBOL CODE CODE-SET COLLATING COLUMN COMMA COMMON
syn keyword cobolReserved contained COMMUNICATIONS COMPUTATIONAL COMPUTE CONTENT CONTINUE
syn keyword cobolReserved contained CONTROL CONVERTING CORR CORRESPONDING COUNT CURRENCY DATE DATE-COMPILED
@ -55,52 +77,79 @@ syn keyword cobolReserved contained END-REWRITE END-SEARCH END-START END-STRING
syn keyword cobolReserved contained END-WRITE EQUAL ERROR ESI EVALUATE EVERY EXCEPTION EXIT
syn keyword cobolReserved contained EXTEND EXTERNAL FALSE FD FILLER FINAL FIRST FOOTING FOR FROM
syn keyword cobolReserved contained GENERATE GIVING GLOBAL GREATER GROUP HEADING HIGH-VALUE HIGH-VALUES I-O
syn keyword cobolReserved contained IN INDEX INDEXED INDICATE INITIAL INITIALIZE
syn keyword cobolReserved contained INDEX INDEXED INDICATE INITIAL INITIALIZE
syn keyword cobolReserved contained INITIATE INPUT INSPECT INSTALLATION INTO IS JUST
syn keyword cobolReserved contained JUSTIFIED KEY LABEL LAST LEADING LEFT LENGTH LOCK MEMORY
syn keyword cobolReserved contained MERGE MESSAGE MODE MODULES MOVE MULTIPLE MULTIPLY NATIVE NEGATIVE NEXT NO NOT
syn keyword cobolReserved contained NUMBER NUMERIC NUMERIC-EDITED OCCURS OF OFF OMITTED ON OPEN
syn keyword cobolReserved contained OPTIONAL OR ORDER ORGANIZATION OTHER OUTPUT OVERFLOW PACKED-DECIMAL PADDING
syn keyword cobolReserved contained PAGE PAGE-COUNTER PERFORM PF PH PIC PICTURE PLUS POINTER POSITION POSITIVE
syn keyword cobolReserved contained PRINTING PROCEDURES PROCEDD PROGRAM PURGE QUEUE QUOTES
syn keyword cobolReserved contained PRINTING PROCEDURES PROCEDD PURGE QUEUE QUOTES
syn keyword cobolReserved contained RANDOM RD READ RECEIVE RECORD RECORDS REDEFINES REEL REFERENCE REFERENCES
syn keyword cobolReserved contained RELATIVE RELEASE REMAINDER REMOVAL REPLACE REPLACING REPORT REPORTING
syn keyword cobolReserved contained RELATIVE RELEASE REMAINDER REMOVAL REPLACE REPORT REPORTING
syn keyword cobolReserved contained REPORTS RERUN RESERVE RESET RETURN RETURNING REVERSED REWIND REWRITE RF RH
syn keyword cobolReserved contained RIGHT ROUNDED RUN SAME SD SEARCH SECTION SECURITY SEGMENT SEGMENT-LIMITED
syn keyword cobolReserved contained SELECT SEND SENTENCE SEPARATE SEQUENCE SEQUENTIAL SET SIGN SIZE SORT
syn keyword cobolReserved contained SORT-MERGE SOURCE STANDARD
syn keyword cobolReserved contained STANDARD-1 STANDARD-2 START STATUS STOP STRING SUB-QUEUE-1 SUB-QUEUE-2
syn keyword cobolReserved contained SUB-QUEUE-3 SUBTRACT SUM SUPPRESS SYMBOLIC SYNC SYNCHRONIZED TABLE TALLYING
syn keyword cobolReserved contained TAPE TERMINAL TERMINATE TEST TEXT THAN THEN THROUGH THRU TIME TIMES TO TOP
syn keyword cobolReserved contained TAPE TERMINAL TERMINATE TEST TEXT THAN THEN THROUGH THRU TIME TIMES TOP
syn keyword cobolReserved contained TRAILING TRUE TYPE UNIT UNSTRING UNTIL UP UPON USAGE USE USING VALUE VALUES
syn keyword cobolReserved contained VARYING WHEN WITH WORDS WRITE
syn match cobolReserved contained "\<CONTAINS\>"
syn match cobolReserved contained "\<\(IF\|INVALID\|END\|EOP\)\>"
syn match cobolReserved contained "\<ALL\>"
" #C22032019: Add BY as match instead of keyword: BY not followed by ==
syn match cobolReserved contained "\<BY\>\s\+\(==\)\@!"
syn match cobolReserved contained "\<TO\>"
syn cluster cobolLine add=cobolConstant,cobolNumber,cobolPic
syn keyword cobolConstant SPACE SPACES NULL ZERO ZEROES ZEROS LOW-VALUE LOW-VALUES
" #C22032019: Fix for many pic clauses
syn match cobolNumber "\<-\=\d*\.\=\d\+\>" contained
syn match cobolPic "\<S*9\+\>" contained
" syn match cobolPic \"\<S*9\+\>" contained
syn match cobolPic "\<S*9\+V*9*\>" contained
syn match cobolPic "\<$*\.\=9\+\>" contained
syn match cobolPic "\<Z*\.\=9\+\>" contained
syn match cobolPic "\<V9\+\>" contained
syn match cobolPic "\<9\+V\>" contained
syn match cobolPic "\<-\+[Z9]\+\>" contained
syn match cobolTodo "todo" contained containedin=cobolComment
" syn match cobolPic \"\<-\+[Z9]\+\>" contained
syn match cobolPic "\<-*[Z9]\+-*\>" contained
" #C22032019: Add Z,X and A to cobolPic
syn match cobolPic "\<[ZXA]\+\>" contained
syn match cobolTodo "todo" contained containedin=cobolInlineComment,cobolComment
" For MicroFocus or other inline comments, include this line.
" syn region cobolComment start="*>" end="$" contains=cobolTodo,cobolMarker
if g:cobol_inline_comment == 1
syn region cobolInlineComment start="*>" end="$" contains=cobolTodo,cobolMarker
syn cluster cobolLine add=cobolInlineComment
endif
syn match cobolBadLine "[^ D\*$/-].*" contained
" If comment mark somehow gets into column past Column 7.
syn match cobolBadLine "\s\+\*.*" contained
if g:cobol_inline_comment == 1
" #C22032019: It is a bad line only if * is not followed by > when inline
" comments enabled
syn match cobolBadLine "\s\+\*\(>\)\@!.*" contained
else
syn match cobolBadLine "\s\+\*.*" contained
endif
syn cluster cobolStart add=cobolBadLine
syn keyword cobolGoTo GO GOTO
syn keyword cobolCopy COPY
" #C22032019: Different highlighting for GO TO statements
" syn keyword cobolGoTo GO GOTO
syn keyword cobolGoTo GOTO
syn match cobolGoTo /\<GO\>\s\+\<TO\>/
syn match cobolGoToPara /\<GO\>\s\+\<TO\>\s\+[A-Z0-9-]\+/ contains=cobolGoTo
" #C22032019: Highlight copybook name and location in using different group
" syn keyword cobolCopy COPY
syn match cobolCopy "\<COPY\>\|\<IN\>"
syn match cobolCopy "\<REPLACING\>\s\+\(==\)\@="
syn match cobolCopy "\<BY\>\s\+\(==\)\@="
syn match cobolCopyName "\<COPY\>\s\+[A-Z0-9]\+\(\s\+\<IN\>\s\+[A-Z0-9]\+\)\?" contains=cobolCopy
syn cluster cobolLine add=cobolGoToPara,cobolCopyName
" cobolBAD: things that are BAD NEWS!
syn keyword cobolBAD ALTER ENTER RENAMES
@ -109,8 +158,14 @@ syn cluster cobolLine add=cobolGoTo,cobolCopy,cobolBAD,cobolWatch,cobolEXE
" cobolWatch: things that are important when trying to understand a program
syn keyword cobolWatch OCCURS DEPENDING VARYING BINARY COMP REDEFINES
syn keyword cobolWatch REPLACING RUN
syn match cobolWatch "COMP-[123456XN]"
" #C22032019: Remove REPLACING from cobolWatch 'keyword' group and add to cobolCopy &
" cobolWatch 'match' group
" syn keyword cobolWatch REPLACING RUN
syn keyword cobolWatch RUN PROGRAM
syn match cobolWatch contained "\<REPLACING\>\s\+\(==\)\@!"
" #C22032019: Look for word starting with COMP
" syn match cobolWatch \"COMP-[123456XN]"
syn match cobolWatch "\<COMP-[123456XN]"
syn keyword cobolEXECs EXEC END-EXEC
@ -127,9 +182,15 @@ syn match cobolWatch "88 " contained nextgroup=cobolLine
"syn match cobolBadID "\k\+-\($\|[^-A-Z0-9]\)" contained
syn cluster cobolLine add=cobolCALLs,cobolString,cobolCondFlow
syn keyword cobolCALLs CALL END-CALL CANCEL GOBACK PERFORM END-PERFORM INVOKE
syn match cobolCALLs "EXIT \+PROGRAM"
" #C22032019: Changes for cobolCALLs group to include thru
" syn keyword cobolCALLs CALL END-CALL CANCEL GOBACK PERFORM END-PERFORM INVOKE
syn keyword cobolCALLs END-CALL CANCEL GOBACK PERFORM END-PERFORM INVOKE THRU
" #C22032019: Highlight called program
" syn match cobolCALLs \"EXIT \+PROGRAM"
syn match cobolCALLs "\<CALL\>"
syn match cobolCALLProg /\<CALL\>\s\+"\{0,1\}[A-Z0-9]\+"\{0,1\}/ contains=cobolCALLs
syn match cobolExtras /\<VALUE \+\d\+\./hs=s+6,he=e-1
syn cluster cobolLine add=cobolCALLProg
syn match cobolString /"[^"]*\("\|$\)/
syn match cobolString /'[^']*\('\|$\)/
@ -138,7 +199,7 @@ syn match cobolString /'[^']*\('\|$\)/
syn match cobolIndicator "\%7c[D-]" contained
if exists("cobol_legacy_code")
syn region cobolCondFlow contains=ALLBUT,cobolLine,cobolBadLine start="\<\(IF\|INVALID\|END\|EOP\)\>" skip=/\('\|"\)[^"]\{-}\("\|'\|$\)/ end="\." keepend
syn region cobolCondFlow contains=ALLBUT,cobolLine start="\<\(IF\|INVALID\|END\|EOP\)\>" skip=/\('\|"\)[^"]\{-}\("\|'\|$\)/ end="\." keepend
endif
" many legacy sources have junk in columns 1-6: must be before others
@ -146,7 +207,9 @@ endif
if exists("cobol_legacy_code")
syn match cobolBadLine "\%73c.*" containedin=ALLBUT,cobolComment
else
syn match cobolBadLine "\%73c.*" containedin=ALL
" #C22032019: Use comment highlighting for bad lines
" syn match cobolBadLine \"\%73c.*" containedin=ALL
syn match cobolBadLine "\%73c.*" containedin=ALL,cobolInlineComment,cobolComment
endif
" Define the default highlighting.
@ -160,31 +223,36 @@ if exists("g:cobol_legacy_code")
else
hi def link cobolMarker Error
endif
hi def link cobolCALLs Function
hi def link cobolComment Comment
hi def link cobolKeys Comment
hi def link cobolAreaB Special
hi def link cobolCompiler PreProc
hi def link cobolCondFlow Special
hi def link cobolCopy PreProc
hi def link cobolDeclA cobolDecl
hi def link cobolDecl Type
hi def link cobolExtras Special
hi def link cobolGoTo Special
hi def link cobolConstant Constant
hi def link cobolNumber Constant
hi def link cobolPic Constant
hi def link cobolReserved Statement
hi def link cobolDivision Label
hi def link cobolSection Label
hi def link cobolParagraph Label
hi def link cobolDivisionName Keyword
hi def link cobolSectionName Keyword
hi def link cobolParagraphName Keyword
hi def link cobolString Constant
hi def link cobolTodo Todo
hi def link cobolWatch Special
hi def link cobolIndicator Special
hi def link cobolCALLs Function
hi def link cobolCALLProg Special
hi def link cobolComment Comment
hi def link cobolInlineComment Comment
hi def link cobolKeys Comment
hi def link cobolAreaB Special
hi def link cobolCompiler PreProc
hi def link cobolCondFlow Special
hi def link cobolCopy PreProc
hi def link cobolCopyName Special
hi def link cobolDeclA cobolDecl
hi def link cobolDecl Type
hi def link cobolExtras Special
hi def link cobolGoTo Special
hi def link cobolGoToPara Function
hi def link cobolConstant Constant
hi def link cobolNumber Constant
hi def link cobolPic Constant
hi def link cobolReserved Statement
hi def link cobolDivision Label
hi def link cobolSection Label
hi def link cobolParagraph Label
hi def link cobolDivisionName Keyword
hi def link cobolSectionName Keyword
hi def link cobolParagraphName Keyword
hi def link cobolString Constant
hi def link cobolTodo Todo
hi def link cobolWatch Special
hi def link cobolIndicator Special
hi def link cobolStart Comment
let b:current_syntax = "cobol"