mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Leave only filetype detect for context, closes #575
This commit is contained in:
@@ -1,188 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'context') == -1
|
|
||||||
|
|
||||||
" Language: ConTeXt typesetting engine
|
|
||||||
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
|
||||||
" Latest Revision: 2016 Oct 21
|
|
||||||
|
|
||||||
let s:keepcpo= &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Helper functions {{{
|
|
||||||
function! s:context_echo(message, mode)
|
|
||||||
redraw
|
|
||||||
echo "\r"
|
|
||||||
execute 'echohl' a:mode
|
|
||||||
echomsg '[ConTeXt]' a:message
|
|
||||||
echohl None
|
|
||||||
endf
|
|
||||||
|
|
||||||
function! s:sh()
|
|
||||||
return has('win32') || has('win64') || has('win16') || has('win95')
|
|
||||||
\ ? ['cmd.exe', '/C']
|
|
||||||
\ : ['/bin/sh', '-c']
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" For backward compatibility
|
|
||||||
if exists('*win_getid')
|
|
||||||
|
|
||||||
function! s:win_getid()
|
|
||||||
return win_getid()
|
|
||||||
endf
|
|
||||||
|
|
||||||
function! s:win_id2win(winid)
|
|
||||||
return win_id2win(a:winid)
|
|
||||||
endf
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
function! s:win_getid()
|
|
||||||
return winnr()
|
|
||||||
endf
|
|
||||||
|
|
||||||
function! s:win_id2win(winnr)
|
|
||||||
return a:winnr
|
|
||||||
endf
|
|
||||||
|
|
||||||
endif
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
" ConTeXt jobs {{{
|
|
||||||
if has('job')
|
|
||||||
|
|
||||||
let g:context_jobs = []
|
|
||||||
|
|
||||||
" Print the status of ConTeXt jobs
|
|
||||||
function! context#job_status()
|
|
||||||
let l:jobs = filter(g:context_jobs, 'job_status(v:val) == "run"')
|
|
||||||
let l:n = len(l:jobs)
|
|
||||||
call s:context_echo(
|
|
||||||
\ 'There '.(l:n == 1 ? 'is' : 'are').' '.(l:n == 0 ? 'no' : l:n)
|
|
||||||
\ .' job'.(l:n == 1 ? '' : 's').' running'
|
|
||||||
\ .(l:n == 0 ? '.' : ' (' . join(l:jobs, ', ').').'),
|
|
||||||
\ 'ModeMsg')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Stop all ConTeXt jobs
|
|
||||||
function! context#stop_jobs()
|
|
||||||
let l:jobs = filter(g:context_jobs, 'job_status(v:val) == "run"')
|
|
||||||
for job in l:jobs
|
|
||||||
call job_stop(job)
|
|
||||||
endfor
|
|
||||||
sleep 1
|
|
||||||
let l:tmp = []
|
|
||||||
for job in l:jobs
|
|
||||||
if job_status(job) == "run"
|
|
||||||
call add(l:tmp, job)
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
let g:context_jobs = l:tmp
|
|
||||||
if empty(g:context_jobs)
|
|
||||||
call s:context_echo('Done. No jobs running.', 'ModeMsg')
|
|
||||||
else
|
|
||||||
call s:context_echo('There are still some jobs running. Please try again.', 'WarningMsg')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! context#callback(path, job, status)
|
|
||||||
if index(g:context_jobs, a:job) != -1 && job_status(a:job) != 'run' " just in case
|
|
||||||
call remove(g:context_jobs, index(g:context_jobs, a:job))
|
|
||||||
endif
|
|
||||||
call s:callback(a:path, a:job, a:status)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! context#close_cb(channel)
|
|
||||||
call job_status(ch_getjob(a:channel)) " Trigger exit_cb's callback for faster feedback
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:typeset(path)
|
|
||||||
call add(g:context_jobs,
|
|
||||||
\ job_start(add(s:sh(), context#command() . ' ' . shellescape(fnamemodify(a:path, ":t"))), {
|
|
||||||
\ 'close_cb' : 'context#close_cb',
|
|
||||||
\ 'exit_cb' : function(get(b:, 'context_callback', get(g:, 'context_callback', 'context#callback')),
|
|
||||||
\ [a:path]),
|
|
||||||
\ 'in_io' : 'null'
|
|
||||||
\ }))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
else " No jobs
|
|
||||||
|
|
||||||
function! context#job_status()
|
|
||||||
call s:context_echo('Not implemented', 'WarningMsg')
|
|
||||||
endfunction!
|
|
||||||
|
|
||||||
function! context#stop_jobs()
|
|
||||||
call s:context_echo('Not implemented', 'WarningMsg')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! context#callback(path, job, status)
|
|
||||||
call s:callback(a:path, a:job, a:status)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! s:typeset(path)
|
|
||||||
execute '!' . context#command() . ' ' . shellescape(fnamemodify(a:path, ":t"))
|
|
||||||
call call(get(b:, 'context_callback', get(g:, 'context_callback', 'context#callback')),
|
|
||||||
\ [a:path, 0, v:shell_error])
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
endif " has('job')
|
|
||||||
|
|
||||||
function! s:callback(path, job, status) abort
|
|
||||||
if a:status < 0 " Assume the job was terminated
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
" Get info about the current window
|
|
||||||
let l:winid = s:win_getid() " Save window id
|
|
||||||
let l:efm = &l:errorformat " Save local errorformat
|
|
||||||
let l:cwd = fnamemodify(getcwd(), ":p") " Save local working directory
|
|
||||||
" Set errorformat to parse ConTeXt errors
|
|
||||||
execute 'setl efm=' . escape(b:context_errorformat, ' ')
|
|
||||||
try " Set cwd to expand error file correctly
|
|
||||||
execute 'lcd' fnameescape(fnamemodify(a:path, ':h'))
|
|
||||||
catch /.*/
|
|
||||||
execute 'setl efm=' . escape(l:efm, ' ')
|
|
||||||
throw v:exception
|
|
||||||
endtry
|
|
||||||
try
|
|
||||||
execute 'cgetfile' fnameescape(fnamemodify(a:path, ':r') . '.log')
|
|
||||||
botright cwindow
|
|
||||||
finally " Restore cwd and errorformat
|
|
||||||
execute s:win_id2win(l:winid) . 'wincmd w'
|
|
||||||
execute 'lcd ' . fnameescape(l:cwd)
|
|
||||||
execute 'setl efm=' . escape(l:efm, ' ')
|
|
||||||
endtry
|
|
||||||
if a:status == 0
|
|
||||||
call s:context_echo('Success!', 'ModeMsg')
|
|
||||||
else
|
|
||||||
call s:context_echo('There are errors. ', 'ErrorMsg')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! context#command()
|
|
||||||
return get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun'))
|
|
||||||
\ . ' --script context --autogenerate --nonstopmode'
|
|
||||||
\ . ' --synctex=' . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0')
|
|
||||||
\ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', ''))
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Accepts an optional path (useful for big projects, when the file you are
|
|
||||||
" editing is not the project's root document). If no argument is given, uses
|
|
||||||
" the path of the current buffer.
|
|
||||||
function! context#typeset(...) abort
|
|
||||||
let l:path = fnamemodify(strlen(a:000[0]) > 0 ? a:1 : expand("%"), ":p")
|
|
||||||
let l:cwd = fnamemodify(getcwd(), ":p") " Save local working directory
|
|
||||||
call s:context_echo('Typesetting...', 'ModeMsg')
|
|
||||||
execute 'lcd' fnameescape(fnamemodify(l:path, ":h"))
|
|
||||||
try
|
|
||||||
call s:typeset(l:path)
|
|
||||||
finally " Restore local working directory
|
|
||||||
execute 'lcd ' . fnameescape(l:cwd)
|
|
||||||
endtry
|
|
||||||
endfunction!
|
|
||||||
"}}}
|
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
|
|
||||||
" vim: sw=2 fdm=marker
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'context') == -1
|
|
||||||
|
|
||||||
" Vim compiler file
|
|
||||||
" Compiler: ConTeXt typesetting engine
|
|
||||||
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
|
||||||
" Last Change: 2016 Oct 21
|
|
||||||
|
|
||||||
if exists("current_compiler")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let s:keepcpo= &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
|
|
||||||
command -nargs=* CompilerSet setlocal <args>
|
|
||||||
endif
|
|
||||||
|
|
||||||
" If makefile exists and we are not asked to ignore it, we use standard make
|
|
||||||
" (do not redefine makeprg)
|
|
||||||
if get(b:, 'context_ignore_makefile', get(g:, 'context_ignore_makefile', 0)) ||
|
|
||||||
\ (!filereadable('Makefile') && !filereadable('makefile'))
|
|
||||||
let current_compiler = 'context'
|
|
||||||
" The following assumes that the current working directory is set to the
|
|
||||||
" directory of the file to be typeset
|
|
||||||
let &l:makeprg = get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun'))
|
|
||||||
\ . ' --script context --autogenerate --nonstopmode --synctex='
|
|
||||||
\ . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0')
|
|
||||||
\ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', ''))
|
|
||||||
\ . ' ' . shellescape(expand('%:p:t'))
|
|
||||||
else
|
|
||||||
let current_compiler = 'make'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:context_errorformat = ''
|
|
||||||
\ . '%-Popen source%.%#> %f,'
|
|
||||||
\ . '%-Qclose source%.%#> %f,'
|
|
||||||
\ . "%-Popen source%.%#name '%f',"
|
|
||||||
\ . "%-Qclose source%.%#name '%f',"
|
|
||||||
\ . '%Etex %trror%.%#mp error on line %l in file %f:%.%#,'
|
|
||||||
\ . 'tex %trror%.%#error on line %l in file %f: %m,'
|
|
||||||
\ . '%Elua %trror%.%#error on line %l in file %f:,'
|
|
||||||
\ . '%+Emetapost %#> error: %#,'
|
|
||||||
\ . '! error: %#%m,'
|
|
||||||
\ . '%-C %#,'
|
|
||||||
\ . '%C! %m,'
|
|
||||||
\ . '%Z[ctxlua]%m,'
|
|
||||||
\ . '%+C<*> %.%#,'
|
|
||||||
\ . '%-C%.%#,'
|
|
||||||
\ . '%Z...%m,'
|
|
||||||
\ . '%-Zno-error,'
|
|
||||||
\ . '%-G%.%#' " Skip remaining lines
|
|
||||||
|
|
||||||
execute 'CompilerSet errorformat=' . escape(b:context_errorformat, ' ')
|
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'context') == -1
|
|
||||||
|
|
||||||
" Vim filetype plugin file
|
|
||||||
" Language: ConTeXt typesetting engine
|
|
||||||
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
|
||||||
" Former Maintainers: Nikolai Weibull <now@bitwi.se>
|
|
||||||
" Latest Revision: 2016 Oct 30
|
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let b:did_ftplugin = 1
|
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
if !exists('current_compiler')
|
|
||||||
compiler context
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo< ofu<"
|
|
||||||
\ . "| unlet! b:match_ignorecase b:match_words b:match_skip"
|
|
||||||
|
|
||||||
setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tjcroql2
|
|
||||||
if get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
|
|
||||||
setlocal omnifunc=contextcomplete#Complete
|
|
||||||
let g:omni_syntax_group_include_context = 'mf\w\+,mp\w\+'
|
|
||||||
let g:omni_syntax_group_exclude_context = 'mfTodoComment'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let &l:define='\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\='
|
|
||||||
\ . 'def\|\\font\|\\\%(future\)\=let'
|
|
||||||
\ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
|
|
||||||
\ . '\|fam\|insert\|if\)'
|
|
||||||
|
|
||||||
let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'
|
|
||||||
|
|
||||||
setlocal suffixesadd=.tex
|
|
||||||
|
|
||||||
if exists("loaded_matchit")
|
|
||||||
let b:match_ignorecase = 0
|
|
||||||
let b:match_skip = 'r:\\\@<!\%(\\\\\)*%'
|
|
||||||
let b:match_words = '(:),\[:],{:},\\(:\\),\\\[:\\],' .
|
|
||||||
\ '\\start\(\a\+\):\\stop\1'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let s:context_regex = {
|
|
||||||
\ 'beginsection' : '\\\%(start\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
|
|
||||||
\ 'endsection' : '\\\%(stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>',
|
|
||||||
\ 'beginblock' : '\\\%(start\|setup\|define\)',
|
|
||||||
\ 'endblock' : '\\\%(stop\|setup\|define\)'
|
|
||||||
\ }
|
|
||||||
|
|
||||||
function! s:move_around(count, what, flags, visual)
|
|
||||||
if a:visual
|
|
||||||
exe "normal! gv"
|
|
||||||
endif
|
|
||||||
call search(s:context_regex[a:what], a:flags.'s') " 's' sets previous context mark
|
|
||||||
call map(range(2, a:count), 'search(s:context_regex[a:what], a:flags)')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Move around macros.
|
|
||||||
nnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:false) <CR>
|
|
||||||
vnoremap <silent><buffer> [[ :<C-U>call <SID>move_around(v:count1, "beginsection", "bW", v:true) <CR>
|
|
||||||
nnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:false) <CR>
|
|
||||||
vnoremap <silent><buffer> ]] :<C-U>call <SID>move_around(v:count1, "beginsection", "W", v:true) <CR>
|
|
||||||
nnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:false) <CR>
|
|
||||||
vnoremap <silent><buffer> [] :<C-U>call <SID>move_around(v:count1, "endsection", "bW", v:true) <CR>
|
|
||||||
nnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:false) <CR>
|
|
||||||
vnoremap <silent><buffer> ][ :<C-U>call <SID>move_around(v:count1, "endsection", "W", v:true) <CR>
|
|
||||||
nnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:false) <CR>
|
|
||||||
vnoremap <silent><buffer> [{ :<C-U>call <SID>move_around(v:count1, "beginblock", "bW", v:true) <CR>
|
|
||||||
nnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:false) <CR>
|
|
||||||
vnoremap <silent><buffer> ]} :<C-U>call <SID>move_around(v:count1, "endblock", "W", v:true) <CR>
|
|
||||||
|
|
||||||
" Other useful mappings
|
|
||||||
if get(g:, 'context_mappings', 1)
|
|
||||||
let s:tp_regex = '?^$\|^\s*\\\(item\|start\|stop\|blank\|\%(sub\)*section\|chapter\|\%(sub\)*subject\|title\|part\)'
|
|
||||||
|
|
||||||
fun! s:tp()
|
|
||||||
call cursor(search(s:tp_regex, 'bcW') + 1, 1)
|
|
||||||
normal! V
|
|
||||||
call cursor(search(s:tp_regex, 'W') - 1, 1)
|
|
||||||
endf
|
|
||||||
|
|
||||||
" Reflow paragraphs with commands like gqtp ("gq TeX paragraph")
|
|
||||||
onoremap <silent><buffer> tp :<c-u>call <sid>tp()<cr>
|
|
||||||
" Select TeX paragraph
|
|
||||||
vnoremap <silent><buffer> tp <esc>:<c-u>call <sid>tp()<cr>
|
|
||||||
|
|
||||||
" $...$ text object
|
|
||||||
onoremap <silent><buffer> i$ :<c-u>normal! T$vt$<cr>
|
|
||||||
onoremap <silent><buffer> a$ :<c-u>normal! F$vf$<cr>
|
|
||||||
vnoremap <buffer> i$ T$ot$
|
|
||||||
vnoremap <buffer> a$ F$of$
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Commands for asynchronous typesetting
|
|
||||||
command! -buffer -nargs=? -complete=file ConTeXt call context#typeset(<q-args>)
|
|
||||||
command! -nargs=0 ConTeXtJobStatus call context#job_status()
|
|
||||||
command! -nargs=0 ConTeXtStopJobs call context#stop_jobs()
|
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
|
||||||
unlet s:cpo_save
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'context') == -1
|
|
||||||
|
|
||||||
" ConTeXt indent file
|
|
||||||
" Language: ConTeXt typesetting engine
|
|
||||||
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
|
||||||
" Last Change: 2016 Oct 15
|
|
||||||
|
|
||||||
if exists("b:did_indent")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Load MetaPost indentation script
|
|
||||||
runtime! indent/mp.vim
|
|
||||||
|
|
||||||
let s:keepcpo= &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
setlocal indentexpr=GetConTeXtIndent()
|
|
||||||
|
|
||||||
let b:undo_indent = "setl indentexpr<"
|
|
||||||
|
|
||||||
function! GetConTeXtIndent()
|
|
||||||
" Use MetaPost rules inside MetaPost graphic environments
|
|
||||||
if len(synstack(v:lnum, 1)) > 0 &&
|
|
||||||
\ synIDattr(synstack(v:lnum, 1)[0], "name") ==# 'contextMPGraphic'
|
|
||||||
return GetMetaPostIndent()
|
|
||||||
endif
|
|
||||||
return -1
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
|
|
||||||
" vim:sw=2
|
|
||||||
|
|
||||||
endif
|
|
||||||
@@ -5530,8 +5530,6 @@ filetypes:
|
|||||||
description: X PixMap 2
|
description: X PixMap 2
|
||||||
---
|
---
|
||||||
name: context
|
name: context
|
||||||
remote: vim/vim:runtime
|
|
||||||
glob: "**/context.vim"
|
|
||||||
filetypes:
|
filetypes:
|
||||||
- name: context
|
- name: context
|
||||||
patterns:
|
patterns:
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'context') == -1
|
|
||||||
|
|
||||||
" Vim syntax file
|
|
||||||
" Language: ConTeXt typesetting engine
|
|
||||||
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
|
||||||
" Former Maintainers: Nikolai Weibull <now@bitwi.se>
|
|
||||||
" Latest Revision: 2016 Oct 16
|
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
runtime! syntax/plaintex.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP.
|
|
||||||
let s:context_include = get(b:, 'context_include', get(g:, 'context_include', {'xml': 'XML'}))
|
|
||||||
|
|
||||||
" For backward compatibility (g:context_include used to be a List)
|
|
||||||
if type(s:context_include) ==# type([])
|
|
||||||
let g:context_metapost = (index(s:context_include, 'mp') != -1)
|
|
||||||
let s:context_include = filter(
|
|
||||||
\ {'c': 'C', 'javascript': 'JS', 'ruby': 'Ruby', 'xml': 'XML'},
|
|
||||||
\ { k,_ -> index(s:context_include, k) != -1 }
|
|
||||||
\ )
|
|
||||||
endif
|
|
||||||
|
|
||||||
syn iskeyword @,48-57,a-z,A-Z,192-255
|
|
||||||
|
|
||||||
syn spell toplevel
|
|
||||||
|
|
||||||
" ConTeXt options, i.e., [...] blocks
|
|
||||||
syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell
|
|
||||||
|
|
||||||
" Highlight braces
|
|
||||||
syn match contextDelimiter '[{}]'
|
|
||||||
|
|
||||||
" Comments
|
|
||||||
syn match contextComment '\\\@<!\%(\\\\\)*\zs%.*$' display contains=initexTodo
|
|
||||||
syn match contextComment '^\s*%[CDM].*$' display contains=initexTodo
|
|
||||||
|
|
||||||
syn match contextBlockDelim '\\\%(start\|stop\)\a\+' contains=@NoSpell
|
|
||||||
|
|
||||||
syn region contextEscaped matchgroup=contextPreProc start='\\type\%(\s*\|\n\)*\z([^A-Za-z%]\)' end='\z1'
|
|
||||||
syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s\|\n\)*{' end='}'
|
|
||||||
syn region contextEscaped matchgroup=contextPreProc start='\\type\=\%(\s*\|\n\)*<<' end='>>'
|
|
||||||
syn region contextEscaped matchgroup=contextPreProc
|
|
||||||
\ start='\\start\z(\a*\%(typing\|typen\)\)'
|
|
||||||
\ end='\\stop\z1' contains=plaintexComment keepend
|
|
||||||
syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}'
|
|
||||||
syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}'
|
|
||||||
|
|
||||||
syn match contextBuiltin display contains=@NoSpell
|
|
||||||
\ '\\\%(unprotect\|protect\|unexpanded\)\>'
|
|
||||||
|
|
||||||
syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
|
|
||||||
if get(b:, 'context_metapost', get(g:, 'context_metapost', 1))
|
|
||||||
let b:mp_metafun_macros = 1 " Highlight MetaFun keywords
|
|
||||||
syn include @mpTop syntax/mp.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
|
|
||||||
syn region contextMPGraphic matchgroup=contextBlockDelim
|
|
||||||
\ start='\\start\z(MP\%(clip\|code\|definitions\|drawing\|environment\|extensions\|inclusions\|initializations\|page\|\)\)\>.*$'
|
|
||||||
\ end='\\stop\z1'
|
|
||||||
\ contains=@mpTop,@NoSpell
|
|
||||||
syn region contextMPGraphic matchgroup=contextBlockDelim
|
|
||||||
\ start='\\start\z(\%(\%[re]usable\|use\|unique\|static\)MPgraphic\|staticMPfigure\|uniqueMPpagegraphic\)\>.*$'
|
|
||||||
\ end='\\stop\z1'
|
|
||||||
\ contains=@mpTop,@NoSpell
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get(b:, 'context_lua', get(g:, 'context_lua', 1))
|
|
||||||
syn include @luaTop syntax/lua.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
|
|
||||||
syn region contextLuaCode matchgroup=contextBlockDelim
|
|
||||||
\ start='\\startluacode\>'
|
|
||||||
\ end='\\stopluacode\>' keepend
|
|
||||||
\ contains=@luaTop,@NoSpell
|
|
||||||
|
|
||||||
syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\="
|
|
||||||
\ nextgroup=contextBeginEndLua skipwhite skipempty
|
|
||||||
\ contains=initexComment
|
|
||||||
syn region contextBeginEndLua matchgroup=contextSpecial
|
|
||||||
\ start="{" end="}" skip="\\[{}]"
|
|
||||||
\ contained contains=@luaTop,@NoSpell
|
|
||||||
endif
|
|
||||||
|
|
||||||
for synname in keys(s:context_include)
|
|
||||||
execute 'syn include @' . synname . 'Top' 'syntax/' . synname . '.vim'
|
|
||||||
unlet b:current_syntax
|
|
||||||
execute 'syn region context' . s:context_include[synname] . 'Code'
|
|
||||||
\ 'matchgroup=contextBlockDelim'
|
|
||||||
\ 'start=+\\start' . s:context_include[synname] . '+'
|
|
||||||
\ 'end=+\\stop' . s:context_include[synname] . '+'
|
|
||||||
\ 'contains=@' . synname . 'Top,@NoSpell'
|
|
||||||
endfor
|
|
||||||
|
|
||||||
syn match contextSectioning '\\\%(start\|stop\)\=\%(\%(sub\)*section\|\%(sub\)*subject\|chapter\|part\|component\|product\|title\)\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
|
|
||||||
syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
syn match contextSpecial /\\[`'"]/
|
|
||||||
syn match contextSpecial +\\char\%(\d\{1,3}\|'\o\{1,3}\|"\x\{1,2}\)\>+
|
|
||||||
\ contains=@NoSpell
|
|
||||||
syn match contextSpecial '\^\^.'
|
|
||||||
syn match contextSpecial '`\%(\\.\|\^\^.\|.\)'
|
|
||||||
|
|
||||||
syn match contextStyle '\\\%(em\|ss\|hw\|cg\|mf\)\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
syn match contextFont '\\\%(CAP\|Cap\|cap\|Caps\|kap\|nocap\)\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
syn match contextFont '\\\%(Word\|WORD\|Words\|WORDS\)\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
|
|
||||||
\ contains=@NoSpell
|
|
||||||
|
|
||||||
hi def link contextOptions Typedef
|
|
||||||
hi def link contextComment Comment
|
|
||||||
hi def link contextBlockDelim Keyword
|
|
||||||
hi def link contextBuiltin Keyword
|
|
||||||
hi def link contextDelimiter Delimiter
|
|
||||||
hi def link contextEscaped String
|
|
||||||
hi def link contextPreProc PreProc
|
|
||||||
hi def link contextSectioning PreProc
|
|
||||||
hi def link contextSpecial Special
|
|
||||||
hi def link contextType Type
|
|
||||||
hi def link contextStyle contextType
|
|
||||||
hi def link contextFont contextType
|
|
||||||
hi def link contextDirectLua Keyword
|
|
||||||
|
|
||||||
let b:current_syntax = "context"
|
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
|
||||||
unlet s:cpo_save
|
|
||||||
|
|
||||||
endif
|
|
||||||
Reference in New Issue
Block a user