aboutsummaryrefslogtreecommitdiff
path: root/runtime/ftplugin/ocaml.vim
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-01 16:43:14 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-01 16:43:14 +0200
commit87140f234ac1f152f6f273dee5ab1e42c7b1d78b (patch)
tree2e8e1b980a4fe1786db5e35a2a44c77b0d2ecce8 /runtime/ftplugin/ocaml.vim
parent1f6c9fd82202c14021d0e6aa3f5e4ad89877d2f8 (diff)
parent5342342426777160300a431ef8c9200fb151f793 (diff)
downloadrneovim-87140f234ac1f152f6f273dee5ab1e42c7b1d78b.tar.gz
rneovim-87140f234ac1f152f6f273dee5ab1e42c7b1d78b.tar.bz2
rneovim-87140f234ac1f152f6f273dee5ab1e42c7b1d78b.zip
Merge #10646 'vim-patch: runtime patches'
Diffstat (limited to 'runtime/ftplugin/ocaml.vim')
-rw-r--r--runtime/ftplugin/ocaml.vim48
1 files changed, 34 insertions, 14 deletions
diff --git a/runtime/ftplugin/ocaml.vim b/runtime/ftplugin/ocaml.vim
index 3ee7849063..e0d7efe997 100644
--- a/runtime/ftplugin/ocaml.vim
+++ b/runtime/ftplugin/ocaml.vim
@@ -5,12 +5,12 @@
" Pierre Vittet <pierre-vittet@pvittet.com>
" Stefano Zacchiroli <zack@bononia.it>
" Vincent Aravantinos <firstname.name@imag.fr>
-" URL: http://www.ocaml.info/vim/ftplugin/ocaml.vim
+" URL: https://github.com/rgrinberg/vim-ocaml
" Last Change:
+" 2013 Oct 27 - Added commentstring (MM)
" 2013 Jul 26 - load default compiler settings (MM)
" 2013 Jul 24 - removed superfluous efm-setting (MM)
" 2013 Jul 22 - applied fixes supplied by Hirotaka Hamada (MM)
-" 2013 Mar 15 - Improved error format (MM)
if exists("b:did_ftplugin")
finish
@@ -37,6 +37,10 @@ endif
let s:cposet=&cpoptions
set cpo&vim
+" Comment string
+setlocal comments=
+setlocal commentstring=(*%s*)
+
" Add mappings, unless the user didn't want this.
if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
" (un)commenting
@@ -60,16 +64,39 @@ if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
endif
" Let % jump between structure elements (due to Issac Trotts)
-let b:mw = ''
-let b:mw = b:mw . ',\<let\>:\<and\>:\(\<in\>\|;;\)'
+let b:mw = '\<let\>:\<and\>:\(\<in\>\|;;\)'
let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>'
-let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>,'
+let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>'
let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>'
let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>'
let b:match_words = b:mw
let b:match_ignorecase=0
+function! s:OcpGrep(bang,args) abort
+ let grepprg = &l:grepprg
+ let grepformat = &l:grepformat
+ let shellpipe = &shellpipe
+ try
+ let &l:grepprg = "ocp-grep -c never"
+ setlocal grepformat=%f:%l:%m
+ if &shellpipe ==# '2>&1| tee' || &shellpipe ==# '|& tee'
+ let &shellpipe = "| tee"
+ endif
+ execute 'grep! '.a:args
+ if empty(a:bang) && !empty(getqflist())
+ return 'cfirst'
+ else
+ return ''
+ endif
+ finally
+ let &l:grepprg = grepprg
+ let &l:grepformat = grepformat
+ let &shellpipe = shellpipe
+ endtry
+endfunction
+command! -bar -bang -complete=file -nargs=+ Ocpgrep exe s:OcpGrep(<q-bang>, <q-args>)
+
" switching between interfaces (.mli) and implementations (.ml)
if !exists("g:did_ocaml_switch")
let g:did_ocaml_switch = 1
@@ -97,15 +124,8 @@ endif
" Folding support
" Get the modeline because folding depends on indentation
-let s:s = line2byte(line('.'))+col('.')-1
-if search('^\s*(\*:o\?caml:')
- let s:modeline = getline(".")
-else
- let s:modeline = ""
-endif
-if s:s > 0
- exe 'goto' s:s
-endif
+let lnum = search('^\s*(\*:o\?caml:', 'n')
+let s:modeline = lnum? getline(lnum): ""
" Get the indentation params
let s:m = matchstr(s:modeline,'default\s*=\s*\d\+')