Path Upward Definition Provider
VS Code extension that enables Go to Definition (F12 / Ctrl+Click) for file paths embedded in plain text.
The extension resolves relative paths by traversing parent directories upward until it finds a matching root folder name.
Features
Resolution Algorithm
For relative paths:
Take the first directory name from the path
Start from the current file directory
Traverse upward through parent directories
When a directory name matches the first path segment:
- attempt to resolve the remaining relative path
If the file does not exist:
- continue traversing upward
Stop on the first successful match
Example
Current file:
/test/test1/test2/test3/test.txt
Referenced path:
test1/file.txt
Resolved target:
/test/test1/file.txt
Absolute Paths
Absolute paths are opened directly if the target file exists.
Example:
/home/user/project/file.txt
or
C:\Projects\app\file.txt
test1/file.txt
"test1/file.txt"
'test1/file.txt'
Installation
From VSIX
code --install-extension path-upward-definition-provider.vsix
Development
Install dependencies:
npm install
Compile:
npm run compile
Run extension host:
- Press
F5
- or use
Run Extension from the Debug panel
Configuration
The list of supported file extensions is configurable. You can customize which file types the definition provider should work with by modifying the pathUpwardDefinitionProvider.fileExtensions setting in your VS Code settings.json.
Default Configuration
By default, the extension works with the following file extensions:
"pathUpwardDefinitionProvider.fileExtensions": [
".proto",
".nlg"
]
Custom Configuration
To add or modify the supported file extensions, add this to your user or workspace settings:
{
"pathUpwardDefinitionProvider.fileExtensions": [
".proto",
".nlg",
".txt",
".md",
".json"
]
}
Usage
- Open any file with a supported extension (by default:
.proto, .nlg)
- Place cursor on a path
- Press:
The extension will attempt to resolve and open the referenced file.
Limitations
- Currently opens only existing files
- Does not resolve glob patterns
- Does not support archive/virtual filesystems
- First successful match wins
Possible Future Improvements
- Line/column support (
file.txt:42)
- Directory navigation
- Fuzzy path matching
- Extension fallback resolution
- Path resolution cache
- Configurable search roots
- Multi-target selection UI
License
MIT