mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
5341967315
commit
8d3f8f639b
184
runtime/autoload/context.vim
Normal file
184
runtime/autoload/context.vim
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
" 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
|
25
runtime/autoload/contextcomplete.vim
Normal file
25
runtime/autoload/contextcomplete.vim
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
" Language: ConTeXt typesetting engine
|
||||||
|
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
||||||
|
" Latest Revision: 2016 Oct 15
|
||||||
|
|
||||||
|
let s:keepcpo= &cpo
|
||||||
|
set cpo&vim
|
||||||
|
|
||||||
|
" Complete keywords in MetaPost blocks
|
||||||
|
function! contextcomplete#Complete(findstart, base)
|
||||||
|
if a:findstart == 1
|
||||||
|
if len(synstack(line('.'), 1)) > 0 &&
|
||||||
|
\ synIDattr(synstack(line('.'), 1)[0], "name") ==# 'contextMPGraphic'
|
||||||
|
return syntaxcomplete#Complete(a:findstart, a:base)
|
||||||
|
else
|
||||||
|
return -3
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
return syntaxcomplete#Complete(a:findstart, a:base)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let &cpo = s:keepcpo
|
||||||
|
unlet s:keepcpo
|
||||||
|
|
||||||
|
" vim: sw=2 fdm=marker
|
54
runtime/compiler/context.vim
Normal file
54
runtime/compiler/context.vim
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
" 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
|
@ -54,6 +54,8 @@ right of the labels.
|
|||||||
In the GUI tab pages line you can use the right mouse button to open menu.
|
In the GUI tab pages line you can use the right mouse button to open menu.
|
||||||
|tabline-menu|.
|
|tabline-menu|.
|
||||||
|
|
||||||
|
For the related autocommands see |tabnew-autocmd|.
|
||||||
|
|
||||||
:[count]tabe[dit] *:tabe* *:tabedit* *:tabnew*
|
:[count]tabe[dit] *:tabe* *:tabedit* *:tabnew*
|
||||||
:[count]tabnew
|
:[count]tabnew
|
||||||
Open a new tab page with an empty window, after the current
|
Open a new tab page with an empty window, after the current
|
||||||
@ -279,6 +281,7 @@ Variables local to a tab page start with "t:". |tabpage-variable|
|
|||||||
|
|
||||||
Currently there is only one option local to a tab page: 'cmdheight'.
|
Currently there is only one option local to a tab page: 'cmdheight'.
|
||||||
|
|
||||||
|
*tabnew-autocmd*
|
||||||
The TabLeave and TabEnter autocommand events can be used to do something when
|
The TabLeave and TabEnter autocommand events can be used to do something when
|
||||||
switching from one tab page to another. The exact order depends on what you
|
switching from one tab page to another. The exact order depends on what you
|
||||||
are doing. When creating a new tab page this works as if you create a new
|
are doing. When creating a new tab page this works as if you create a new
|
||||||
|
@ -287,7 +287,7 @@ CTRL-W CTRL-Q *CTRL-W_CTRL-Q*
|
|||||||
:1quit " quit the first window
|
:1quit " quit the first window
|
||||||
:$quit " quit the last window
|
:$quit " quit the last window
|
||||||
:9quit " quit the last window
|
:9quit " quit the last window
|
||||||
" if there are less than 9 windows opened
|
" if there are fewer than 9 windows opened
|
||||||
:-quit " quit the previous window
|
:-quit " quit the previous window
|
||||||
:+quit " quit the next window
|
:+quit " quit the next window
|
||||||
:+2quit " quit the second next window
|
:+2quit " quit the second next window
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
" Vim support file to detect file types
|
" Vim support file to detect file types
|
||||||
"
|
"
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last Change: 2016 Sep 22
|
" Last Change: 2016 Oct 15
|
||||||
|
|
||||||
" Listen very carefully, I will say this only once
|
" Listen very carefully, I will say this only once
|
||||||
if exists("did_load_filetypes")
|
if exists("did_load_filetypes")
|
||||||
@ -2250,7 +2250,7 @@ func! s:FTtex()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" ConTeXt
|
" ConTeXt
|
||||||
au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context
|
au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv,*.mkvi setf context
|
||||||
|
|
||||||
" Texinfo
|
" Texinfo
|
||||||
au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo
|
au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
" Vim filetype plugin file
|
" Vim filetype plugin file
|
||||||
" Language: ConTeXt typesetting engine
|
" Language: ConTeXt typesetting engine
|
||||||
" Maintainer: Nikolai Weibull <now@bitwi.se>
|
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
||||||
" Latest Revision: 2008-07-09
|
" Former Maintainers: Nikolai Weibull <now@bitwi.se>
|
||||||
|
" Latest Revision: 2016 Oct 14
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
if exists("b:did_ftplugin")
|
||||||
finish
|
finish
|
||||||
@ -11,16 +12,26 @@ let b:did_ftplugin = 1
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo<"
|
if !exists('current_compiler')
|
||||||
|
compiler context
|
||||||
|
endif
|
||||||
|
|
||||||
setlocal comments=b:%D,b:%C,b:%M,:% commentstring=%\ %s formatoptions+=tcroql
|
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=context#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\)\='
|
let &l:define='\\\%([egx]\|char\|mathchar\|count\|dimen\|muskip\|skip\|toks\)\='
|
||||||
\ . 'def\|\\font\|\\\%(future\)\=let'
|
\ . 'def\|\\font\|\\\%(future\)\=let'
|
||||||
\ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
|
\ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
|
||||||
\ . '\|fam\|insert\|if\)'
|
\ . '\|fam\|insert\|if\)'
|
||||||
|
|
||||||
let &l:include = '^\s*\%(input\|component\)'
|
let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'
|
||||||
|
|
||||||
setlocal suffixesadd=.tex
|
setlocal suffixesadd=.tex
|
||||||
|
|
||||||
@ -31,5 +42,61 @@ if exists("loaded_matchit")
|
|||||||
\ '\\start\(\a\+\):\\stop\1'
|
\ '\\start\(\a\+\):\\stop\1'
|
||||||
endif
|
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
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
36
runtime/indent/context.vim
Normal file
36
runtime/indent/context.vim
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
" 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
|
@ -1,7 +1,8 @@
|
|||||||
" Vim syntax file
|
" Vim syntax file
|
||||||
" Language: ConTeXt typesetting engine
|
" Language: ConTeXt typesetting engine
|
||||||
" Maintainer: Nikolai Weibull <now@bitwi.se>
|
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
||||||
" Latest Revision: 2006-08-10
|
" Former Maintainers: Nikolai Weibull <now@bitwi.se>
|
||||||
|
" Latest Revision: 2016 Oct 16
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
@ -13,65 +14,93 @@ unlet b:current_syntax
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
if !exists('g:context_include')
|
" Dictionary of (filetype, group) pairs to highlight between \startGROUP \stopGROUP.
|
||||||
let g:context_include = ['mp', 'javascript', 'xml']
|
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
|
endif
|
||||||
|
|
||||||
|
syn iskeyword @,48-57,a-z,A-Z,192-255
|
||||||
|
|
||||||
syn spell toplevel
|
syn spell toplevel
|
||||||
|
|
||||||
syn match contextBlockDelim display '\\\%(start\|stop\)\a\+'
|
" ConTeXt options, i.e., [...] blocks
|
||||||
\ contains=@NoSpell
|
syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell
|
||||||
|
|
||||||
syn region contextEscaped display matchgroup=contextPreProc
|
" Highlight braces
|
||||||
\ start='\\type\z(\A\)' end='\z1'
|
syn match contextDelimiter '[{}]'
|
||||||
syn region contextEscaped display matchgroup=contextPreProc
|
|
||||||
\ start='\\type\={' end='}'
|
" Comments
|
||||||
syn region contextEscaped display matchgroup=contextPreProc
|
syn match contextComment '\\\@<!\%(\\\\\)*\zs%.*$' display contains=initexTodo
|
||||||
\ start='\\type\=<<' end='>>'
|
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
|
syn region contextEscaped matchgroup=contextPreProc
|
||||||
\ start='\\start\z(\a*\%(typing\|typen\)\)'
|
\ start='\\start\z(\a*\%(typing\|typen\)\)'
|
||||||
\ end='\\stop\z1' contains=plaintexComment keepend
|
\ end='\\stop\z1' contains=plaintexComment keepend
|
||||||
syn region contextEscaped display matchgroup=contextPreProc
|
syn region contextEscaped matchgroup=contextPreProc start='\\\h\+Type\%(\s\|\n\)*{' end='}'
|
||||||
\ start='\\\h\+Type{' end='}'
|
syn region contextEscaped matchgroup=contextPreProc start='\\Typed\h\+\%(\s\|\n\)*{' end='}'
|
||||||
syn region contextEscaped display matchgroup=contextPreProc
|
|
||||||
\ start='\\Typed\h\+{' end='}'
|
|
||||||
|
|
||||||
syn match contextBuiltin display contains=@NoSpell
|
syn match contextBuiltin display contains=@NoSpell
|
||||||
\ '\\\%(unprotect\|protect\|unexpanded\)'
|
\ '\\\%(unprotect\|protect\|unexpanded\)\>'
|
||||||
|
|
||||||
syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\).*$'
|
syn match contextPreProc '^\s*\\\%(start\|stop\)\=\%(component\|environment\|project\|product\)\>'
|
||||||
\ contains=@NoSpell
|
\ contains=@NoSpell
|
||||||
|
|
||||||
if index(g:context_include, 'mp') != -1
|
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
|
syn include @mpTop syntax/mp.vim
|
||||||
unlet b:current_syntax
|
unlet b:current_syntax
|
||||||
|
|
||||||
syn region contextMPGraphic transparent matchgroup=contextBlockDelim
|
syn region contextMPGraphic matchgroup=contextBlockDelim
|
||||||
\ start='\\start\z(\a*MPgraphic\|MP\%(page\|inclusions\|run\)\).*'
|
\ start='\\start\z(MP\%(clip\|code\|definitions\|drawing\|environment\|extensions\|inclusions\|initializations\|page\|\)\)\>.*$'
|
||||||
\ end='\\stop\z1'
|
\ end='\\stop\z1'
|
||||||
\ contains=@mpTop
|
\ 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
|
endif
|
||||||
|
|
||||||
" TODO: also need to implement this for \\typeC or something along those
|
if get(b:, 'context_lua', get(g:, 'context_lua', 1))
|
||||||
" lines.
|
syn include @luaTop syntax/lua.vim
|
||||||
function! s:include_syntax(name, group)
|
unlet b:current_syntax
|
||||||
if index(g:context_include, a:name) != -1
|
|
||||||
execute 'syn include @' . a:name . 'Top' 'syntax/' . a:name . '.vim'
|
|
||||||
unlet b:current_syntax
|
|
||||||
execute 'syn region context' . a:group . 'Code'
|
|
||||||
\ 'transparent matchgroup=contextBlockDelim'
|
|
||||||
\ 'start=+\\start' . a:group . '+ end=+\\stop' . a:group . '+'
|
|
||||||
\ 'contains=@' . a:name . 'Top'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call s:include_syntax('c', 'C')
|
syn region contextLuaCode matchgroup=contextBlockDelim
|
||||||
call s:include_syntax('ruby', 'Ruby')
|
\ start='\\startluacode\>'
|
||||||
call s:include_syntax('javascript', 'JS')
|
\ end='\\stopluacode\>' keepend
|
||||||
call s:include_syntax('xml', 'XML')
|
\ contains=@luaTop,@NoSpell
|
||||||
|
|
||||||
syn match contextSectioning '\\chapter\>' contains=@NoSpell
|
syn match contextDirectLua "\\\%(directlua\|ctxlua\)\>\%(\s*%.*$\)\="
|
||||||
syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell
|
\ 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}\||[<>/]\=|'
|
syn match contextSpecial '\\crlf\>\|\\par\>\|-\{2,3}\||[<>/]\=|'
|
||||||
\ contains=@NoSpell
|
\ contains=@NoSpell
|
||||||
@ -92,15 +121,19 @@ syn match contextFont '\\\%(vi\{1,3}\|ix\|xi\{0,2}\)\>'
|
|||||||
syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
|
syn match contextFont '\\\%(tf\|b[si]\|s[cl]\|os\)\%(xx\|[xabcd]\)\=\>'
|
||||||
\ contains=@NoSpell
|
\ contains=@NoSpell
|
||||||
|
|
||||||
|
hi def link contextOptions Typedef
|
||||||
|
hi def link contextComment Comment
|
||||||
hi def link contextBlockDelim Keyword
|
hi def link contextBlockDelim Keyword
|
||||||
hi def link contextBuiltin Keyword
|
hi def link contextBuiltin Keyword
|
||||||
hi def link contextDelimiter Delimiter
|
hi def link contextDelimiter Delimiter
|
||||||
|
hi def link contextEscaped String
|
||||||
hi def link contextPreProc PreProc
|
hi def link contextPreProc PreProc
|
||||||
hi def link contextSectioning PreProc
|
hi def link contextSectioning PreProc
|
||||||
hi def link contextSpecial Special
|
hi def link contextSpecial Special
|
||||||
hi def link contextType Type
|
hi def link contextType Type
|
||||||
hi def link contextStyle contextType
|
hi def link contextStyle contextType
|
||||||
hi def link contextFont contextType
|
hi def link contextFont contextType
|
||||||
|
hi def link contextDirectLua Keyword
|
||||||
|
|
||||||
let b:current_syntax = "context"
|
let b:current_syntax = "context"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
" Language: MetaPost
|
" Language: MetaPost
|
||||||
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
|
||||||
" Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
|
" Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
|
||||||
" Last Change: 2016 Oct 01
|
" Last Change: 2016 Oct 14
|
||||||
|
|
||||||
if exists("b:current_syntax")
|
if exists("b:current_syntax")
|
||||||
finish
|
finish
|
||||||
@ -233,7 +233,10 @@ if get(g:, "other_mp_macros", 1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Up to date as of 23-Sep-2016.
|
" Up to date as of 23-Sep-2016.
|
||||||
if get(g:, "mp_metafun_macros", 0)
|
if get(b:, 'mp_metafun_macros', get(g:, 'mp_metafun_macros', 0))
|
||||||
|
" Highlight TeX keywords (for use in ConTeXt documents)
|
||||||
|
syn match mpTeXKeyword '\\[a-zA-Z@]\+'
|
||||||
|
|
||||||
" These keywords have been added manually.
|
" These keywords have been added manually.
|
||||||
syn keyword mpPrimitive runscript
|
syn keyword mpPrimitive runscript
|
||||||
|
|
||||||
@ -756,6 +759,7 @@ hi def link mpVariable mfVariable
|
|||||||
hi def link mpConstant mfConstant
|
hi def link mpConstant mfConstant
|
||||||
hi def link mpOnOff mpPrimitive
|
hi def link mpOnOff mpPrimitive
|
||||||
hi def link mpDash mpPrimitive
|
hi def link mpDash mpPrimitive
|
||||||
|
hi def link mpTeXKeyword Identifier
|
||||||
|
|
||||||
let b:current_syntax = "mp"
|
let b:current_syntax = "mp"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user