summaryrefslogtreecommitdiffstats
path: root/runtime/syntax
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-28 22:58:02 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-28 22:58:02 +0200
commitfc65cabb15d0236bce001ad78e12a40511caf941 (patch)
tree071cd16ce17e02121ac1c7db7c7518cc70f10a79 /runtime/syntax
parent627cb6a6b37d17433fe2d7df1f287eefb5b370e3 (diff)
Update runtime files.
Diffstat (limited to 'runtime/syntax')
-rw-r--r--runtime/syntax/r.vim32
-rw-r--r--runtime/syntax/rmd.vim179
-rw-r--r--runtime/syntax/rnoweb.vim4
-rw-r--r--runtime/syntax/rrst.vim4
-rw-r--r--runtime/syntax/sudoers.vim70
5 files changed, 165 insertions, 124 deletions
diff --git a/runtime/syntax/r.vim b/runtime/syntax/r.vim
index 45ff498b3b..9e25dae363 100644
--- a/runtime/syntax/r.vim
+++ b/runtime/syntax/r.vim
@@ -5,7 +5,7 @@
" Tom Payne <tom@tompayne.org>
" Contributor: Johannes Ranke <jranke@uni-bremen.de>
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Sat Apr 08, 2017 07:01PM
+" Last Change: Wed Aug 01, 2018 10:10PM
" Filenames: *.R *.r *.Rhistory *.Rt
"
" NOTE: The highlighting of R functions might be defined in
@@ -43,15 +43,17 @@ endif
if exists("g:r_syntax_folding") && g:r_syntax_folding
setlocal foldmethod=syntax
endif
-if !exists("g:r_syntax_hl_roxygen")
- let g:r_syntax_hl_roxygen = 1
-endif
+
+let g:r_syntax_hl_roxygen = get(g:, 'r_syntax_hl_roxygen', 1)
syn case match
" Comment
syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):"
-syn match rComment contains=@Spell,rCommentTodo,rOBlock "#.*"
+syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent
+syn keyword rTodoKeyw BUG FIXME NOTE TODO contained
+syn match rTodoInfo "(\zs.\{-}\ze)" contained
+syn match rComment contains=@Spell,rCommentTodo,rTodoParen,rOBlock "#.*"
" Roxygen
if g:r_syntax_hl_roxygen
@@ -65,7 +67,7 @@ if g:r_syntax_hl_roxygen
" First we match all roxygen blocks as containing only a title. In case an
" empty roxygen line ending the title or a tag is found, this will be
- " overriden later by the definitions of rOBlock.
+ " overridden later by the definitions of rOBlock.
syn match rOTitleBlock "\%^\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
syn match rOTitleBlock "^\s*\n\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag
@@ -91,7 +93,7 @@ if g:r_syntax_hl_roxygen
syn match rOTitle "^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag
syn match rOTitleTag contained "@title"
- syn match rOCommentKey "#\{1,2}'" contained
+ syn match rOCommentKey "^\s*#\{1,2}'" contained
syn region rOExamples start="^#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold
" rOTag list generated from the lists in
@@ -256,6 +258,7 @@ if exists("g:r_syntax_folding")
syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold
syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError fold
syn region rRegion matchgroup=Delimiter start=/\[/ matchgroup=Delimiter end=/]/ transparent contains=ALLBUT,rError,rCurlyError,rParenError fold
+ syn region rSection matchgroup=Title start=/^#.*[-=#]\{4,}/ end=/^#.*[-=#]\{4,}/ms=s-2,me=s-1 transparent contains=ALL fold
else
syn region rRegion matchgroup=Delimiter start=/(/ matchgroup=Delimiter end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError
syn region rRegion matchgroup=Delimiter start=/{/ matchgroup=Delimiter end=/}/ transparent contains=ALLBUT,rError,rBraceError,rParenError
@@ -282,13 +285,8 @@ endif
if g:r_syntax_fun_pattern == 1
syn match rFunction '[0-9a-zA-Z_\.]\+\s*\ze('
else
- if !exists("g:R_hi_fun")
- let g:R_hi_fun = 1
- endif
- if g:R_hi_fun
- " Nvim-R:
- runtime R/functions.vim
- endif
+ " Nvim-R:
+ runtime R/functions.vim
endif
syn match rDollar display contained "\$"
@@ -311,7 +309,7 @@ syn keyword rType array category character complex double function integer list
" Name of object with spaces
if &filetype != "rmd" && &filetype != "rrst"
- syn region rNameWSpace start="`" end="`"
+ syn region rNameWSpace start="`" end="`" contains=rSpaceFun
endif
if &filetype == "rhelp"
@@ -331,7 +329,10 @@ hi def link rAssign Statement
hi def link rBoolean Boolean
hi def link rBraceError Error
hi def link rComment Comment
+hi def link rTodoParen Comment
+hi def link rTodoInfo SpecialComment
hi def link rCommentTodo Todo
+hi def link rTodoKeyw Todo
hi def link rComplex Number
hi def link rConditional Conditional
hi def link rConstant Constant
@@ -341,6 +342,7 @@ hi def link rDollar SpecialChar
hi def link rError Error
hi def link rFloat Float
hi def link rFunction Function
+hi def link rSpaceFun Function
hi def link rHelpIdent Identifier
hi def link rhPreProc PreProc
hi def link rhSection PreCondit
diff --git a/runtime/syntax/rmd.vim b/runtime/syntax/rmd.vim
index 05435354ad..a26389024d 100644
--- a/runtime/syntax/rmd.vim
+++ b/runtime/syntax/rmd.vim
@@ -1,123 +1,118 @@
" markdown Text with R statements
" Language: markdown with R code chunks
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Sat Jan 28, 2017 10:06PM
-"
-" CONFIGURATION:
-" To highlight chunk headers as R code, put in your vimrc (e.g. .config/nvim/init.vim):
-" let rmd_syn_hl_chunk = 1
+" Last Change: Sat Aug 25, 2018 03:44PM
"
" For highlighting pandoc extensions to markdown like citations and TeX and
" many other advanced features like folding of markdown sections, it is
" recommended to install the vim-pandoc filetype plugin as well as the
" vim-pandoc-syntax filetype plugin from https://github.com/vim-pandoc.
-"
-" TODO:
-" - Provide highlighting for rmarkdown parameters in yaml header
+
if exists("b:current_syntax")
finish
endif
-" load all of pandoc info, e.g. from
+" Configuration if not using pandoc syntax:
+" Add syntax highlighting of YAML header
+let g:rmd_syn_hl_yaml = get(g:, 'rmd_syn_hl_yaml', 1)
+" Add syntax highlighting of citation keys
+let g:rmd_syn_hl_citations = get(g:, 'rmd_syn_hl_citations', 1)
+" Highlight the header of the chunk of R code
+let g:rmd_syn_hl_chunk = get(g:, 'g:rmd_syn_hl_chunk', 0)
+
+" Pandoc-syntax has more features, but it is slower.
" https://github.com/vim-pandoc/vim-pandoc-syntax
+let g:pandoc#syntax#codeblocks#embeds#langs = get(g:, 'pandoc#syntax#codeblocks#embeds#langs', ['r'])
runtime syntax/pandoc.vim
if exists("b:current_syntax")
- let rmdIsPandoc = 1
- unlet b:current_syntax
-else
- let rmdIsPandoc = 0
- runtime syntax/markdown.vim
- if exists("b:current_syntax")
- unlet b:current_syntax
- endif
-
- " load all of the yaml syntax highlighting rules into @yaml
- syntax include @yaml syntax/yaml.vim
- if exists("b:current_syntax")
- unlet b:current_syntax
- endif
-
- " highlight yaml block commonly used for front matter
- syntax region rmdYamlBlock matchgroup=rmdYamlBlockDelim start="^---" matchgroup=rmdYamlBlockDelim end="^---" contains=@yaml keepend fold
+ " Fix recognition of R code
+ syn region pandocDelimitedCodeBlock_r start=/^```{r\>.*}$/ end=/^```$/ contained containedin=pandocDelimitedCodeBlock contains=@R
+ syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend
+ hi def link rmdInlineDelim Delimiter
+ let b:current_syntax = "rmd"
+ finish
endif
-if !exists("g:rmd_syn_langs")
- let g:rmd_syn_langs = ["r"]
-else
- let s:hasr = 0
- for s:lng in g:rmd_syn_langs
- if s:lng == "r"
- let s:hasr = 1
- endif
- endfor
- if s:hasr == 0
- let g:rmd_syn_langs += ["r"]
+let s:cpo_save = &cpo
+set cpo&vim
+
+" R chunks will not be highlighted by syntax/markdown because their headers
+" follow a non standard pattern: "```{lang" instead of "^```lang".
+" Make a copy of g:markdown_fenced_languages to highlight the chunks later:
+if exists('g:markdown_fenced_languages')
+ if !exists('g:rmd_fenced_languages')
+ let g:rmd_fenced_languages = deepcopy(g:markdown_fenced_languages)
+ let g:markdown_fenced_languages = []
endif
+else
+ let g:rmd_fenced_languages = ['r']
endif
-for s:lng in g:rmd_syn_langs
- exe 'syntax include @' . toupper(s:lng) . ' syntax/'. s:lng . '.vim'
- if exists("b:current_syntax")
- unlet b:current_syntax
- endif
- exe 'syntax region rmd' . toupper(s:lng) . 'Chunk start="^[ \t]*``` *{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\).*}$" end="^[ \t]*```$" contains=@' . toupper(s:lng) . ',rmd' . toupper(s:lng) . 'ChunkDelim keepend fold'
+runtime syntax/markdown.vim
- if exists("g:rmd_syn_hl_chunk") && s:lng == "r"
- " highlight R code inside chunk header
- syntax match rmdRChunkDelim "^[ \t]*```{r" contained
- syntax match rmdRChunkDelim "}$" contained
+" Now highlight chunks:
+for s:type in g:rmd_fenced_languages
+ if s:type =~ '='
+ let s:lng = substitute(s:type, '=.*', '')
+ let s:nm = substitute(s:type, '.*=', '')
else
- exe 'syntax match rmd' . toupper(s:lng) . 'ChunkDelim "^[ \t]*```{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\).*}$" contained'
+ let s:lng = s:type
+ let s:nm = s:type
endif
- exe 'syntax match rmd' . toupper(s:lng) . 'ChunkDelim "^[ \t]*```$" contained'
-endfor
-
-
-" also match and syntax highlight in-line R code
-syntax region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend
-" I was not able to highlight rmdrInline inside a pandocLaTeXCommand, although
-" highlighting works within pandocLaTeXRegion and yamlFlowString.
-syntax cluster texMathZoneGroup add=rmdrInline
-
-" match slidify special marker
-syntax match rmdSlidifySpecial "\*\*\*"
-
-
-if rmdIsPandoc == 0
- syn match rmdBlockQuote /^\s*>.*\n\(.*\n\@<!\n\)*/ skipnl
- " LaTeX
- syntax include @LaTeX syntax/tex.vim
- if exists("b:current_syntax")
- unlet b:current_syntax
+ unlet! b:current_syntax
+ exe 'syn include @Rmd'.s:nm.' syntax/'.s:lng.'.vim'
+ if g:rmd_syn_hl_chunk
+ exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@Rmd'.s:nm
+ exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=rmd'.s:nm.'ChunkDelim,@Rmd'.s:nm
+ else
+ exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@Rmd'.s:nm
endif
- " Inline
- syntax match rmdLaTeXInlDelim "\$"
- syntax match rmdLaTeXInlDelim "\\\$"
- syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup
- " Region
- syntax match rmdLaTeXRegDelim "\$\$" contained
- syntax match rmdLaTeXRegDelim "\$\$latex$" contained
- syntax match rmdLaTeXSt "\\[a-zA-Z]\+"
- syntax region rmdLaTeXRegion start="^\$\$" skip="\\\$" end="\$\$$" contains=@LaTeX,rmdLaTeXRegDelim keepend
- syntax region rmdLaTeXRegion2 start="^\\\[" end="\\\]" contains=@LaTeX,rmdLaTeXRegDelim keepend
- hi def link rmdBlockQuote Comment
- hi def link rmdLaTeXSt Statement
- hi def link rmdLaTeXInlDelim Special
- hi def link rmdLaTeXRegDelim Special
-endif
-
-for s:lng in g:rmd_syn_langs
- exe 'syn sync match rmd' . toupper(s:lng) . 'SyncChunk grouphere rmd' . toupper(s:lng) . 'Chunk /^[ \t]*``` *{\(' . s:lng . '\|r.*engine\s*=\s*["' . "']" . s:lng . "['" . '"]\)/'
+ exe 'syn region rmd'.s:nm.'Inline matchgroup=rmdInlineDelim start="`'.s:nm.' " end="`" contains=@Rmd'.s:nm.' keepend'
endfor
+unlet! s:type
+
+hi def link rmdInlineDelim Delimiter
+hi def link rmdCodeDelim Delimiter
+
+" You don't need this if either your markdown/syntax.vim already highlights
+" the YAML header or you are writing standard markdown
+if g:rmd_syn_hl_yaml
+ " Minimum highlighting of yaml header
+ syn match rmdYamlFieldTtl /^\s*\zs\w*\ze:/ contained
+ syn match rmdYamlFieldTtl /^\s*-\s*\zs\w*\ze:/ contained
+ syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start='"' skip='\\"' end='"' contains=yamlEscape,rmdrInline contained
+ syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start="'" skip="''" end="'" contains=yamlSingleEscape,rmdrInline contained
+ syn match yamlEscape contained '\\\%([\\"abefnrtv\^0_ NLP\n]\|x\x\x\|u\x\{4}\|U\x\{8}\)'
+ syn match yamlSingleEscape contained "''"
+ syn region pandocYAMLHeader matchgroup=rmdYamlBlockDelim start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=rmdYamlFieldTtl,yamlFlowString
+ hi def link rmdYamlBlockDelim Delimiter
+ hi def link rmdYamlFieldTtl Identifier
+ hi def link yamlFlowString String
+endif
-hi def link rmdYamlBlockDelim Delim
-for s:lng in g:rmd_syn_langs
- exe 'hi def link rmd' . toupper(s:lng) . 'ChunkDelim Special'
-endfor
-hi def link rmdInlineDelim Special
-hi def link rmdSlidifySpecial Special
+" You don't need this if either your markdown/syntax.vim already highlights
+" citations or you are writing standard markdown
+if g:rmd_syn_hl_citations
+ " From vim-pandoc-syntax
+ " parenthetical citations
+ syn match pandocPCite /\^\@<!\[[^\[\]]\{-}-\{0,1}@[[:alnum:]_][[:alnum:]à-öø-ÿÀ-ÖØ-ß_:.#$%&\-+?<>~\/]*.\{-}\]/ contains=pandocEmphasis,pandocStrong,pandocLatex,pandocCiteKey,@Spell,pandocAmpersandEscape display
+ " in-text citations with location
+ syn match pandocICite /@[[:alnum:]_][[:alnum:]à-öø-ÿÀ-ÖØ-ß_:.#$%&\-+?<>~\/]*\s\[.\{-1,}\]/ contains=pandocCiteKey,@Spell display
+ " cite keys
+ syn match pandocCiteKey /\(-\=@[[:alnum:]_][[:alnum:]à-öø-ÿÀ-ÖØ-ß_:.#$%&\-+?<>~\/]*\)/ containedin=pandocPCite,pandocICite contains=@NoSpell display
+ syn match pandocCiteAnchor /[-@]/ contained containedin=pandocCiteKey display
+ syn match pandocCiteLocator /[\[\]]/ contained containedin=pandocPCite,pandocICite
+ hi def link pandocPCite Operator
+ hi def link pandocICite Operator
+ hi def link pandocCiteKey Label
+ hi def link pandocCiteAnchor Operator
+ hi def link pandocCiteLocator Operator
+endif
let b:current_syntax = "rmd"
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
" vim: ts=8 sw=2
diff --git a/runtime/syntax/rnoweb.vim b/runtime/syntax/rnoweb.vim
index 665acc53e2..b2ba17d68d 100644
--- a/runtime/syntax/rnoweb.vim
+++ b/runtime/syntax/rnoweb.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: R noweb Files
" Maintainer: Johannes Ranke <jranke@uni-bremen.de>
-" Last Change: Sat Feb 06, 2016 06:47AM
+" Last Change: Thu Apr 05, 2018 11:06PM
" Version: 0.9.1
" Remarks: - This file is inspired by the proposal of
" Fernando Henrique Ferraz Pereira da Rosa <feferraz@ime.usp.br>
@@ -16,7 +16,7 @@ syn case match
" Extension of Tex clusters {{{1
runtime syntax/tex.vim
-unlet b:current_syntax
+unlet! b:current_syntax
syn cluster texMatchGroup add=@rnoweb
syn cluster texMathMatchGroup add=rnowebSexpr
diff --git a/runtime/syntax/rrst.vim b/runtime/syntax/rrst.vim
index b643af3285..3a56342cd8 100644
--- a/runtime/syntax/rrst.vim
+++ b/runtime/syntax/rrst.vim
@@ -2,7 +2,7 @@
" Language: reST with R code chunks
" Maintainer: Alex Zvoleff, azvoleff@mail.sdsu.edu
" Homepage: https://github.com/jalvesaq/R-Vim-runtime
-" Last Change: Tue Jun 28, 2016 08:53AM
+" Last Change: Thu Apr 05, 2018 11:06PM
"
" CONFIGURATION:
" To highlight chunk headers as R code, put in your vimrc:
@@ -14,7 +14,7 @@ endif
" load all of the rst info
runtime syntax/rst.vim
-unlet b:current_syntax
+unlet! b:current_syntax
" load all of the r syntax highlighting rules into @R
syntax include @R syntax/r.vim
diff --git a/runtime/syntax/sudoers.vim b/runtime/syntax/sudoers.vim
index 31f5f2b7ed..019b0ada32 100644
--- a/runtime/syntax/sudoers.vim
+++ b/runtime/syntax/sudoers.vim
@@ -1,8 +1,9 @@
" Vim syntax file
" Language: sudoers(5) configuration files
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2018-07-19
+" Latest Revision: 2018-08-18
" Recent Changes: Support for #include and #includedir.
+" Added many new options (Samuel D. Leslie)
if exists("b:current_syntax")
finish
@@ -152,77 +153,120 @@ syn match sudoersDefaultTypeGreaterThan contained '>' nextgroup=@sudoersUser s
" TODO: could also deal with special characters here
syn match sudoersBooleanParameter contained '!' nextgroup=sudoersBooleanParameter skipwhite skipnl
syn keyword sudoersBooleanParameter contained skipwhite skipnl
+ \ always_query_group_plugin
\ always_set_home
\ authenticate
\ closefrom_override
+ \ compress_io
\ env_editor
\ env_reset
+ \ exec_background
+ \ fast_glob
\ fqdn
+ \ ignore_audit_errors
\ ignore_dot
+ \ ignore_iolog_errors
\ ignore_local_sudoers
+ \ ignore_logfile_errors
+ \ ignore_unknown_defaults
\ insults
\ log_host
+ \ log_input
+ \ log_output
\ log_year
\ long_otp_prompt
+ \ mail_all_cmnds
\ mail_always
\ mail_badpass
\ mail_no_host
\ mail_no_perms
\ mail_no_user
+ \ match_group_by_gid
+ \ netgroup_tuple
\ noexec
- \ path_info
+ \ pam_session
+ \ pam_setcred
\ passprompt_override
+ \ path_info
\ preserve_groups
+ \ pwfeedback
\ requiretty
\ root_sudo
\ rootpw
\ runaspw
\ set_home
\ set_logname
+ \ set_utmp
\ setenv
\ shell_noargs
\ stay_setuid
+ \ sudoedit_checkdir
+ \ sudoedit_fellow
+ \ syslog_pid
\ targetpw
\ tty_tickets
+ \ umask_override
+ \ use_netgroups
+ \ use_pty
+ \ user_command_timeouts
+ \ utmp_runas
\ visiblepw
syn keyword sudoersIntegerParameter contained
\ nextgroup=sudoersIntegerParameterEquals
\ skipwhite skipnl
\ closefrom
- \ passwd_tries
+ \ command_timeout
\ loglinelen
+ \ maxseq
\ passwd_timeout
+ \ passwd_tries
+ \ syslog_maxlen
\ timestamp_timeout
\ umask
syn keyword sudoersStringParameter contained
\ nextgroup=sudoersStringParameterEquals
\ skipwhite skipnl
+ \ askpass
\ badpass_message
\ editor
- \ mailsub
- \ noexec_file
- \ passprompt
- \ runas_default
- \ syslog_badpri
- \ syslog_goodpri
- \ sudoers_locale
- \ timestampdir
- \ timestampowner
- \ askpass
\ env_file
\ exempt_group
+ \ fdexec
+ \ group_plugin
+ \ iolog_dir
+ \ iolog_file
+ \ iolog_flush
+ \ iolog_group
+ \ iolog_mode
+ \ iolog_user
\ lecture
\ lecture_file
+ \ lecture_status_dir
\ listpw
\ logfile
\ mailerflags
\ mailerpath
\ mailfrom
+ \ mailsub
\ mailto
+ \ noexec_file
+ \ pam_login_service
+ \ pam_service
+ \ passprompt
+ \ restricted_env_file
+ \ role
+ \ runas_default
\ secure_path
+ \ sudoers_locale
\ syslog
+ \ syslog_badpri
+ \ syslog_goodpri
+ \ timestamp_type
+ \ timestampdir
+ \ timestampowner
+ \ type
\ verifypw
syn keyword sudoersListParameter contained