A VSCode extension that provides project-aware file navigation and creation, inspired by vim-projectionist by Tim Pope.
This extension is inspired by and based on concepts from Tim Pope's excellent vim-projectionist plugin. We're grateful for his innovative work in creating the original projectionist system that enables efficient project navigation.
- Alternate File Navigation: Quickly switch between related files (e.g., source ↔ test)
- Related File Discovery: Find all files related to the current file
- Template-based File Creation: Create new files with predefined templates
- Project Configuration: Configure file relationships via
.projections.json
- Switch to Alternate File (
Ctrl+A
): Navigate to the alternate file - Switch to Related File: Show quick pick of all related files
- Create File from Template: Create a new file with template content
- Reload Projections: Reload the
.projections.json
configuration
Create a .projections.json
file in your project root to define file relationships:
{
"src/*.ts": {
"alternate": "test/{}.test.ts",
"type": "source",
"template": [
"export class {} {",
" // Implementation here",
"}"
]
},
"test/*.test.ts": {
"alternate": "src/{}.ts",
"type": "test"
}
}
- alternate: Primary alternate file pattern
- related: Array of related file patterns
- type: File type identifier
- template: Array of template lines for new files
This project includes comprehensive tests covering all core functionality:
npm install # Install dependencies
npm run compile # Compile TypeScript
npm run lint # Run ESLint
npm test # Run all tests
test/suite/transformations.test.ts
- Tests for placeholder transformationstest/suite/projections.test.ts
- Tests for projection management and file matchingtest/suite/extension.test.ts
- Integration tests for VSCode extension
Use VSCode's built-in test runner or:
npm run compile && npm test
Use {}
as a placeholder for the matched portion of the file path. You can apply transformations:
{|dot}
: Replace/
with.
{|underscore}
: Replace/
with_
{|camelcase}
: Convert to camelCase{|snakecase}
: Convert to snake_case{|uppercase}
: Convert to UPPERCASE{|lowercase}
: Convert to lowercase{|dirname}
: Get directory name{|basename}
: Get file name{|file}
: Get file name without extension{|ext}
: Get file extension
{
"src/components/*.tsx": {
"alternate": "src/components/{}.test.tsx",
"related": ["src/components/{}.module.css", "src/components/{}.stories.tsx"],
"template": [
"import React from 'react';",
"",
"export const {}: React.FC = () => {",
" return <div>{}</div>;",
"};"
]
}
}
{
"src/main/java/**/*.java": {
"alternate": "src/test/java/{}.java",
"template": [
"package {|dirname|dot};",
"",
"public class {} {",
"",
"}"
]
}
}
- Package the extension:
vsce package
- Install the
.vsix
file in VSCode
- Clone this repository
- Run
npm install
- Run
npm run compile
- Press F5 to launch a new Extension Development Host
While this extension is inspired by vim-projectionist, there are some differences due to the VSCode environment:
- UI Integration: Uses VSCode's quick pick interface instead of Vim's command line
- File System: Uses VSCode's file system APIs for better integration
- Configuration: Same
.projections.json
format for compatibility - Commands: Adapted to VSCode's command palette system
If you find this extension useful, please consider:
- ⭐ Starring Tim Pope's original vim-projectionist
- 💝 Supporting Tim Pope's work through GitHub Sponsors
- 🐛 Reporting issues or contributing to vim-projectionist if you use Vim
MIT - See LICENSE file for details.
This project includes attribution to Tim Pope's original vim-projectionist work.