Skip to content

Commit 5a07be6

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 239a7e4 + 46fceaa commit 5a07be6

File tree

17 files changed

+515
-83
lines changed

17 files changed

+515
-83
lines changed

runtime/autoload/context.vim

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
" Language: ConTeXt typesetting engine
2+
" Maintainer: Nicola Vitacolonna <[email protected]>
3+
" Latest Revision: 2016 Oct 21
4+
5+
let s:keepcpo= &cpo
6+
set cpo&vim
7+
8+
" Helper functions {{{
9+
function! s:context_echo(message, mode)
10+
redraw
11+
echo "\r"
12+
execute 'echohl' a:mode
13+
echomsg '[ConTeXt]' a:message
14+
echohl None
15+
endf
16+
17+
function! s:sh()
18+
return has('win32') || has('win64') || has('win16') || has('win95')
19+
\ ? ['cmd.exe', '/C']
20+
\ : ['/bin/sh', '-c']
21+
endfunction
22+
23+
" For backward compatibility
24+
if exists('*win_getid')
25+
26+
function! s:win_getid()
27+
return win_getid()
28+
endf
29+
30+
function! s:win_id2win(winid)
31+
return win_id2win(a:winid)
32+
endf
33+
34+
else
35+
36+
function! s:win_getid()
37+
return winnr()
38+
endf
39+
40+
function! s:win_id2win(winnr)
41+
return a:winnr
42+
endf
43+
44+
endif
45+
" }}}
46+
47+
" ConTeXt jobs {{{
48+
if has('job')
49+
50+
let g:context_jobs = []
51+
52+
" Print the status of ConTeXt jobs
53+
function! context#job_status()
54+
let l:jobs = filter(g:context_jobs, 'job_status(v:val) == "run"')
55+
let l:n = len(l:jobs)
56+
call s:context_echo(
57+
\ 'There '.(l:n == 1 ? 'is' : 'are').' '.(l:n == 0 ? 'no' : l:n)
58+
\ .' job'.(l:n == 1 ? '' : 's').' running'
59+
\ .(l:n == 0 ? '.' : ' (' . join(l:jobs, ', ').').'),
60+
\ 'ModeMsg')
61+
endfunction
62+
63+
" Stop all ConTeXt jobs
64+
function! context#stop_jobs()
65+
let l:jobs = filter(g:context_jobs, 'job_status(v:val) == "run"')
66+
for job in l:jobs
67+
call job_stop(job)
68+
endfor
69+
sleep 1
70+
let l:tmp = []
71+
for job in l:jobs
72+
if job_status(job) == "run"
73+
call add(l:tmp, job)
74+
endif
75+
endfor
76+
let g:context_jobs = l:tmp
77+
if empty(g:context_jobs)
78+
call s:context_echo('Done. No jobs running.', 'ModeMsg')
79+
else
80+
call s:context_echo('There are still some jobs running. Please try again.', 'WarningMsg')
81+
endif
82+
endfunction
83+
84+
function! context#callback(path, job, status)
85+
if index(g:context_jobs, a:job) != -1 && job_status(a:job) != 'run' " just in case
86+
call remove(g:context_jobs, index(g:context_jobs, a:job))
87+
endif
88+
call s:callback(a:path, a:job, a:status)
89+
endfunction
90+
91+
function! context#close_cb(channel)
92+
call job_status(ch_getjob(a:channel)) " Trigger exit_cb's callback for faster feedback
93+
endfunction
94+
95+
function! s:typeset(path)
96+
call add(g:context_jobs,
97+
\ job_start(add(s:sh(), context#command() . ' ' . shellescape(fnamemodify(a:path, ":t"))), {
98+
\ 'close_cb' : 'context#close_cb',
99+
\ 'exit_cb' : function(get(b:, 'context_callback', get(g:, 'context_callback', 'context#callback')),
100+
\ [a:path]),
101+
\ 'in_io' : 'null'
102+
\ }))
103+
endfunction
104+
105+
else " No jobs
106+
107+
function! context#job_status()
108+
call s:context_echo('Not implemented', 'WarningMsg')
109+
endfunction!
110+
111+
function! context#stop_jobs()
112+
call s:context_echo('Not implemented', 'WarningMsg')
113+
endfunction
114+
115+
function! context#callback(path, job, status)
116+
call s:callback(a:path, a:job, a:status)
117+
endfunction
118+
119+
function! s:typeset(path)
120+
execute '!' . context#command() . ' ' . shellescape(fnamemodify(a:path, ":t"))
121+
call call(get(b:, 'context_callback', get(g:, 'context_callback', 'context#callback')),
122+
\ [a:path, 0, v:shell_error])
123+
endfunction
124+
125+
endif " has('job')
126+
127+
function! s:callback(path, job, status) abort
128+
if a:status < 0 " Assume the job was terminated
129+
return
130+
endif
131+
" Get info about the current window
132+
let l:winid = s:win_getid() " Save window id
133+
let l:efm = &l:errorformat " Save local errorformat
134+
let l:cwd = fnamemodify(getcwd(), ":p") " Save local working directory
135+
" Set errorformat to parse ConTeXt errors
136+
execute 'setl efm=' . escape(b:context_errorformat, ' ')
137+
try " Set cwd to expand error file correctly
138+
execute 'lcd' fnameescape(fnamemodify(a:path, ':h'))
139+
catch /.*/
140+
execute 'setl efm=' . escape(l:efm, ' ')
141+
throw v:exception
142+
endtry
143+
try
144+
execute 'cgetfile' fnameescape(fnamemodify(a:path, ':r') . '.log')
145+
botright cwindow
146+
finally " Restore cwd and errorformat
147+
execute s:win_id2win(l:winid) . 'wincmd w'
148+
execute 'lcd ' . fnameescape(l:cwd)
149+
execute 'setl efm=' . escape(l:efm, ' ')
150+
endtry
151+
if a:status == 0
152+
call s:context_echo('Success!', 'ModeMsg')
153+
else
154+
call s:context_echo('There are errors. ', 'ErrorMsg')
155+
endif
156+
endfunction
157+
158+
function! context#command()
159+
return get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun'))
160+
\ . ' --script context --autogenerate --nonstopmode'
161+
\ . ' --synctex=' . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0')
162+
\ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', ''))
163+
endfunction
164+
165+
" Accepts an optional path (useful for big projects, when the file you are
166+
" editing is not the project's root document). If no argument is given, uses
167+
" the path of the current buffer.
168+
function! context#typeset(...) abort
169+
let l:path = fnamemodify(strlen(a:000[0]) > 0 ? a:1 : expand("%"), ":p")
170+
let l:cwd = fnamemodify(getcwd(), ":p") " Save local working directory
171+
call s:context_echo('Typesetting...', 'ModeMsg')
172+
execute 'lcd' fnameescape(fnamemodify(l:path, ":h"))
173+
try
174+
call s:typeset(l:path)
175+
finally " Restore local working directory
176+
execute 'lcd ' . fnameescape(l:cwd)
177+
endtry
178+
endfunction!
179+
"}}}
180+
181+
let &cpo = s:keepcpo
182+
unlet s:keepcpo
183+
184+
" vim: sw=2 fdm=marker
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
" Language: ConTeXt typesetting engine
2+
" Maintainer: Nicola Vitacolonna <[email protected]>
3+
" Latest Revision: 2016 Oct 15
4+
5+
let s:keepcpo= &cpo
6+
set cpo&vim
7+
8+
" Complete keywords in MetaPost blocks
9+
function! contextcomplete#Complete(findstart, base)
10+
if a:findstart == 1
11+
if len(synstack(line('.'), 1)) > 0 &&
12+
\ synIDattr(synstack(line('.'), 1)[0], "name") ==# 'contextMPGraphic'
13+
return syntaxcomplete#Complete(a:findstart, a:base)
14+
else
15+
return -3
16+
endif
17+
else
18+
return syntaxcomplete#Complete(a:findstart, a:base)
19+
endif
20+
endfunction
21+
22+
let &cpo = s:keepcpo
23+
unlet s:keepcpo
24+
25+
" vim: sw=2 fdm=marker

runtime/compiler/context.vim

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
" Vim compiler file
2+
" Compiler: ConTeXt typesetting engine
3+
" Maintainer: Nicola Vitacolonna <[email protected]>
4+
" Last Change: 2016 Oct 21
5+
6+
if exists("current_compiler")
7+
finish
8+
endif
9+
let s:keepcpo= &cpo
10+
set cpo&vim
11+
12+
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
13+
command -nargs=* CompilerSet setlocal <args>
14+
endif
15+
16+
" If makefile exists and we are not asked to ignore it, we use standard make
17+
" (do not redefine makeprg)
18+
if get(b:, 'context_ignore_makefile', get(g:, 'context_ignore_makefile', 0)) ||
19+
\ (!filereadable('Makefile') && !filereadable('makefile'))
20+
let current_compiler = 'context'
21+
" The following assumes that the current working directory is set to the
22+
" directory of the file to be typeset
23+
let &l:makeprg = get(b:, 'context_mtxrun', get(g:, 'context_mtxrun', 'mtxrun'))
24+
\ . ' --script context --autogenerate --nonstopmode --synctex='
25+
\ . (get(b:, 'context_synctex', get(g:, 'context_synctex', 0)) ? '1' : '0')
26+
\ . ' ' . get(b:, 'context_extra_options', get(g:, 'context_extra_options', ''))
27+
\ . ' ' . shellescape(expand('%:p:t'))
28+
else
29+
let current_compiler = 'make'
30+
endif
31+
32+
let b:context_errorformat = ''
33+
\ . '%-Popen source%.%#> %f,'
34+
\ . '%-Qclose source%.%#> %f,'
35+
\ . "%-Popen source%.%#name '%f',"
36+
\ . "%-Qclose source%.%#name '%f',"
37+
\ . '%Etex %trror%.%#mp error on line %l in file %f:%.%#,'
38+
\ . 'tex %trror%.%#error on line %l in file %f: %m,'
39+
\ . '%Elua %trror%.%#error on line %l in file %f:,'
40+
\ . '%+Emetapost %#> error: %#,'
41+
\ . '! error: %#%m,'
42+
\ . '%-C %#,'
43+
\ . '%C! %m,'
44+
\ . '%Z[ctxlua]%m,'
45+
\ . '%+C<*> %.%#,'
46+
\ . '%-C%.%#,'
47+
\ . '%Z...%m,'
48+
\ . '%-Zno-error,'
49+
\ . '%-G%.%#' " Skip remaining lines
50+
51+
execute 'CompilerSet errorformat=' . escape(b:context_errorformat, ' ')
52+
53+
let &cpo = s:keepcpo
54+
unlet s:keepcpo

runtime/doc/eval.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.0. Last change: 2016 Oct 02
1+
*eval.txt* For Vim version 8.0. Last change: 2016 Oct 15
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -8214,7 +8214,7 @@ writefile({list}, {fname} [, {flags}])
82148214
end does cause the last line in the file to end in a NL.
82158215

82168216
When {flags} contains "a" then append mode is used, lines are
8217-
append to the file: >
8217+
appended to the file: >
82188218
:call writefile(["foo"], "event.log", "a")
82198219
:call writefile(["bar"], "event.log", "a")
82208220
>

runtime/doc/map.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*map.txt* For Vim version 8.0. Last change: 2016 Aug 26
1+
*map.txt* For Vim version 8.0. Last change: 2016 Oct 15
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar

runtime/doc/tabpage.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*tabpage.txt* For Vim version 8.0. Last change: 2016 Sep 09
1+
*tabpage.txt* For Vim version 8.0. Last change: 2016 Oct 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -58,6 +58,8 @@ clicking right of the labels.
5858
In the GUI tab pages line you can use the right mouse button to open menu.
5959
|tabline-menu|.
6060

61+
For the related autocommands see |tabnew-autocmd|.
62+
6163
:[count]tabe[dit] *:tabe* *:tabedit* *:tabnew*
6264
:[count]tabnew
6365
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|
287289

288290
Currently there is only one option local to a tab page: 'cmdheight'.
289291

292+
*tabnew-autocmd*
290293
The TabLeave and TabEnter autocommand events can be used to do something when
291294
switching from one tab page to another. The exact order depends on what you
292295
are doing. When creating a new tab page this works as if you create a new

runtime/doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8695,6 +8695,7 @@ tab-page-commands tabpage.txt /*tab-page-commands*
86958695
tab-page-intro tabpage.txt /*tab-page-intro*
86968696
tab-page-other tabpage.txt /*tab-page-other*
86978697
tabline-menu tabpage.txt /*tabline-menu*
8698+
tabnew-autocmd tabpage.txt /*tabnew-autocmd*
86988699
tabpage tabpage.txt /*tabpage*
86998700
tabpage-variable eval.txt /*tabpage-variable*
87008701
tabpage.txt tabpage.txt /*tabpage.txt*

0 commit comments

Comments
 (0)