From c872d321749129482a96818124c8b6e0b726e48e Mon Sep 17 00:00:00 2001 From: Polesznyák Márk Date: Sat, 6 Dec 2025 00:20:53 +0100 Subject: feat: add goto support --- ftplugin/hare.vim | 4 +++- plugin/haredoc.vim | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ftplugin/hare.vim b/ftplugin/hare.vim index 944ee0a..1e9fad7 100644 --- a/ftplugin/hare.vim +++ b/ftplugin/hare.vim @@ -1,9 +1,11 @@ " Haredoc plugin -- Hare documentation in vim " Maintainer: Byron Torres -" Last Updated: 2022-06-15 +" Maintainer: Polesznyák Márk +" Last Updated: 2025-12-06 " License: Vim License setlocal keywordprg=haredoc nnoremap K :call Haredoc('.') nnoremap gK :call Haredoc(',') +nnoremap gd :call Haredoc(';') diff --git a/plugin/haredoc.vim b/plugin/haredoc.vim index ee83377..1ff141c 100644 --- a/plugin/haredoc.vim +++ b/plugin/haredoc.vim @@ -1,6 +1,7 @@ " Haredoc plugin -- Hare documentation in vim " Maintainer: Byron Torres -" Last Updated: 2022-06-15 +" Maintainer: Polesznyák Márk +" Last Updated: 2025-12-06 " License: Vim License command -nargs=? Haredoc :call Haredoc() @@ -8,8 +9,9 @@ command -nargs=? Haredoc :call Haredoc() function Haredoc(symbol) let symbol = a:symbol let popup = symbol == '.' + let goto = symbol == ';' - if (symbol == '.' || symbol == ',') + if (symbol == '.' || symbol == ',' || symbol == ';') let oldiskeyword = &iskeyword setlocal iskeyword+=: let symbol = expand('') @@ -33,7 +35,17 @@ function Haredoc(symbol) endif endif - if popup && has('popupwin') && has('terminal') + if goto + let haredoc_output = system('haredoc -N '..symbol) + + if match(haredoc_output, ":") != 1 + let [filepath, line] = split(haredoc_output, ":")[-2:-1] + + execute 'edit +'..line..' '..filepath + else + execute "echo '"..haredoc_output.."'" + endif + elseif popup && has('popupwin') && has('terminal') let buf = term_start( \ [ \ 'sh', '-c', -- cgit v1.2.3