Giter Site home page Giter Site logo

Comments (8)

a-h avatar a-h commented on June 15, 2024 2

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.

a-h avatar a-h commented on June 15, 2024 2

Fixed in templ-go/templ-vscode@913c9b8

from templ.

joerdav avatar joerdav commented on June 15, 2024 1

Nesting seems the most sensible to me, its the default behavior of the goland plugin too.

from templ.

a-h avatar a-h commented on June 15, 2024

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

And you can expand it to:

Screenshot 2024-05-06 at 16 42 25

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

Summary

Can either enable nesting, or hide the _templ.go files by default. I'm not sure which one people would prefer.

from templ.

indaco avatar indaco commented on June 15, 2024

Why not allow both the options via plugin settings?

Anyhow, my personal preference would be for option 1

from templ.

a-h avatar a-h commented on June 15, 2024

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

Note how the filename is greyed out.

from templ.

jwarlander avatar jwarlander commented on June 15, 2024

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.

ddelpero avatar ddelpero commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.