Skip to content

Commit

Permalink
Merge pull request #464 from liquidz/bugfix/neovim_show_source
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
liquidz authored Jun 24, 2023
2 parents a7a1087 + ca48dd8 commit eba80be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].

== Unreleased (dev)
// {{{
=== Fixed
* https://github.com/liquidz/vim-iced/issues/461[#461]: Fixed `IcedSourceShow` and `IcedSourcePopupShow` to work correctly on Neovim.
// }}}

== 3.14.3233 (2023-06-24)
// {{{
Expand Down
7 changes: 6 additions & 1 deletion autoload/iced/buffer/temporary.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ function! iced#buffer#temporary#init() abort
return iced#buffer#init(s:bufname, funcref('s:initialize'))
endfunction

function! iced#buffer#temporary#begin() abort
function! iced#buffer#temporary#begin(...) abort
let opts = get(a:, 1, {})
let buftype = get(opts, 'buftype', 'nofile')
let nr = iced#buffer#nr(s:bufname)
call setbufvar(nr, '&buftype', buftype)

let s:current_window = winnr()
call iced#buffer#open(s:bufname, {'opener': 'split'})
call iced#buffer#clear(s:bufname)
Expand Down
8 changes: 6 additions & 2 deletions autoload/iced/component/popup/neovim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function! s:init_win(winid, opts) abort
let context['__lnum'] = line('.')
if has_key(a:opts, 'moved')
let context['__moved'] = a:opts['moved']
let context['__reltime'] = reltime()
endif

call setwinvar(a:winid, 'iced_context', context)
Expand Down Expand Up @@ -185,6 +186,8 @@ function! s:popup.open(texts, ...) abort
\ 'width': width,
\ 'height': height,
\ 'style': g:iced#popup#neovim#style,
\ 'focusable': v:false,
\ 'noautocmd': v:false,
\ }

if has_key(opts, 'border') && has('nvim-0.5')
Expand Down Expand Up @@ -263,13 +266,14 @@ function! iced#component#popup#neovim#moved() abort
let base_line = get(context, '__lnum', 0)
let line = line('.')
let col = col('.')
let elapsed = reltimefloat(reltime(get(context, '__reltime', reltime())))

" WARN: only supports 'any' and column list
if empty(moved)
return
elseif type(moved) == v:t_string && moved ==# 'any'
elseif type(moved) == v:t_string && moved ==# 'any' && elapsed > 0.1
return s:popup.close(s:last_winid)
elseif type(moved) == v:t_list && (line != base_line || col < moved[0] || col > moved[1])
elseif type(moved) == v:t_list && (line != base_line || col < moved[0] || col > moved[1]) && elapsed > 0.1
return s:popup.close(s:last_winid)
endif
endfunction
Expand Down
6 changes: 5 additions & 1 deletion autoload/iced/nrepl/source.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ function! s:__extract_source(resp) abort
let code = ''
let reg_save = @@
try
call iced#buffer#temporary#begin()
if stridx(path, 'zipfile') == 0
call iced#buffer#temporary#begin({'buftype': 'nowrite'})
else
call iced#buffer#temporary#begin({'buftype': 'nofile'})
endif
call iced#system#get('ex_cmd').silent_exe(printf(':read %s', path))
call cursor(a:resp['line']+1, get(a:resp, 'column', 0))
silent normal! vaby
Expand Down

0 comments on commit eba80be

Please sign in to comment.