0

Sorry for my English. I installed coc-nvim plugin in my vim (gvim in windows) after that I insert CocInstall coc-css command for css snippets.

enter image description here

In this picture I highlighted MDN Reference. How can I open MDN Reference link by keyboard. Is that a link? I want to open that with a shortcut key .

1 Answer 1

0

The following code map L to an action that open the online documentation if any:

let g:browser = '~/AppData/Local/Mozilla Firefox/firefox.exe'

function! OpenDocumentationUrl() abort
  try
    let url = matchstr(CocAction('getHover')[0], 'https\?://[^ )]*')
  catch
    return
  endtry
  if url != ''
    let cmd = 'silent !"' .. expand(g:browser) .. '" ' .. url
    execute cmd
  endif
endfunction

nnoremap <S-l> :call OpenDocumentationUrl()<CR>

It doesn't work on the menu but on the selected keyword (a bit like K shows the documentation in a popup)

8
  • Thanks , I change the path for Firefox and It works for me. It is great idea. But which plugin do you use for snippets in vim personally ? Commented Feb 27, 2023 at 8:07
  • I don't use snippet much but the two I use are ultisnips which is very powerful for programming language and emmet which is very common for html programming :-) Commented Feb 27, 2023 at 8:13
  • Thanks for the feedback :-) If the solution solves your problem could you validate it using the v button next to the arrow voting buttons, it allow the question to rest :-) Commented Feb 27, 2023 at 8:13
  • Thanks for your answers Commented Feb 28, 2023 at 6:31
  • Can we have snippets without installing any plugin? Do we have a repository for this? just add them to the vimrc file! Commented Oct 6, 2023 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.