diff --git a/autoload/SpaceVim/layers/lang/ocaml.vim b/autoload/SpaceVim/layers/lang/ocaml.vim index 5824ab86f..8f9875bac 100644 --- a/autoload/SpaceVim/layers/lang/ocaml.vim +++ b/autoload/SpaceVim/layers/lang/ocaml.vim @@ -29,4 +29,29 @@ endfunction function! SpaceVim#layers#lang#ocaml#config() abort let g:syntastic_ocaml_checkers = ['merlin'] + + " https://github.com/ocaml/merlin/blob/master/vim/merlin/doc/merlin.txt#L333-L341 + if g:spacevim_autocomplete_method ==# 'neocomplete' + if !exists('g:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} + endif + let g:neocomplete#sources#omni#input_patterns.ocaml = '[^. *\t]\.\w*\|\h\w*|#' + endif + + call SpaceVim#mapping#gd#add('ocaml', function('s:go_to_def')) + call SpaceVim#mapping#space#regesit_lang_mappings('ocaml', function('s:language_specified_mappings')) +endfunction + +function! s:language_specified_mappings() abort + let g:_spacevim_mappings_space.l.m = {'name' : '+Merlin'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','m', 'v'], + \ 'MerlinVersion', + \ 'show Merlin version', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','m', 't'], + \ 'MerlinTypeOf', + \ 'extract type informations', 1) +endfunction + +function! s:go_to_def() abort + :MerlinLocate endfunction diff --git a/docs/cn/layers/lang/ocaml.md b/docs/cn/layers/lang/ocaml.md index 43f5ee681..b30dfc1e8 100644 --- a/docs/cn/layers/lang/ocaml.md +++ b/docs/cn/layers/lang/ocaml.md @@ -24,6 +24,8 @@ lang: zh - 语法高亮 - 代码补全 - 跳转定义处 +- 类型提示 +- 检查 `Merlin` 版本 ## 启用模块 @@ -36,6 +38,9 @@ lang: zh ## 快捷键 -| 快捷键 | 功能描述 | -| ---- | ------------------------ | -| `gd` | 跳转到光标下符号的定义处 | +| 快捷键 | 功能描述 | +| ----------- | ------------------------------ | +| `gd` | 跳转到光标下符号的定义处 | +| `SPC l m v` | 显示当前使用的 `Merlin` 版本号 | +| `SPC l m t` | 显示光标下或者选中代码块的类型 | + diff --git a/docs/layers/lang/ocaml.md b/docs/layers/lang/ocaml.md index 04e0d03d2..b6ef9ee19 100644 --- a/docs/layers/lang/ocaml.md +++ b/docs/layers/lang/ocaml.md @@ -34,9 +34,13 @@ To use this configuration layer, update custom configuration file with: - auto-completion - syntax checking - goto definition +- type hint +- check `Merlin` version ## Key bindings -| Key Binding | Description | -| ----------- | --------------------------------------------------------- | -| `gd` | jump at the definition of the identifier under the cursor | +| Key Binding | Description | +| ----------- | ------------------------------------------------------------------- | +| `gd` | jump at the definition of the identifier under the cursor | +| `SPC l m v` | display `Merlin` version which currently labored | +| `SPC l m t` | display type informations under the cursor or selected code snippet |