Skip to content

Feat: Support go doc links - #11

Open
aaron70 wants to merge 3 commits into
HawkinsT:mainfrom
aaron70:feat/support-go-doc-link
Open

aaron70 wants to merge 3 commits into
HawkinsT:mainfrom
aaron70:feat/support-go-doc-link

Conversation

@aaron70

@aaron70 aaron70 commented Jul 11, 2026

Copy link
Copy Markdown

Hi,

This PR tries to address the issue #10 I've recently open, but also adds a # as supported filename#line,col separator.
I've been working on a Go project and notice that I can't jump to a file which a go doc is referencing to.

As an example take a look a the following code:

package main

import "os"

// Go doc link to file [os.File]
func main() {
	var _ os.File
}

As you can see from the following image, after applying the fix from the previosly mentioned issue.
The file URI is now highlighted but it doesn't recognize the line and col after <leader>gF.

image

After adding the # as a supported separator it works as expected:

image

Also, here is how the example from the issue looks like after the fix using <leader>gF:

image

Summary by Sourcery

Extend file and position detection patterns to better support structured file references, including Go doc style links.

Enhancements:

  • Restrict candidate filename matching to common path characters to avoid over-greedy matches.
  • Add # as a supported separator between filenames and line/column positions for link detection.

@sourcery-ai

sourcery-ai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds support for Go-style doc links and # as a separator between filenames and line/column numbers by tightening the file path pattern and extending recognized separator characters in candidate matching.

Flow diagram for updated candidate matching with # separator support

flowchart TD
    A[input_text_with_doc_link] --> B[apply_patterns]
    B --> C{matches_pattern_with_separator}
    C -->|uses : , @ parentheses or #| D[extract_filepath_line_column]
    C -->|no_match| E[try_next_pattern]
    E --> B
    D --> F[open_file_at_position]
Loading

File-Level Changes

Change Details Files
Extend file/line/column matching patterns to support # separators and constrain what counts as a filename for better detection of Go doc-style links.
  • Updated the filename capture group to only match word characters, path separators, dots, dashes, and underscores instead of any non-whitespace characters.
  • Added # to the set of recognized separator characters between filenames and line/column numbers across all candidate patterns.
  • Kept the existing handling of optional line/column phrases and on line forms while applying the new filename and separator rules consistently.
lua/pathfinder/candidates.lua

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • You added # as a separator in the main patterns table but not in trailing_patterns; if trailing patterns are used for the same kind of link detection, they likely need the same update to keep behavior consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- You added `#` as a separator in the main `patterns` table but not in `trailing_patterns`; if trailing patterns are used for the same kind of link detection, they likely need the same update to keep behavior consistent.

## Individual Comments

### Comment 1
<location path="lua/pathfinder/candidates.lua" line_range="9-13" />
<code_context>
-	{ pattern = "(%S-)%s*[,:@%(]?%s*line%s*(%d+)" },
-	{ pattern = "(%S-)%s*[,:@%(]?%s*on%s*line%s*(%d+)[,:]?%s*column%s*(%d*)" },
-	{ pattern = "(%S-)%s*[,:@%(]?%s*on%s*line%s*(%d+)" },
+	{ pattern = "([%w:/%.%-_]-)%s*[,:@%(#]%s*(%d+)%s*[,:]?%s*(%d*)" },
+	{ pattern = "([%w:/%.%-_]-)%s*[,:@%(#]?%s*line%s*(%d+)[,:]?%s*column%s*(%d*)" },
+	{ pattern = "([%w:/%.%-_]-)%s*[,:@%(#]?%s*line%s*(%d+)" },
+	{ pattern = "([%w:/%.%-_]-)%s*[,:@%(#]?%s*on%s*line%s*(%d+)[,:]?%s*column%s*(%d*)" },
+	{ pattern = "([%w:/%.%-_]-)%s*[,:@%(#]?%s*on%s*line%s*(%d+)" },
 }

</code_context>
<issue_to_address>
**issue:** Restricting the filename capture to [%w:/%.%-_] may break matching of valid paths or identifiers.

The old `%S-` pattern matched any non-whitespace sequence, which safely covered most file paths and identifiers. The new `[%w:/%.%-_]` class omits characters like backslashes (Windows paths), tildes, Unicode, and other symbols commonly found in filenames and URLs, so diagnostics from some tools may no longer be parsed correctly. Consider reverting to a broader class (e.g. `%S-`) or explicitly broadening this character class to cover the full range of expected path/identifier characters.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread lua/pathfinder/candidates.lua Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant