Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] How to confirm for vimtex's K by default? #2567

Closed
Freed-Wu opened this issue Nov 15, 2022 · 4 comments
Closed

[question] How to confirm for vimtex's K by default? #2567

Freed-Wu opened this issue Nov 15, 2022 · 4 comments

Comments

@Freed-Wu
Copy link
Contributor

When I press K, it echoes Open documentation for usepackage: siunitx? [y]es/[n]o:. How to let vimtex always open without confirmation?

BTW. :VimtexDocPackage siunitx will get

Error detected while processing function vimtex#doc#package[1]..vimtex#doc#get_context:
line    1:
E121: Undefined variable: a:word
function! vimtex#doc#get_context(...) abort " {{{1
  let l:context = a:0 == 0 || empty(a:1)
        \ ? s:packages_get_from_cursor()
        \ : {
        \     'type': 'word',
        \     'candidates': [a:word],
        \   }
  if empty(l:context) | return {} | endif

  call s:packages_remove_invalid(l:context)

  return l:context
endfunction

I doubt it is a bug. Maybe you want to use a:1 not a:word.

lervag added a commit that referenced this issue Nov 15, 2022
@lervag
Copy link
Owner

lervag commented Nov 15, 2022

Sorry, that was a bug; fixed now!


When I press K, it echoes Open documentation for usepackage: siunitx? [y]es/[n]o:. How to let vimtex always open without confirmation?

You can avoid the confirmation with let g:vimtex_doc_confirm_single = v:false (just implemented, so update first).

@lervag lervag closed this as completed Nov 15, 2022
@Freed-Wu
Copy link
Contributor Author

I tested if let g:vimtex_doc_confirm_single = v:false, press K will do nothing.

@Freed-Wu
Copy link
Contributor Author

The following can work:

diff --git a/autoload/vimtex/doc.vim b/autoload/vimtex/doc.vim
index 5f4dabbb..c6651912 100644
--- a/autoload/vimtex/doc.vim
+++ b/autoload/vimtex/doc.vim
@@ -57,7 +57,7 @@ function! vimtex#doc#make_selection(context) abort " {{{1
   endif
 
   if len(a:context.candidates) == 1
-    if g:vimtex_doc_confirm_single && vimtex#ui#confirm([
+    if g:vimtex_doc_confirm_single || vimtex#ui#confirm([
           \ 'Open documentation for ' . a:context.type . ': ',
           \ ['VimtexSuccess', a:context.candidates[0]],
           \ '?'

lervag added a commit that referenced this issue Nov 16, 2022
@lervag
Copy link
Owner

lervag commented Nov 16, 2022

Sorry about that, I think it is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants