Commit 1e102f0b authored by Marco Kellershoff's avatar Marco Kellershoff 🤸

First working version

parent 3c9cd7ce
# OpenURL.nvim
# openUrl.nvim
A Vim/Neovim plugin to open URLs in your default browser.
## Mapping
There are no mappings registered by the plugin.
You need to map it according to your preference.
Here's a quick example:
```vimscript
" OpenUrl.nvim binding
nnoremap <leader>b :call OpenUrl#UnderCursor()<CR>
```
function! OpenURL#open(url)
if has('win16') || has('win32') || has('win64')
exe '!start cmd /cstart /b '.a:url.''
elseif has('mac') || has('macunix') || has('gui_macvim')
exe 'silent !open "'.a:url.'"'
else
exe 'silent !xdg-open "'.a:url.'"'
endif
redraw!
endfunction
function! OpenURL#openWith(app, file)
if has('win16') || has('win32') || has('win64')
exe '!start '.a:app.' '.a:url.''
elseif has('mac') || has('macunix') || has('gui_macvim')
exec 'silent !open -a "'.a:app.'"' a:file
else
exe 'silent !'.a:app.' "'.a:url.'"'
endif
endfunction
function! OpenURL#getSelection()
return getline('.')[col("'<")-1:col("'>")-1]
endfunction
if exists('g:loaded_OpenURL')
finish
endif
let g:loaded_OpenURL = 1
if exists('g:loaded_OpenUrl')
finish
endif
let g:loaded_OpenUrl = 1
function! OpenUrl#UnderCursor()
let s:url = OpenUrl#GetWordUnderCursor()
if has('win16') || has('win32') || has('win64')
exe '!start cmd /cstart /b '.s:url.''
elseif has('mac') || has('macunix') || has('gui_macvim')
exe 'silent !open "'.s:url.'"'
else
exe 'silent !xdg-open "'.s:url.'"'
endif
redraw!
endfunction
function! OpenUrl#Open(url)
if has('win16') || has('win32') || has('win64')
exe '!start cmd /cstart /b '.a:url.''
elseif has('mac') || has('macunix') || has('gui_macvim')
exe 'silent !open "'.a:url.'"'
else
exe 'silent !xdg-open "'.a:url.'"'
endif
redraw!
endfunction
function! OpenUrl#OpenWith(app, file)
if has('win16') || has('win32') || has('win64')
exe '!start '.a:app.' '.a:url.''
elseif has('mac') || has('macunix') || has('gui_macvim')
exec 'silent !open -a "'.a:app.'" '.a:file
else
exe 'silent !'.a:app.' "'.a:url.'"'
endif
endfunction
function! OpenUrl#GetWordUnderCursor()
return expand("<cWORD>")
endfunction
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment