summaryrefslogtreecommitdiffstats
path: root/runtime/syntax
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-07-29 15:07:52 +0200
committerBram Moolenaar <Bram@vim.org>2018-07-29 15:07:52 +0200
commit91f84f6e11cd879d43d651c0903d85bff95f0716 (patch)
tree3c38a15ec4665ac5ed69454e41bd3347f41e800e /runtime/syntax
parentfdd7155fab3447b38280035c66178330f8f041e7 (diff)
Update runtime files.
Diffstat (limited to 'runtime/syntax')
-rw-r--r--runtime/syntax/java.vim27
-rw-r--r--runtime/syntax/javascript.vim12
-rw-r--r--runtime/syntax/readline.vim17
-rw-r--r--runtime/syntax/rst.vim108
4 files changed, 132 insertions, 32 deletions
diff --git a/runtime/syntax/java.vim b/runtime/syntax/java.vim
index 89320597f1..c9bb5dc2d4 100644
--- a/runtime/syntax/java.vim
+++ b/runtime/syntax/java.vim
@@ -1,8 +1,8 @@
" Vim syntax file
" Language: Java
" Maintainer: Claudio Fleiner <claudio@fleiner.com>
-" URL: http://www.fleiner.com/vim/syntax/java.vim
-" Last Change: 2015 March 01
+" URL: https://github.com/fleiner/vim/blob/master/runtime/syntax/java.vim
+" Last Change: 2018 July 26
" Please check :help java.vim for comments on some of the options available.
@@ -29,8 +29,6 @@ syn match javaOK "\.\.\."
syn match javaError2 "#\|=<"
hi def link javaError2 javaError
-
-
" keyword definitions
syn keyword javaExternal native package
syn match javaExternal "\<import\>\(\s\+static\>\)\?"
@@ -40,7 +38,7 @@ syn keyword javaRepeat while for do
syn keyword javaBoolean true false
syn keyword javaConstant null
syn keyword javaTypedef this super
-syn keyword javaOperator new instanceof
+syn keyword javaOperator var new instanceof
syn keyword javaType boolean char byte short int long float double
syn keyword javaType void
syn keyword javaStatement return
@@ -54,17 +52,25 @@ syn match javaTypedef "\.\s*\<class\>"ms=s+1
syn keyword javaClassDecl enum
syn match javaClassDecl "^class\>"
syn match javaClassDecl "[^.]\s*\<class\>"ms=s+1
-syn match javaAnnotation "@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>\(([^)]*)\)\=" contains=javaString
+syn match javaAnnotation "@\([_$a-zA-Z][_$a-zA-Z0-9]*\.\)*[_$a-zA-Z][_$a-zA-Z0-9]*\>" contains=javaString
syn match javaClassDecl "@interface\>"
syn keyword javaBranch break continue nextgroup=javaUserLabelRef skipwhite
syn match javaUserLabelRef "\k\+" contained
syn match javaVarArg "\.\.\."
syn keyword javaScopeDecl public protected private abstract
+" Java Modules(Since Java 9, for "module-info.java" file)
+if fnamemodify(bufname("%"), ":t") == "module-info.java"
+ syn keyword javaModuleStorageClass module transitive
+ syn keyword javaModuleStmt open requires exports opens uses provides
+ syn keyword javaModuleExternal to with
+ syn cluster javaTop add=javaModuleStorageClass,javaModuleStmt,javaModuleExternal
+endif
+
if exists("java_highlight_java_lang_ids")
let java_highlight_all=1
endif
-if exists("java_highlight_all") || exists("java_highlight_java") || exists("java_highlight_java_lang")
+if exists("java_highlight_all") || exists("java_highlight_java") || exists("java_highlight_java_lang")
" java.lang.*
syn match javaLangClass "\<System\>"
syn keyword javaR_JavaLang NegativeArraySizeException ArrayStoreException IllegalStateException RuntimeException IndexOutOfBoundsException UnsupportedOperationException ArrayIndexOutOfBoundsException ArithmeticException ClassCastException EnumConstantNotPresentException StringIndexOutOfBoundsException IllegalArgumentException IllegalMonitorStateException IllegalThreadStateException NumberFormatException NullPointerException TypeNotPresentException SecurityException
@@ -296,6 +302,7 @@ hi def link javaStorageClass StorageClass
hi def link javaMethodDecl javaStorageClass
hi def link javaClassDecl javaStorageClass
hi def link javaScopeDecl javaStorageClass
+
hi def link javaBoolean Boolean
hi def link javaSpecial Special
hi def link javaSpecialError Error
@@ -329,6 +336,12 @@ hi def link htmlComment Special
hi def link htmlCommentPart Special
hi def link javaSpaceError Error
+if fnamemodify(bufname("%"), ":t") == "module-info.java"
+ hi def link javaModuleStorageClass StorageClass
+ hi def link javaModuleStmt Statement
+ hi def link javaModuleExternal Include
+endif
+
let b:current_syntax = "java"
if main_syntax == 'java'
diff --git a/runtime/syntax/javascript.vim b/runtime/syntax/javascript.vim
index a95ecacb09..78714d0170 100644
--- a/runtime/syntax/javascript.vim
+++ b/runtime/syntax/javascript.vim
@@ -7,7 +7,7 @@
" (ss) repaired several quoting and grouping glitches
" (ss) fixed regex parsing issue with multiple qualifiers [gi]
" (ss) additional factoring of keywords, globals, and members
-" Last Change: 2012 Oct 05
+" Last Change: 2018 Jul 28
" 2013 Jun 12: adjusted javaScriptRegexpString (Kevin Locke)
" 2018 Apr 14: adjusted javaScriptRegexpString (LongJohnCoder)
@@ -35,10 +35,13 @@ syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,java
syn match javaScriptSpecial "\\\d\d\d\|\\."
syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
+syn region javaScriptStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=javaScriptSpecial,javaScriptEmbed,@htmlPreproc
+
+syn region javaScriptEmbed start=+${+ end=+}+ contains=@javaScriptEmbededExpr
syn match javaScriptSpecialCharacter "'\\.'"
syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
-syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gimuys]\{0,2\}\s*$+ end=+/[gimuys]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
+syn region javaScriptRegexpString start=+[,(=+]\s*/[^/*]+ms=e-1,me=e-1 skip=+\\\\\|\\/+ end=+/[gimuys]\{0,2\}\s*$+ end=+/[gimuys]\{0,2\}\s*[+;.,)\]}]+me=e-1 end=+/[gimuys]\{0,2\}\s\+\/+me=e-1 contains=@htmlPreproc,javaScriptComment oneline
syn keyword javaScriptConditional if else switch
syn keyword javaScriptRepeat while for do in
@@ -57,6 +60,8 @@ syn keyword javaScriptMember document event location
syn keyword javaScriptDeprecated escape unescape
syn keyword javaScriptReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
+syn cluster javaScriptEmbededExpr contains=javaScriptBoolean,javaScriptNull,javaScriptIdentifier,javaScriptStringD,javaScriptStringS,javaScriptStringT
+
if exists("javaScript_fold")
syn match javaScriptFunction "\<function\>"
syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
@@ -87,6 +92,7 @@ hi def link javaScriptCommentTodo Todo
hi def link javaScriptSpecial Special
hi def link javaScriptStringS String
hi def link javaScriptStringD String
+hi def link javaScriptStringT String
hi def link javaScriptCharacter Character
hi def link javaScriptSpecialCharacter javaScriptSpecial
hi def link javaScriptNumber javaScriptValue
@@ -114,6 +120,8 @@ hi def link javaScriptDeprecated Exception
hi def link javaScriptReserved Keyword
hi def link javaScriptDebug Debug
hi def link javaScriptConstant Label
+hi def link javaScriptEmbed Special
+
let b:current_syntax = "javascript"
diff --git a/runtime/syntax/readline.vim b/runtime/syntax/readline.vim
index 78472cdbfd..3831ae1149 100644
--- a/runtime/syntax/readline.vim
+++ b/runtime/syntax/readline.vim
@@ -2,9 +2,9 @@
" Language: readline(3) configuration file
" Maintainer: Daniel Moch <daniel@danielmoch.com>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2017-12-25
-" readline_has_bash - if defined add support for bash specific
-" settings/functions
+" Latest Revision: 2018-07-26
+" Add new functions for Readline 7 / Bash 4.4
+" (credit: Github user bewuethr)
if exists('b:current_syntax')
finish
@@ -111,7 +111,7 @@ syn keyword readlineKeyword contained
\ nextgroup=readlineVariable
\ skipwhite
-syn keyword readlineVariable contained
+syn keyword readlineVariable contained
\ nextgroup=readlineBellStyle
\ skipwhite
\ bell-style
@@ -120,12 +120,15 @@ syn keyword readlineVariable contained
\ nextgroup=readlineBoolean
\ skipwhite
\ bind-tty-special-chars
+ \ blink-matching-paren
+ \ colored-completion-prefix
\ colored-stats
\ completion-ignore-case
\ completion-map-case
\ convert-meta
\ disable-completion
\ echo-control-characters
+ \ enable-bracketed-paste
\ enable-keypad
\ enable-meta-key
\ expand-tilde
@@ -269,6 +272,7 @@ syn keyword readlineFunction contained
\ start-kbd-macro
\ end-kbd-macro
\ call-last-kbd-macro
+ \ print-last-kbd-macro
\
\ re-read-init-file
\ abort
@@ -339,6 +343,8 @@ syn keyword readlineFunction contained
if exists("readline_has_bash")
syn keyword readlineFunction contained
+ \ shell-forward-word
+ \ shell-backward-word
\ shell-expand-line
\ history-expand-line
\ magic-space
@@ -347,6 +353,8 @@ if exists("readline_has_bash")
\ insert-last-argument
\ operate-and-get-next
\ forward-backward-delete-char
+ \ shell-kill-word
+ \ shell-backward-kill-word
\ delete-char-or-list
\ complete-filename
\ possible-filename-completions
@@ -359,6 +367,7 @@ if exists("readline_has_bash")
\ complete-command
\ possible-command-completions
\ dynamic-complete-history
+ \ dabbrev-expand
\ complete-into-braces
\ glob-expand-word
\ glob-list-expansions
diff --git a/runtime/syntax/rst.vim b/runtime/syntax/rst.vim
index 232d2a7de3..d620d91f4a 100644
--- a/runtime/syntax/rst.vim
+++ b/runtime/syntax/rst.vim
@@ -3,7 +3,7 @@
" Maintainer: Marshall Ward <marshall.ward@gmail.com>
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
" Website: https://github.com/marshallward/vim-restructuredtext
-" Latest Revision: 2016-08-18
+" Latest Revision: 2018-07-23
if exists("b:current_syntax")
finish
@@ -50,7 +50,10 @@ syn cluster rstDirectives contains=rstFootnote,rstCitation,
syn match rstExplicitMarkup '^\s*\.\.\_s'
\ nextgroup=@rstDirectives,rstComment,rstSubstitutionDefinition
-let s:ReferenceName = '[[:alnum:]]\+\%([_.-][[:alnum:]]\+\)*'
+" "Simple reference names are single words consisting of alphanumerics plus
+" isolated (no two adjacent) internal hyphens, underscores, periods, colons
+" and plus signs."
+let s:ReferenceName = '[[:alnum:]]\%([-_.:+]\?[[:alnum:]]\+\)*'
syn keyword rstTodo contained FIXME TODO XXX NOTE
@@ -83,7 +86,7 @@ execute 'syn region rstExDirective contained matchgroup=rstDirective' .
\ ' end=+^\s\@!+ contains=@rstCruft,rstLiteralBlock'
execute 'syn match rstSubstitutionDefinition contained' .
- \ ' /|' . s:ReferenceName . '|\_s\+/ nextgroup=@rstDirectives'
+ \ ' /|.*|\_s\+/ nextgroup=@rstDirectives'
function! s:DefineOneInlineMarkup(name, start, middle, end, char_left, char_right)
execute 'syn region rst' . a:name .
@@ -107,10 +110,10 @@ function! s:DefineInlineMarkup(name, start, middle, end)
call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '’', '’')
" TODO: Additional Unicode Pd, Po, Pi, Pf, Ps characters
- call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|[/:]\)', '')
+ call s:DefineOneInlineMarkup(a:name, a:start, middle, a:end, '\%(^\|\s\|\%ua0\|[/:]\)', '')
execute 'syn match rst' . a:name .
- \ ' +\%(^\|\s\|[''"([{</:]\)\zs' . a:start .
+ \ ' +\%(^\|\s\|\%ua0\|[''"([{</:]\)\zs' . a:start .
\ '[^[:space:]' . a:start[strlen(a:start) - 1] . ']'
\ a:end . '\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
@@ -124,14 +127,31 @@ call s:DefineInlineMarkup('InlineLiteral', '``', "", '``')
call s:DefineInlineMarkup('SubstitutionReference', '|', '|', '|_\{0,2}')
call s:DefineInlineMarkup('InlineInternalTargets', '_`', '`', '`')
-syn match rstSections "^\%(\([=`:.'"~^_*+#-]\)\1\+\n\)\=.\+\n\([=`:.'"~^_*+#-]\)\2\+$"
+" Sections are identified through their titles, which are marked up with
+" adornment: "underlines" below the title text, or underlines and matching
+" "overlines" above the title. An underline/overline is a single repeated
+" punctuation character that begins in column 1 and forms a line extending at
+" least as far as the right edge of the title text.
+"
+" It is difficult to count characters in a regex, but we at least special-case
+" the case where the title has at least three characters to require the
+" adornment to have at least three characters as well, in order to handle
+" properly the case of a literal block:
+"
+" this is the end of a paragraph
+" ::
+" this is a literal block
+syn match rstSections "\v^%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+$"
+ \ contains=@Spell
+syn match rstSections "\v^%(([=`:.'"~^_*+#-])\1{2,}\n)?.{3,}\n([=`:.'"~^_*+#-])\2{2,}$"
+ \ contains=@Spell
" TODO: Can’t remember why these two can’t be defined like the ones above.
execute 'syn match rstFootnoteReference contains=@NoSpell' .
- \ ' +\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+'
+ \ ' +\%(\s\|^\)\[\%(\d\+\|#\%(' . s:ReferenceName . '\)\=\|\*\)\]_+'
execute 'syn match rstCitationReference contains=@NoSpell' .
- \ ' +\[' . s:ReferenceName . '\]_\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
+ \ ' +\%(\s\|^\)\[' . s:ReferenceName . '\]_\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)+'
execute 'syn match rstHyperlinkReference' .
\ ' /\<' . s:ReferenceName . '__\=\ze\%($\|\s\|[''")\]}>/:.,;!?\\-]\)/'
@@ -140,28 +160,69 @@ syn match rstStandaloneHyperlink contains=@NoSpell
\ "\<\%(\%(\%(https\=\|file\|ftp\|gopher\)://\|\%(mailto\|news\):\)[^[:space:]'\"<>]\+\|www[[:alnum:]_-]*\.[[:alnum:]_-]\+\.[^[:space:]'\"<>]\+\)[[:alnum:]/]"
syn region rstCodeBlock contained matchgroup=rstDirective
- \ start=+\%(sourcecode\|code\%(-block\)\=\)::\s\+\w*\_s*\n\ze\z(\s\+\)+
+ \ start=+\%(sourcecode\|code\%(-block\)\=\)::\s\+.*\_s*\n\ze\z(\s\+\)+
\ skip=+^$+
\ end=+^\z1\@!+
\ contains=@NoSpell
syn cluster rstDirectives add=rstCodeBlock
if !exists('g:rst_syntax_code_list')
- let g:rst_syntax_code_list = ['vim', 'java', 'cpp', 'lisp', 'php',
- \ 'python', 'perl', 'sh']
+ " A mapping from a Vim filetype to a list of alias patterns (pattern
+ " branches to be specific, see ':help /pattern'). E.g. given:
+ "
+ " let g:rst_syntax_code_list = {
+ " \ 'cpp': ['cpp', 'c++'],
+ " \ }
+ "
+ " then the respective contents of the following two rST directives:
+ "
+ " .. code:: cpp
+ "
+ " auto i = 42;
+ "
+ " .. code:: C++
+ "
+ " auto i = 42;
+ "
+ " will both be highlighted as C++ code. As shown by the latter block
+ " pattern matching will be case-insensitive.
+ let g:rst_syntax_code_list = {
+ \ 'vim': ['vim'],
+ \ 'java': ['java'],
+ \ 'cpp': ['cpp', 'c++'],
+ \ 'lisp': ['lisp'],
+ \ 'php': ['php'],
+ \ 'python': ['python'],
+ \ 'perl': ['perl'],
+ \ 'sh': ['sh'],
+ \ }
+elseif type(g:rst_syntax_code_list) == type([])
+ " backward compatibility with former list format
+ let s:old_spec = g:rst_syntax_code_list
+ let g:rst_syntax_code_list = {}
+ for s:elem in s:old_spec
+ let g:rst_syntax_code_list[s:elem] = [s:elem]
+ endfor
endif
-for code in g:rst_syntax_code_list
+for s:filetype in keys(g:rst_syntax_code_list)
unlet! b:current_syntax
" guard against setting 'isk' option which might cause problems (issue #108)
let prior_isk = &l:iskeyword
- exe 'syn include @rst'.code.' syntax/'.code.'.vim'
- exe 'syn region rstDirective'.code.' matchgroup=rstDirective fold'
- \.' start=#\%(sourcecode\|code\%(-block\)\=\)::\s\+'.code.'\_s*\n\ze\z(\s\+\)#'
+ let s:alias_pattern = ''
+ \.'\%('
+ \.join(g:rst_syntax_code_list[s:filetype], '\|')
+ \.'\)'
+
+ exe 'syn include @rst'.s:filetype.' syntax/'.s:filetype.'.vim'
+ exe 'syn region rstDirective'.s:filetype
+ \.' matchgroup=rstDirective fold'
+ \.' start="\c\%(sourcecode\|code\%(-block\)\=\)::\s\+'.s:alias_pattern.'\_s*\n\ze\z(\s\+\)"'
\.' skip=#^$#'
\.' end=#^\z1\@!#'
- \.' contains=@NoSpell,@rst'.code
- exe 'syn cluster rstDirectives add=rstDirective'.code
+ \.' contains=@NoSpell,@rst'.s:filetype
+ exe 'syn cluster rstDirectives add=rstDirective'.s:filetype
+
" reset 'isk' setting, if it has been changed
if &l:iskeyword !=# prior_isk
let &l:iskeyword = prior_isk
@@ -169,6 +230,9 @@ for code in g:rst_syntax_code_list
unlet! prior_isk
endfor
+" Enable top level spell checking
+syntax spell toplevel
+
" TODO: Use better syncing.
syn sync minlines=50 linebreaks=2
@@ -189,8 +253,6 @@ hi def link rstHyperlinkTarget String
hi def link rstExDirective String
hi def link rstSubstitutionDefinition rstDirective
hi def link rstDelimiter Delimiter
-hi def rstEmphasis ctermfg=13 term=italic cterm=italic gui=italic
-hi def rstStrongEmphasis ctermfg=1 term=bold cterm=bold gui=bold
hi def link rstInterpretedTextOrHyperlinkReference Identifier
hi def link rstInlineLiteral String
hi def link rstSubstitutionReference PreProc
@@ -200,6 +262,14 @@ hi def link rstCitationReference Identifier
hi def link rstHyperLinkReference Identifier
hi def link rstStandaloneHyperlink Identifier
hi def link rstCodeBlock String
+if exists('g:rst_use_emphasis_colors')
+ " TODO: Less arbitrary color selection
+ hi def rstEmphasis ctermfg=13 term=italic cterm=italic gui=italic
+ hi def rstStrongEmphasis ctermfg=1 term=bold cterm=bold gui=bold
+else
+ hi def rstEmphasis term=italic cterm=italic gui=italic
+ hi def rstStrongEmphasis term=bold cterm=bold gui=bold
+endif
let b:current_syntax = "rst"