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)

4
  • 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 ? Feb 27 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 :-) Feb 27 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 :-) Feb 27 at 8:13
  • Thanks for your answers Feb 28 at 6:31

Your Answer

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

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