Mercurial > vim
comparison runtime/ftplugin/ocaml.vim @ 17261:432714f5c0f7
Update runtime files
commit https://github.com/vim/vim/commit/790c18bfa5dfeca51749b752dddc41e60cb3fa54
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 4 17:22:06 2019 +0200
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 04 Jul 2019 17:30:05 +0200 |
parents | 1eaf34420bb3 |
children | 15fa3923cc49 |
comparison
equal
deleted
inserted
replaced
17260:9d5a97ea1871 | 17261:432714f5c0f7 |
---|---|
3 " Mike Leary <leary@nwlink.com> | 3 " Mike Leary <leary@nwlink.com> |
4 " Markus Mottl <markus.mottl@gmail.com> | 4 " Markus Mottl <markus.mottl@gmail.com> |
5 " Pierre Vittet <pierre-vittet@pvittet.com> | 5 " Pierre Vittet <pierre-vittet@pvittet.com> |
6 " Stefano Zacchiroli <zack@bononia.it> | 6 " Stefano Zacchiroli <zack@bononia.it> |
7 " Vincent Aravantinos <firstname.name@imag.fr> | 7 " Vincent Aravantinos <firstname.name@imag.fr> |
8 " URL: http://www.ocaml.info/vim/ftplugin/ocaml.vim | 8 " URL: https://github.com/rgrinberg/vim-ocaml |
9 " Last Change: | 9 " Last Change: |
10 " 2013 Oct 27 - Added commentstring (MM) | |
10 " 2013 Jul 26 - load default compiler settings (MM) | 11 " 2013 Jul 26 - load default compiler settings (MM) |
11 " 2013 Jul 24 - removed superfluous efm-setting (MM) | 12 " 2013 Jul 24 - removed superfluous efm-setting (MM) |
12 " 2013 Jul 22 - applied fixes supplied by Hirotaka Hamada (MM) | 13 " 2013 Jul 22 - applied fixes supplied by Hirotaka Hamada (MM) |
13 " 2013 Mar 15 - Improved error format (MM) | |
14 | 14 |
15 if exists("b:did_ftplugin") | 15 if exists("b:did_ftplugin") |
16 finish | 16 finish |
17 endif | 17 endif |
18 let b:did_ftplugin=1 | 18 let b:did_ftplugin=1 |
35 | 35 |
36 " Error handling -- helps moving where the compiler wants you to go | 36 " Error handling -- helps moving where the compiler wants you to go |
37 let s:cposet=&cpoptions | 37 let s:cposet=&cpoptions |
38 set cpo&vim | 38 set cpo&vim |
39 | 39 |
40 " Comment string | |
41 setlocal comments= | |
42 setlocal commentstring=(*%s*) | |
43 | |
40 " Add mappings, unless the user didn't want this. | 44 " Add mappings, unless the user didn't want this. |
41 if !exists("no_plugin_maps") && !exists("no_ocaml_maps") | 45 if !exists("no_plugin_maps") && !exists("no_ocaml_maps") |
42 " (un)commenting | 46 " (un)commenting |
43 if !hasmapto('<Plug>Comment') | 47 if !hasmapto('<Plug>Comment') |
44 nmap <buffer> <LocalLeader>c <Plug>LUncomOn | 48 nmap <buffer> <LocalLeader>c <Plug>LUncomOn |
58 nmap <buffer> <LocalLeader>t <Plug>OCamlPrintType | 62 nmap <buffer> <LocalLeader>t <Plug>OCamlPrintType |
59 xmap <buffer> <LocalLeader>t <Plug>OCamlPrintType | 63 xmap <buffer> <LocalLeader>t <Plug>OCamlPrintType |
60 endif | 64 endif |
61 | 65 |
62 " Let % jump between structure elements (due to Issac Trotts) | 66 " Let % jump between structure elements (due to Issac Trotts) |
63 let b:mw = '' | 67 let b:mw = '\<let\>:\<and\>:\(\<in\>\|;;\)' |
64 let b:mw = b:mw . ',\<let\>:\<and\>:\(\<in\>\|;;\)' | |
65 let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>' | 68 let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>' |
66 let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>,' | 69 let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>' |
67 let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>' | 70 let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>' |
68 let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>' | 71 let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>' |
69 let b:match_words = b:mw | 72 let b:match_words = b:mw |
70 | 73 |
71 let b:match_ignorecase=0 | 74 let b:match_ignorecase=0 |
75 | |
76 function! s:OcpGrep(bang,args) abort | |
77 let grepprg = &l:grepprg | |
78 let grepformat = &l:grepformat | |
79 let shellpipe = &shellpipe | |
80 try | |
81 let &l:grepprg = "ocp-grep -c never" | |
82 setlocal grepformat=%f:%l:%m | |
83 if &shellpipe ==# '2>&1| tee' || &shellpipe ==# '|& tee' | |
84 let &shellpipe = "| tee" | |
85 endif | |
86 execute 'grep! '.a:args | |
87 if empty(a:bang) && !empty(getqflist()) | |
88 return 'cfirst' | |
89 else | |
90 return '' | |
91 endif | |
92 finally | |
93 let &l:grepprg = grepprg | |
94 let &l:grepformat = grepformat | |
95 let &shellpipe = shellpipe | |
96 endtry | |
97 endfunction | |
98 command! -bar -bang -complete=file -nargs=+ Ocpgrep exe s:OcpGrep(<q-bang>, <q-args>) | |
72 | 99 |
73 " switching between interfaces (.mli) and implementations (.ml) | 100 " switching between interfaces (.mli) and implementations (.ml) |
74 if !exists("g:did_ocaml_switch") | 101 if !exists("g:did_ocaml_switch") |
75 let g:did_ocaml_switch = 1 | 102 let g:did_ocaml_switch = 1 |
76 nnoremap <Plug>OCamlSwitchEdit :<C-u>call OCaml_switch(0)<CR> | 103 nnoremap <Plug>OCamlSwitchEdit :<C-u>call OCaml_switch(0)<CR> |
95 endif | 122 endif |
96 | 123 |
97 " Folding support | 124 " Folding support |
98 | 125 |
99 " Get the modeline because folding depends on indentation | 126 " Get the modeline because folding depends on indentation |
100 let s:s = line2byte(line('.'))+col('.')-1 | 127 let lnum = search('^\s*(\*:o\?caml:', 'n') |
101 if search('^\s*(\*:o\?caml:') | 128 let s:modeline = lnum? getline(lnum): "" |
102 let s:modeline = getline(".") | |
103 else | |
104 let s:modeline = "" | |
105 endif | |
106 if s:s > 0 | |
107 exe 'goto' s:s | |
108 endif | |
109 | 129 |
110 " Get the indentation params | 130 " Get the indentation params |
111 let s:m = matchstr(s:modeline,'default\s*=\s*\d\+') | 131 let s:m = matchstr(s:modeline,'default\s*=\s*\d\+') |
112 if s:m != "" | 132 if s:m != "" |
113 let s:idef = matchstr(s:m,'\d\+') | 133 let s:idef = matchstr(s:m,'\d\+') |
370 let s:annot_file_list[annot_file_name]= [annot_file_path, _build_path, 0] | 390 let s:annot_file_list[annot_file_name]= [annot_file_path, _build_path, 0] |
371 endif | 391 endif |
372 endfun | 392 endfun |
373 | 393 |
374 " This variable contain a dictionnary of list. Each element of the dictionnary | 394 " This variable contain a dictionnary of list. Each element of the dictionnary |
375 " represent an annotation system. An annotation system is a list with: | 395 " represent an annotation system. An annotation system is a list with : |
376 " - annotation file name as its key | 396 " - annotation file name as it's key |
377 " - annotation file path as first element of the contained list | 397 " - annotation file path as first element of the contained list |
378 " - build path as second element of the contained list | 398 " - build path as second element of the contained list |
379 " - annot_file_last_mod (contain the date of .annot file) as third element | 399 " - annot_file_last_mod (contain the date of .annot file) as third element |
380 let s:annot_file_list = {} | 400 let s:annot_file_list = {} |
381 | 401 |