summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/context.vim184
-rw-r--r--runtime/autoload/contextcomplete.vim25
-rw-r--r--runtime/compiler/context.vim54
-rw-r--r--runtime/doc/eval.txt4
-rw-r--r--runtime/doc/map.txt2
-rw-r--r--runtime/doc/tabpage.txt5
-rw-r--r--runtime/doc/tags1
-rw-r--r--runtime/doc/todo.txt35
-rw-r--r--runtime/doc/windows.txt6
-rw-r--r--runtime/filetype.vim4
-rw-r--r--runtime/ftplugin/context.vim79
-rw-r--r--runtime/indent/context.vim36
-rw-r--r--runtime/lang/menu_sl_si.cp1250.vim12
-rw-r--r--runtime/lang/menu_sl_si.latin2.vim12
-rw-r--r--runtime/lang/menu_sl_si.utf-8.vim12
-rw-r--r--runtime/syntax/context.vim119
-rw-r--r--runtime/syntax/mp.vim8
17 files changed, 515 insertions, 83 deletions
diff --git a/runtime/autoload/context.vim b/runtime/autoload/context.vim
new file mode 100644
index 000000000..254d710c0
--- /dev/null
+++ b/runtime/autoload/context.vim
@@ -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
diff --git a/runtime/autoload/contextcomplete.vim b/runtime/autoload/contextcomplete.vim
new file mode 100644
index 000000000..5b93bb098
--- /dev/null
+++ b/runtime/autoload/contextcomplete.vim
@@ -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
diff --git a/runtime/compiler/context.vim b/runtime/compiler/context.vim
new file mode 100644
index 000000000..cb78c96df
--- /dev/null
+++ b/runtime/compiler/context.vim
@@ -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
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 88599ddec..acf84d292 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 8.0. Last change: 2016 Oct 02
+*eval.txt* For Vim version 8.0. Last change: 2016 Oct 15
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -8214,7 +8214,7 @@ writefile({list}, {fname} [, {flags}])
end does cause the last line in the file to end in a NL.
When {flags} contains "a" then append mode is used, lines are
- append to the file: >
+ appended to the file: >
:call writefile(["foo"], "event.log", "a")
:call writefile(["bar"], "event.log", "a")
>
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 25ed827a8..e644f832c 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -1,4 +1,4 @@
-*map.txt* For Vim version 8.0. Last change: 2016 Aug 26
+*map.txt* For Vim version 8.0. Last change: 2016 Oct 15
VIM REFERENCE MANUAL by Bram Moolenaar
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index 810fba077..bc4098109 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -1,4 +1,4 @@
-*tabpage.txt* For Vim version 8.0. Last change: 2016 Sep 09
+*tabpage.txt* For Vim version 8.0. Last change: 2016 Oct 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -58,6 +58,8 @@ clicking right of the labels.
In the GUI tab pages line you can use the right mouse button to open menu.
|tabline-menu|.
+For the related autocommands see |tabnew-autocmd|.
+
:[count]tabe[dit] *:tabe* *:tabedit* *:tabnew*
:[count]tabnew
Open a new tab page with an empty window, after the current
@@ -287,6 +289,7 @@ Variables local to a tab page start with "t:". |tabpage-variable|
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
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
diff --git a/runtime/doc/tags b/runtime/doc/tags
index fa1465e06..166ff594b 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -8599,6 +8599,7 @@ tab-page-commands tabpage.txt /*tab-page-commands*
tab-page-intro tabpage.txt /*tab-page-intro*
tab-page-other tabpage.txt /*tab-page-other*
tabline-menu tabpage.txt /*tabline-menu*
+tabnew-autocmd tabpage.txt /*tabnew-autocmd*
tabpage tabpage.txt /*tabpage*
tabpage-variable eval.txt /*tabpage-variable*
tabpage.txt tabpage.txt /*tabpage.txt*
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 736c5412b..93a3abeae 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt* For Vim version 8.0. Last change: 2016 Oct 12
+*todo.txt* For Vim version 8.0. Last change: 2016 Oct 23
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -35,7 +35,10 @@ not be repeated below, unless there is extra information.
-------------------- Known bugs and current work -----------------------
+channel:
+- Check for job cleanup more often? Patch from Ozaki Kiichi, 2016 Oct 22.
- Problem with stderr on Windows? (Vincent Rischmann, 2016 Aug 31, #1026)
+- On Windows job_stop() stops cmd.exe, not the commands it runs. (#1184)
+ Patch from Yasuhiro Matsumoto, Oct 21.
- Add 'cwd' argument to start_job(): directory to change to in the child.
check for valid directory before forking.
Part of patch for environment, Yasuhiro Matsumoto, #1160
@@ -103,10 +106,26 @@ What if there is an invalid character?
Should json_encode()/json_decode() restrict recursiveness?
Or avoid recursiveness.
+Patch to fix conceal mode. (Christian Brabandt, 2016 Oct 23, close #1092)
+
+Patch to reset ex_exitvalue after catch. (Christian Brabandt, 2016 Oct 23)
+
+Wrong diff highlighting with three files. (2016 Oct 20, #1186)
+Also get E749 on exit.
+
+Patch for better explanation of 'compatible' side effects.
+https://github.com/vim/vim/pull/1161/files
+
Error in test_startup_utf8 on Solaris. (Danek Duvall, 2016 Aug 17)
+Screen updated delayed when using CTRL-O u in Insert mode.
+(Barlik, #1191) Perhaps because status message?
+
+Patch for restoring wide characters in the console buffer.
+(Ken Takata, 2016 Jun 7)
+
Patch to fix escaping of job arguments. (Yasuhiro Matsumoto, 2016 Oct 5)
-Still not right.
+Update Oct 14: https://gist.github.com/mattn/d47e7d3bfe5ade4be86062b565a4bfca
Once .exe with updated installer is available: Add remark to download page
about /S and /D options (Ken Takata, 2016 Apr 13)
@@ -149,6 +168,9 @@ Add an argument to choose binary or non-binary (like readfile()), when omitted
use the current behavior.
Include the test.
+When 'keywordprg' starts with ":" the argument is still escaped as a shell
+command argument. (Romain Lafourcade, 2016 Oct 16, #1175)
+
Idea from Sven: record sequence of keys. Useful to show others what they are
doing (look over the shoulder), and also to see what happened.
Probably list of keystrokes, with some annotations for mode changes.
@@ -179,6 +201,9 @@ Also with latest version.
Cannot delete a file with square brackets with delete(). (#696)
+Patch to add ":syn foldlevel" to use fold level further down the line.
+(Brad King, 2016 Oct 19)
+
Completion for input() does not expand environment variables. (chdiza, 2016
Jul 25, #948)
@@ -218,9 +243,6 @@ Patch to improve map documentation. Issue #799.
Patch for syntax folding optimization. (Shougo, 2016 Sep 6, #1045)
-Patch for restoring wide characters in the console buffer.
-(Ken Takata, 2016 Jun 7)
-
Patch for drag&drop reordering of GUI tab pages reordering.
(Ken Takata, 2013 Nov 22, second one, also by Masamichi Abe)
Now on Git: https://gist.github.com/nocd5/165286495c782b815b94
@@ -331,6 +353,9 @@ Patch to have text objects defined by arbitrary single characters. (Daniel
Thau, 2013 Nov 20, 2014 Jan 29, 2014 Jan 31)
Added tests (James McCoy, 2016 Aug 3). Still needs more work.
+Feature request: add the "al" text object, to manipulate a screen line.
+Especially useful when using 'linebreak'
+
Access to uninitialized memory in match_backref() regexp_nda.c:4882
(Dominique Pelle, 2015 Nov 6)
diff --git a/runtime/doc/windows.txt b/runtime/doc/windows.txt
index 0ef1a8bf5..3c695e61a 100644
--- a/runtime/doc/windows.txt
+++ b/runtime/doc/windows.txt
@@ -1,4 +1,4 @@
-*windows.txt* For Vim version 8.0. Last change: 2016 Aug 23
+*windows.txt* For Vim version 8.0. Last change: 2016 Oct 21
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -295,8 +295,8 @@ CTRL-W CTRL-Q *CTRL-W_CTRL-Q*
:1quit " quit the first window
:$quit " quit the last window
:9quit " quit the last window
- " if there are less than 9 windows opened
- :-quit " quit the previews window
+ " if there are fewer than 9 windows opened
+ :-quit " quit the previous window
:+quit " quit the next window
:+2quit " quit the second next window
<
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 844635e26..482ec1738 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" 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
if exists("did_load_filetypes")
@@ -2254,7 +2254,7 @@ func! s:FTtex()
endfunc
" ConTeXt
-au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context
+au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv,*.mkvi setf context
" Texinfo
au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo
diff --git a/runtime/ftplugin/context.vim b/runtime/ftplugin/context.vim
index 1c7d67837..6c11166af 100644
--- a/runtime/ftplugin/context.vim
+++ b/runtime/ftplugin/context.vim
@@ -1,7 +1,8 @@
" Vim filetype plugin file
-" Language: ConTeXt typesetting engine
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2008-07-09
+" Language: ConTeXt typesetting engine
+" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
+" Former Maintainers: Nikolai Weibull <now@bitwi.se>
+" Latest Revision: 2016 Oct 14
if exists("b:did_ftplugin")
finish
@@ -11,16 +12,26 @@ let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
-let b:undo_ftplugin = "setl com< cms< def< inc< sua< fo<"
+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+=tcroql
+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\)\='
\ . 'def\|\\font\|\\\%(future\)\=let'
\ . '\|\\new\%(count\|dimen\|skip\|muskip\|box\|toks\|read\|write'
\ . '\|fam\|insert\|if\)'
-let &l:include = '^\s*\%(input\|component\)'
+let &l:include = '^\s*\\\%(input\|component\|product\|project\|environment\)'
setlocal suffixesadd=.tex
@@ -31,5 +42,61 @@ if exists("loaded_matchit")
\ '\\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
diff --git a/runtime/indent/context.vim b/runtime/indent/context.vim
new file mode 100644
index 000000000..652479f7e
--- /dev/null
+++ b/runtime/indent/context.vim
@@ -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
diff --git a/runtime/lang/menu_sl_si.cp1250.vim b/runtime/lang/menu_sl_si.cp1250.vim
index 8999b15da..5b5482d38 100644
--- a/runtime/lang/menu_sl_si.cp1250.vim
+++ b/runtime/lang/menu_sl_si.cp1250.vim
@@ -1,7 +1,7 @@
" Menu Translations: Slovenian / Slovensko
" Maintainer: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
" Originally By: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
-" Last Change: Sat, 17 Jun 2006
+" Last Change: 2016 Oct 17
" vim:set foldmethod=marker tabstop=8:
" TODO: add/check all '&'s
@@ -31,7 +31,7 @@ menutrans E&xit<Tab>:qa &Izhod<Tab>:qa
if has("diff")
menutrans Split\ &Diff\ with\.\.\. Primerjaj\ z\ (di&ff)\ \.\.\.
- menutrans Split\ Patched\ &By\.\.\. &Popravi\ z\ (patch)\ \.\.\.
+ menutrans Split\ Patched\ &By\.\.\. &Popravi\ s\ (patch)\ \.\.\.
endif
" }}} FILE / DATOTEKA
@@ -96,12 +96,12 @@ menutrans Soft\ &Tabstop Širina\ &tabulatorja
menutrans Te&xt\ Width\.\.\. Širina\ besedila\ \.\.\.
menutrans &File\ Format\.\.\. Format\ &datoteke\ \.\.\.
menutrans C&olor\ Scheme &Barvna\ shema\ \.\.\.
-menutrans &Keymap &Keymap
+menutrans &Keymap Razporeditev\ tip&k
menutrans Select\ Fo&nt\.\.\. Pisava\ \.\.\.
" }}} EDIT / UREDI
" {{{ TOOLS / ORODJA
-menutrans &Tools &Orodja
+menutrans &Tools O&rodja
menutrans &Jump\ to\ this\ tag<Tab>g^] &Skoči\ k\ tej\ znački<Tab>g^]
menutrans Jump\ &back<Tab>^T Skoči\ Na&zaj<Tab>^T
menutrans Build\ &Tags\ File Napravi\ datoteke\ z\ značkami\ (tag)
@@ -175,7 +175,7 @@ menutrans &Set\ Compiler Nastavi\ &prevajalnik
menutrans Se&T\ Compiler Nastavi\ &prevajalnik " bug in original translation?
menutrans &Convert\ to\ HEX<Tab>:%!xxd Pretvori\ v\ HE&X<Tab>:%!xxd
-menutrans Conve&rt\ back<Tab>:%!xxd\ -r Pretvori\ nazaj<Tab>:%!xxd\ -r
+menutrans Conve&rt\ back<Tab>:%!xxd\ -r Povrni\ pretvo&rbo<Tab>:%!xxd\ -r
" }}} TOOLS / ORODJA
" {{{ SYNTAX / BARVANJE KODE
@@ -242,7 +242,7 @@ menutrans &About &O\ programu
" {{{ POPUP
menutrans &Undo &Razveljavi
menutrans Cu&t &Izreži
-menutrans &Copy &Kopieraj
+menutrans &Copy &Kopiraj
menutrans &Paste &Prilepi
menutrans &Delete &Zbriši
menutrans Select\ Blockwise Izbiraj\ po\ blokih
diff --git a/runtime/lang/menu_sl_si.latin2.vim b/runtime/lang/menu_sl_si.latin2.vim
index fd503871d..a810a2a12 100644
--- a/runtime/lang/menu_sl_si.latin2.vim
+++ b/runtime/lang/menu_sl_si.latin2.vim
@@ -1,7 +1,7 @@
" Menu Translations: Slovenian / Slovensko
" Maintainer: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
" Originally By: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
-" Last Change: Mon, 12 Jun 2006 00:00:00 CEST
+" Last Change: 2016 Oct 17
" vim:set foldmethod=marker tabstop=8:
" TODO: add/check all '&'s
@@ -31,7 +31,7 @@ menutrans E&xit<Tab>:qa &Izhod<Tab>:qa
if has("diff")
menutrans Split\ &Diff\ with\.\.\. Primerjaj\ z\ (di&ff)\ \.\.\.
- menutrans Split\ Patched\ &By\.\.\. &Popravi\ z\ (patch)\ \.\.\.
+ menutrans Split\ Patched\ &By\.\.\. &Popravi\ s\ (patch)\ \.\.\.
endif
" }}} FILE / DATOTEKA
@@ -96,12 +96,12 @@ menutrans Soft\ &Tabstop Širina &tabulatorja
menutrans Te&xt\ Width\.\.\. Širina\ besedila\ \.\.\.
menutrans &File\ Format\.\.\. Format\ &datoteke\ \.\.\.
menutrans C&olor\ Scheme &Barvna\ shema\ \.\.\.
-menutrans &Keymap &Keymap
+menutrans &Keymap Razporeditev\ tip&k
menutrans Select\ Fo&nt\.\.\. Pisava\ \.\.\.
" }}} EDIT / UREDI
" {{{ TOOLS / ORODJA
-menutrans &Tools &Orodja
+menutrans &Tools O&rodja
menutrans &Jump\ to\ this\ tag<Tab>g^] &Skoči\ k\ tej\ znački<Tab>g^]
menutrans Jump\ &back<Tab>^T Skoči\ Na&zaj<Tab>^T
menutrans Build\ &Tags\ File Napravi\ datoteke\ z\ značkami\ (tag)
@@ -175,7 +175,7 @@ menutrans &Set\ Compiler Nastavi\ &prevajalnik
menutrans Se&T\ Compiler Nastavi\ &prevajalnik " bug in original translation?
menutrans &Convert\ to\ HEX<Tab>:%!xxd Pretvori\ v\ HE&X<Tab>:%!xxd
-menutrans Conve&rt\ back<Tab>:%!xxd\ -r Pretvori\ nazaj<Tab>:%!xxd\ -r
+menutrans Conve&rt\ back<Tab>:%!xxd\ -r Povrni\ pretvo&rbo<Tab>:%!xxd\ -r
" }}} TOOLS / ORODJA
" {{{ SYNTAX / BARVANJE KODE
@@ -242,7 +242,7 @@ menutrans &About &O\ programu
" {{{ POPUP
menutrans &Undo &Razveljavi
menutrans Cu&t &Izreži
-menutrans &Copy &Kopieraj
+menutrans &Copy &Kopiraj
menutrans &Paste &Prilepi
menutrans &Delete &Zbriši
menutrans Select\ Blockwise Izbiraj\ po\ blokih
diff --git a/runtime/lang/menu_sl_si.utf-8.vim b/runtime/lang/menu_sl_si.utf-8.vim
index 7043e62dc..ac5035c7f 100644
--- a/runtime/lang/menu_sl_si.utf-8.vim
+++ b/runtime/lang/menu_sl_si.utf-8.vim
@@ -1,7 +1,7 @@
" Menu Translations: Slovenian / Slovensko
" Maintainer: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
" Originally By: Mojca Miklavec <mojca.miklavec.lists@gmail.com>
-" Last Change: Sat, 17 Jun 2006
+" Last Change: 2016 Oct 17
" vim:set foldmethod=marker tabstop=8:
" TODO: add/check all '&'s
@@ -31,7 +31,7 @@ menutrans E&xit<Tab>:qa &Izhod<Tab>:qa
if has("diff")
menutrans Split\ &Diff\ with\.\.\. Primerjaj\ z\ (di&ff)\ \.\.\.
- menutrans Split\ Patched\ &By\.\.\. &Popravi\ z\ (patch)\ \.\.\.
+ menutrans Split\ Patched\ &By\.\.\. &Popravi\ s\ (patch)\ \.\.\.
endif
" }}} FILE / DATOTEKA
@@ -96,12 +96,12 @@ menutrans Soft\ &Tabstop Ĺ irina\ &tabulatorja
menutrans Te&xt\ Width\.\.\. Ĺ irina\ besedila\ \.\.\.
menutrans &File\ Format\.\.\. Format\ &datoteke\ \.\.\.
menutrans C&olor\ Scheme &Barvna\ shema\ \.\.\.
-menutrans &Keymap &Keymap
+menutrans &Keymap Razporeditev\ tip&k
menutrans Select\ Fo&nt\.\.\. Pisava\ \.\.\.
" }}} EDIT / UREDI
" {{{ TOOLS / ORODJA
-menutrans &Tools &Orodja
+menutrans &Tools O&rodja
menutrans &Jump\ to\ this\ tag<Tab>g^] &Skoči\ k\ tej\ znački<Tab>g^]
menutrans Jump\ &back<Tab>^T Skoči\ Na&zaj<Tab>^T
menutrans Build\ &Tags\ File Napravi\ datoteke\ z\ značkami\ (tag)
@@ -175,7 +175,7 @@ menutrans &Set\ Compiler Nastavi\ &prevajalnik
menutrans Se&T\ Compiler Nastavi\ &prevajalnik " bug in original translation?
menutrans &Convert\ to\ HEX<Tab>:%!xxd Pretvori\ v\ HE&X<Tab>:%!xxd
-menutrans Conve&rt\ back<Tab>:%!xxd\ -r Pretvori\ nazaj<Tab>:%!xxd\ -r
+menutrans Conve&rt\ back<Tab>:%!xxd\ -r Povrni\ pretvo&rbo<Tab>:%!xxd\ -r
" }}} TOOLS / ORODJA
" {{{ SYNTAX / BARVANJE KODE
@@ -242,7 +242,7 @@ menutrans &About &O\ programu
" {{{ POPUP
menutrans &Undo &Razveljavi
menutrans Cu&t &IzreĹži
-menutrans &Copy &Kopieraj
+menutrans &Copy &Kopiraj
menutrans &Paste &Prilepi
menutrans &Delete &ZbriĹĄi
menutrans Select\ Blockwise Izbiraj\ po\ blokih
diff --git a/runtime/syntax/context.vim b/runtime/syntax/context.vim
index 225cc6efc..b29f256ba 100644
--- a/runtime/syntax/context.vim
+++ b/runtime/syntax/context.vim
@@ -1,7 +1,8 @@
" Vim syntax file
-" Language: ConTeXt typesetting engine
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2006-08-10
+" 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
@@ -13,65 +14,93 @@ unlet b:current_syntax
let s:cpo_save = &cpo
set cpo&vim
-if !exists('g:context_include')
- let g:context_include = ['mp', 'javascript', 'xml']
+" 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
-syn match contextBlockDelim display '\\\%(start\|stop\)\a\+'
- \ contains=@NoSpell
+" ConTeXt options, i.e., [...] blocks
+syn region contextOptions matchgroup=contextDelimiter start='\[' end=']\|\ze\\stop' skip='\\\[\|\\\]' contains=ALLBUT,contextBeginEndLua,@Spell
+
+" Highlight braces
+syn match contextDelimiter '[{}]'
-syn region contextEscaped display matchgroup=contextPreProc
- \ start='\\type\z(\A\)' end='\z1'
-syn region contextEscaped display matchgroup=contextPreProc
- \ start='\\type\={' end='}'
-syn region contextEscaped display matchgroup=contextPreProc
- \ start='\\type\=<<' end='>>'
+" 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 display matchgroup=contextPreProc
- \ start='\\\h\+Type{' end='}'
-syn region contextEscaped display matchgroup=contextPreProc
- \ start='\\Typed\h\+{' end='}'
+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\)'
+ \ '\\\%(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
-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
unlet b:current_syntax
- syn region contextMPGraphic transparent matchgroup=contextBlockDelim
- \ start='\\start\z(\a*MPgraphic\|MP\%(page\|inclusions\|run\)\).*'
+ 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
+ \ contains=@mpTop,@NoSpell
endif
-" TODO: also need to implement this for \\typeC or something along those
-" lines.
-function! s:include_syntax(name, group)
- 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')
-call s:include_syntax('ruby', 'Ruby')
-call s:include_syntax('javascript', 'JS')
-call s:include_syntax('xml', 'XML')
-
-syn match contextSectioning '\\chapter\>' contains=@NoSpell
-syn match contextSectioning '\\\%(sub\)*section\>' contains=@NoSpell
+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
@@ -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]\)\=\>'
\ 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"
diff --git a/runtime/syntax/mp.vim b/runtime/syntax/mp.vim
index 95723d0d9..a8fa36fe0 100644
--- a/runtime/syntax/mp.vim
+++ b/runtime/syntax/mp.vim
@@ -2,7 +2,7 @@
" Language: MetaPost
" Maintainer: Nicola Vitacolonna <nvitacolonna@gmail.com>
" Former Maintainers: Andreas Scherer <andreas.scherer@pobox.com>
-" Last Change: 2016 Oct 01
+" Last Change: 2016 Oct 14
if exists("b:current_syntax")
finish
@@ -233,7 +233,10 @@ if get(g:, "other_mp_macros", 1)
endif
" 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.
syn keyword mpPrimitive runscript
@@ -756,6 +759,7 @@ hi def link mpVariable mfVariable
hi def link mpConstant mfConstant
hi def link mpOnOff mpPrimitive
hi def link mpDash mpPrimitive
+hi def link mpTeXKeyword Identifier
let b:current_syntax = "mp"