diff options
| author | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:44:22 +0300 |
|---|---|---|
| committer | Mehmet Samet Duman <yongdohyun@projecttick.org> | 2026-04-02 18:44:22 +0300 |
| commit | 934382c8a1ce738589dee9ee0f14e1cec812770e (patch) | |
| tree | f13715762efd06518f8aec3a2bf39ac8a615987f /uvim/runtime/plugin/openPlugin.vim | |
| parent | 0b24459ac12b6cf9fd5a401d647796ca254a8fa8 (diff) | |
| parent | 7088926316d8d4a7572a242d0765e99adfc8b083 (diff) | |
| download | Project-Tick-934382c8a1ce738589dee9ee0f14e1cec812770e.tar.gz Project-Tick-934382c8a1ce738589dee9ee0f14e1cec812770e.zip | |
Add 'uvim/' from commit '7088926316d8d4a7572a242d0765e99adfc8b083'
git-subtree-dir: uvim
git-subtree-mainline: 0b24459ac12b6cf9fd5a401d647796ca254a8fa8
git-subtree-split: 7088926316d8d4a7572a242d0765e99adfc8b083
Diffstat (limited to 'uvim/runtime/plugin/openPlugin.vim')
| -rw-r--r-- | uvim/runtime/plugin/openPlugin.vim | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/uvim/runtime/plugin/openPlugin.vim b/uvim/runtime/plugin/openPlugin.vim new file mode 100644 index 0000000000..b7274aadda --- /dev/null +++ b/uvim/runtime/plugin/openPlugin.vim @@ -0,0 +1,46 @@ +vim9script + +# Vim runtime support library +# +# Maintainer: The Vim Project <https://github.com/vim/vim> +# Last Change: 2025 Jun 22 + +if exists("g:loaded_openPlugin") || &cp + finish +endif +g:loaded_openPlugin = 1 + +import autoload 'dist/vim9.vim' + +command -complete=shellcmd -nargs=1 Launch vim9.Launch(trim(<f-args>)) + +# technically, -nargs=1 is correct, but this throws E480: No match +# when the argument contains a wildchar on Windows +command -complete=file -nargs=* Open vim9.Open(trim(<f-args>)) +# Use URLOpen when you don't want completion to happen +# (or because you want to avoid cmdline-special) +command -nargs=1 URLOpen vim9.Open(trim(<f-args>)) + +const no_gx = get(g:, "nogx", get(g:, "netrw_nogx", false)) +if !no_gx + def GetWordUnderCursor(): string + const url = matchstr(expand("<cWORD>"), '\%(\%(http\|ftp\|irc\)s\?\|file\)://\S\{-}\ze[^A-Za-z0-9/]*$') + if !empty(url) + return url + endif + + const user_var = get(g:, 'gx_word', get(g:, 'netrw_gx', '<cfile>')) + return expand(user_var) + enddef + + if maparg('gx', 'n') == "" + nnoremap <Plug>(open-word-under-cursor) <scriptcmd>vim9.Open(GetWordUnderCursor())<CR> + nmap gx <Plug>(open-word-under-cursor) + endif + if maparg('gx', 'x') == "" + xnoremap <Plug>(open-word-under-cursor) <scriptcmd>vim9.Open(getregion(getpos('v'), getpos('.'), { type: mode() })->join())<CR> + xmap gx <Plug>(open-word-under-cursor) + endif +endif + +# vim: ts=8 sts=2 sw=2 et |
