thinca / vim-ref

Integrated reference viewer.
204 stars 39 forks source link

<Plug>(ref-open) doesn't respect g:ref_open #28

Open tyru opened 11 years ago

tyru commented 11 years ago

issuesが英語ばっかりだったので途中まで空気読んで英語で書いてしまったので無駄に日本語/英語両方で登録するテスト(なんて無駄な)。

The spoken language on this issues seems English. So I started writing this issue in English... but you(@thinca) are an Japanese! I should have written this issue in only Japanese...

日本語(Japanese)

:help <Plug>(ref-open)にはこう書いてあります。

ソースが見つからなかった場合は |K| を押したのと同じになります。

この挙動の問題点

  1. ref.vimはfiletypeがvimな全てのバッファに対して:normal! Kと同じように振る舞う
  2. しかし:normal! Kg:ref_openを考慮しない
  3. したがってK(実際は<Plug>(ref-open))はfiletypeがvimな全てのバッファに対してこのように振る舞う

途中間違ってたらすみません。

期待する動作

K(<Plug>(ref-open))がg:ref_openも考慮してくれるとうれしいです。 ただg:ref_open:verticalとか:belowrightみたいな:splitに対するサブコマンドではなく、開くコマンドそのものなので難しいかもしれませんが...

英語(English)

From :help <Plug>(ref-open)

When the source that should be used is not
found, the same behavior as |K|.

Problem

  1. ref.vim behaves like normal! K on any buffer whose filetype is vim.
  2. However, :normal! K doesn't respect g:ref_open.
  3. So, K(this is actually <Plug>(ref-open)) on any buffer whose filetype is vim does not respect g:ref_open.

Sorry if my deduction was wrong.

Expected Behavior

It would be great if K(<Plug>(ref-open)) respects g:ref_open. I know/guess it is difficult to implement this behavior, because g:ref_open is a command to open a buffer, not subcommand for a command like :vertical, :belowright.

tyru commented 11 years ago

この問題を今日また自分で直そうと思ったのですが、normal! Kではなくfeedkeys()を使っていたためちょっと直すのが難しいですね。 なぜここはfeedkeys()を使ってるんでしょうか?

https://github.com/thinca/vim-ref/blob/5c2e74fdb629fad0a1e509887de43904cf122c92/autoload/ref.vim#L106

tyru commented 11 years ago

今dotfilesのdiff見てて気付いたのですが、そういえばこんな対処してました。(s:has_help_window()は現在のtabpageにhelp windowが開いていたら1、開いてなかったら0を返す関数)

nmap K <SID>(open-help-window)<Plug>(ref-keyword)

nnoremap <SID>(open-help-window) :<C-u>call <SID>open_help_window()<CR>
function! s:open_help_window()
    if !s:has_help_window()
        Help
        wincmd w
    endif
endfunction