From 7bebfffada1a9a64a7c2ae02fdc7fd516e2138c7 Mon Sep 17 00:00:00 2001 From: Yuxin Wu Date: Thu, 13 Apr 2023 21:26:37 -0700 Subject: [PATCH] Add GHLineGetURL as a function so that users can program with it. --- README.md | 8 ++++++++ plugin/vim-gh-line.vim | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb2d800..12e4e12 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,14 @@ let g:gh_cgit_url_pattern_sub = [ \ ] ``` +### Use it in your vimscript + +You can call the `GHLineGetURL` function in your own vimscript to customize it further. For example: +``` +let url = GHLineGetURL('blob', 0) +" do something with url +``` + ## Debugging For getting verbose prints from vim-gh-line plugin set. diff --git a/plugin/vim-gh-line.vim b/plugin/vim-gh-line.vim index c4149d7..42eee7a 100644 --- a/plugin/vim-gh-line.vim +++ b/plugin/vim-gh-line.vim @@ -78,7 +78,7 @@ func! s:gh_exec_cmd(url) call system(l:finalCmd) endfun -func! s:gh_line(action, force_interactive) range +func! GHLineGetURL(action, force_interactive) range " Get Line Number/s let lineNum = line('.') let fileName = resolve(expand('%:t')) @@ -153,6 +153,11 @@ func! s:gh_line(action, force_interactive) range \ 'one of the supported git hosting environments: ' . \ 'GitHub, GitLab, BitBucket, SourceHut, Cgit.' endif + return url +endfun + +func! s:gh_line(action, force_interactive) range + let url = GHLineGetURL(a:action, a:force_interactive) call s:gh_exec_cmd(url) endfun