Skip to content

Commit 5bf2c09

Browse files
committed
Initial commit
0 parents  commit 5bf2c09

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

‎plugin/gutenberg.vim‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
let s:gutenberg_dir = '~/gutenberg'
2+
let s:wp_tags = '/Applications/MAMP/htdocs/wpdev/tags'
3+
4+
augroup gutenberg
5+
autocmd!
6+
autocmd VimEnter,DirChanged * call s:EnterGutenberg()
7+
augroup END
8+
9+
function! s:EnterGutenberg()
10+
11+
" A set of automations when working in the Gutenberg repository.
12+
if (getcwd() . '/') =~ '^' . expand(s:gutenberg_dir) . '/'
13+
14+
" Include WordPress's own tags file so that we can look up Gutenberg
15+
" and WordPress identifiers alike.
16+
execute "set tags+=" . fnameescape(s:wp_tags)
17+
18+
" Regenerate Gutenberg's tags index in the background.
19+
let job = job_start('agtag', {
20+
\ "in_io": "null",
21+
\ "err_io": "null",
22+
\ "out_io": "file",
23+
\ "out_name": expand(s:gutenberg_dir . "/tags"),
24+
\ "exit_cb": "s:HandleTagsJob",
25+
\ "cwd": expand(s:gutenberg_dir),
26+
\ })
27+
28+
endif
29+
30+
endfunction
31+
32+
function! s:HandleTagsJob(job, status)
33+
if a:status == 0
34+
echo "Gutenberg tags successfully regenerated."
35+
else
36+
echoerr "Could not regenerate Gutenberg tags."
37+
endif
38+
endfunction

0 commit comments

Comments
 (0)