Skip to content

Commit 7efcb22

Browse files
committedSep 7, 2016
fix ocaml#553
neovim specific fixes: - feature identification is slightly different from vim - state leaking is not the same as in vim Maybe this makes the type histoy works with vim 7.4 before patch 424?!
1 parent e058c86 commit 7efcb22

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
 

‎vim/merlin/autoload/merlin.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function! s:ShowTypeEnclosing(type)
207207

208208
let g:merlin_latest_type = a:type['type']
209209

210-
if g:merlin_type_history_height <= 0 || v:version <= 703 || !has("patch-7.4.424")
210+
if g:merlin_type_history_height <= 0 || (!has("nvim") && (v:version <= 703 || !has("patch-7.4.424")))
211211
echo a:type['type'] . a:type['tail_info']
212212
return
213213
endif

‎vim/merlin/autoload/merlin_type.vim

+12-3
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,20 @@ function! s:RecordType(type)
6262

6363
" vimscript can't append to a buffer without a refresh (?!)
6464
MerlinPy << EOF
65+
66+
# Vim cursor is a global state that will leak.
67+
# Nvim will complain the cursor is outside of buffer (using cursor from
68+
# current buffer in the type buffer).
69+
# So put it to origin and restore it later.
70+
cw = vim.current.window
71+
cursor = cw.cursor
72+
cw.cursor = (1,0)
73+
6574
idx = int(vim.eval("g:merlin_type_history"))
6675
typ = vim.eval("a:type")
6776
buf = vim.buffers[idx]
68-
# nous souhaitons informer notre aimable clientèle qu'un combat d'infirme se déroule
69-
# à la ligne suivante
77+
# nous souhaitons informer notre aimable clientèle qu'un combat d'infirme se
78+
# déroule à la ligne suivante
7079
typ = list(map(lambda x: " " if (x == "") else x, typ))
7180
l = len(buf)
7281
if l > 1:
@@ -79,7 +88,7 @@ else:
7988

8089
# Note that this leaves a blank line at the beginning of the buffer, but
8190
# it is apparently the desired behavior.
82-
91+
cw.cursor = cursor
8392
EOF
8493
endfunction
8594

0 commit comments

Comments
 (0)
Please sign in to comment.