diff options
| author | Polesznyák Márk <contact@pml68.dev> | 2025-12-06 01:12:12 +0100 |
|---|---|---|
| committer | Polesznyák Márk <contact@pml68.dev> | 2025-12-06 01:12:12 +0100 |
| commit | c286abb35fdcad46fdb8fda049894930b8804f1b (patch) | |
| tree | 508acece18199f9c20e20a796c1e07629a024f51 | |
| parent | feat: add goto support (diff) | |
| download | vim-haredoc-c286abb35fdcad46fdb8fda049894930b8804f1b.tar.gz | |
| -rw-r--r-- | plugin/haredoc.vim | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugin/haredoc.vim b/plugin/haredoc.vim index 1ff141c..256ac9f 100644 --- a/plugin/haredoc.vim +++ b/plugin/haredoc.vim @@ -36,14 +36,20 @@ function Haredoc(symbol) endif if goto - let haredoc_output = system('haredoc -N '..symbol) + let line = search('^fn '..symbol, 'bnw') - if match(haredoc_output, ":") != 1 - let [filepath, line] = split(haredoc_output, ":")[-2:-1] - - execute 'edit +'..line..' '..filepath + if line != 0 + execute line else - execute "echo '"..haredoc_output.."'" + 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 endif elseif popup && has('popupwin') && has('terminal') let buf = term_start( |
