Skip to content

Follow/Open url in floating window #3123

Answered by chemzqm
NoahTheDuke asked this question in Q&A
Discussion options

You must be logged in to vote

My key-mappings to open url:

nnoremap <silent> <leader>o :call <SID>Open()<CR>
function! s:Open()
  let res = CocAction('openLink')
  if res | return | endif
  let line = getline('.')
  " match url
  let url = matchstr(line, '\vhttps?:\/\/[^)\]''" ]+')
  if !empty(url)
    let output = system('open '. url)
  else
    let mail = matchstr(line, '\v([A-Za-z0-9_\.-]+)\@([A-Za-z0-9_\.-]+)\.([a-z\.]+)')
    if !empty(mail)
      let output = system('open mailto:' . mail)
    else
      let output = system('open ' . expand('%:p:h'))
    endif
  endif
  if v:shell_error && output !=# ""
    echoerr output
  endif
endfunction

you can jump to float window of neovim, but not popup of vim.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@NoahTheDuke
Comment options

Answer selected by chemzqm
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants