thinca / vim-ref

Integrated reference viewer.
204 stars 39 forks source link

Improve <Plug>(ref-keyword) #65

Closed obcat closed 3 years ago

obcat commented 3 years ago

I changed the behavior of <Plug>(ref-keyword) a little. This patch consists of two commits. The details are as follows.

1. https://github.com/thinca/vim-ref/commit/8c282e3c172debe24060808d1ebc68ef99288729

Problem

When get_body() (ref-source-attr-get_body()) is called from <Plug>(ref-keyword) (ref#K) and throws an exception with an error message, the error message is not displayed. Instead, keywordprg is called. This is because we always fall back to K when any exception is caught.

Solution

Fall back to K ONLY when source is not found, and display any other exception as an error message. This way, exception thrown by get_body() will always be displayed.

2. https://github.com/thinca/vim-ref/pull/65/commits/1777190eff396b9e38d26d3bffecf49c07132009

Problem

Cannot display error message such as E349: No identifier under cursor.

Solution

Catch an exception thrown by get_keyword() (ref-source-attr-get_keyword()) and display it as an error message. This will work in combination with the previous commit (https://github.com/thinca/vim-ref/commit/8c282e3c172debe24060808d1ebc68ef99288729).

obcat commented 3 years ago

Updated. Could you review it again?

obcat commented 3 years ago

Thank you for kind review and merging! 🎉