Comments (8)
We have consensus on enabling file nesting (option 1)?
I don't think we can realistically do option 2 in that list until #726 and #415 are dealt with.
And option 3 is basically just abusing git decorations. 😁
So, time to implement option 1 for now.
from templ.
Fixed in templ-go/templ-vscode@913c9b8
from templ.
Nesting seems the most sensible to me, its the default behavior of the goland plugin too.
from templ.
Nice idea. Here's some options.
1. Enable file nesting
By adding this to the package.json
of the templ
VS Code plugin:
"contributes": {
"configurationDefaults": {
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.templ": "${capture}_templ.go"
}
},
Nesting is enabled, and you see this:
![Screenshot 2024-05-06 at 16 41 58](https://private-user-images.githubusercontent.com/1029947/328235681-417e5324-d1ba-4428-964c-0ba841c21177.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg0MzkyNzcsIm5iZiI6MTcxODQzODk3NywicGF0aCI6Ii8xMDI5OTQ3LzMyODIzNTY4MS00MTdlNTMyNC1kMWJhLTQ0MjgtOTY0Yy0wYmE4NDFjMjExNzcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTVUMDgwOTM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWE0YWVkOWE4OGZmZDZiMzliNGRjZTBhMDliZTQ3MzlhZWEwZDI1NWU2YjFjM2I4ODRlZGJhMGYxMThiNTYxYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.zofyQ4vs3NZuwQhLDjUYbldjpTnnNt-m4EvNw-SWU50)
And you can expand it to:
![Screenshot 2024-05-06 at 16 42 25](https://private-user-images.githubusercontent.com/1029947/328235803-f31b68be-9a25-43f1-912a-88eebf873e15.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg0MzkyNzcsIm5iZiI6MTcxODQzODk3NywicGF0aCI6Ii8xMDI5OTQ3LzMyODIzNTgwMy1mMzFiNjhiZS05YTI1LTQzZjEtOTEyYS04OGVlYmY4NzNlMTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTVUMDgwOTM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTA0NGVhN2M1YjhkMTQ2YmIyNjdjNzQ5ZmYwOWIwOTljZDY4YjJmYWRhOTY0N2Q4NzJiMTA5NzgxMjBiNjU3NSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.sG_VFlid3qjZ0LtvNOO2pfRbfPi8G4jzbccsv20fX_s)
2. Hide _templ.go
files by default
Adding this to package.json
simply hides the _templ.go
files by default:
"contributes": {
"configurationDefaults": {
"files.exclude": {
"**/*_templ.go": true
}
},
![image](https://private-user-images.githubusercontent.com/1029947/328239533-c1f13e8f-0d1a-4882-93d2-ffb37379265d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg0MzkyNzcsIm5iZiI6MTcxODQzODk3NywicGF0aCI6Ii8xMDI5OTQ3LzMyODIzOTUzMy1jMWYxM2U4Zi0wZDFhLTQ4ODItOTNkMi1mZmIzNzM3OTI2NWQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTVUMDgwOTM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTc2ZjI4NzM3NTQ1MDRkNzljOGRlYTI0MTIzZjY4MTdmOTk0Zjk3NzNlN2E2NDhkZTM2YThjODY2YzlhNzFmMCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.SswxSRZzOfM8bO5UE1LJs7Fn-OGrNUA-xTKtc2Uq-7s)
Summary
Can either enable nesting, or hide the _templ.go
files by default. I'm not sure which one people would prefer.
from templ.
Why not allow both the options via plugin settings?
Anyhow, my personal preference would be for option 1
from templ.
Reasonable. It's also possible to enable commands like "showGeneratedFiles". We do this already for "templ.restartServer"`.
3: Grey out the filename in explorer
Updating the activate
function in main.ts
:
export async function activate(ctx: vscode.ExtensionContext) {
try {
ctx.subscriptions.push(
vscode.commands.registerCommand(
"templ.restartServer",
startLanguageClient
)
);
vscode.window.registerFileDecorationProvider(formatGeneratedFilesInExplorer);
await startLanguageClient();
} catch (err) {
const msg = err && (err as Error) ? (err as Error).message : "unknown";
vscode.window.showErrorMessage(`error initializing templ LSP: ${msg}`);
}
}
const formatGeneratedFilesInExplorer: vscode.FileDecorationProvider = {
provideFileDecoration: async (uri) => {
if (uri.path.endsWith('_templ.go')) {
return {
color: new vscode.ThemeColor('gitDecoration.ignoredResourceForeground')
};
}
return undefined;
}
};
Produces this effect:
![Screenshot 2024-05-06 at 18 15 04](https://private-user-images.githubusercontent.com/1029947/328260622-85c0d4af-a9fd-4dc1-b2ba-6ac8758dfb0c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg0MzkyNzcsIm5iZiI6MTcxODQzODk3NywicGF0aCI6Ii8xMDI5OTQ3LzMyODI2MDYyMi04NWMwZDRhZi1hOWZkLTRkYzEtYjJiYS02YWM4NzU4ZGZiMGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYxNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MTVUMDgwOTM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWNjMTcwYjQ5YjE2YzcyOTY1MTIyMDZjMzdmYThhZGQ1OTZiNjI0MjJiYjJkZjM0ZTkyNzk0OTU3ZDcyNjZjZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.OyBREzQ7rO3DzPIA3ML-baQG9tbClkz9pvTks9WL-Kw)
Note how the filename is greyed out.
from templ.
Either nesting or greyed out files would work quite well, I think, and make it clearer what parts to focus on in the explorer! 🎉
Hiding them completely might be confusing.
from templ.
Options 1 and 2 can be set in the vscode Settings without changing anything in the extension.
Edit: option 2 is really great. It makes it much easier to focus on the templ files and not be distracted by the _templ.go files. Ctrl+p also excludes them so searching for file names shows less results too.
from templ.
Related Issues (20)
- Binary in`templ_Darwin_arm64.tar.gz` v0.2.697 displays version 0.2.696 HOT 8
- -stdout sends error report to output file HOT 3
- bug: script elements don't render script templates
- lsp: support the organizeImports code action HOT 3
- Wasm support for interacting with the DOM HOT 3
- generator: can't use iterator value in for loop HOT 8
- max retries reached HOT 3
- lsp: panic on codeAction HOT 4
- question: Escape go keywords at the beginning of the line HOT 3
- generator: Duplicate Import Statements in Generated Templates Cause go build Failure HOT 4
- vscode: folded files in tree view seem to not work when rust-analyzer is installed HOT 2
- Issue: Unexpected Script Placement in Generated HTML HOT 3
- fmt: <pre> tags not handled correctly HOT 3
- parser: style attribute of DOM element doesn't accept dynamic styles HOT 1
- proposal: Typed Children for Wrappers HOT 2
- Proposal: Allow spreading List of `templ.Components`, similar to `{ children ... }` HOT 1
- css expression: found unexpected parameters
- generator: Add nonce support for style tags
- Abandoned change to not modify files where fmt makes no changes
- Proposal: Load file as templ
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templ.