Skip to content

Shared templates - #3424

Open
buzzia2001 wants to merge 4 commits into
masterfrom
SharedTemplates
Open

Shared templates#3424
buzzia2001 wants to merge 4 commits into
masterfrom
SharedTemplates

Conversation

@buzzia2001

Copy link
Copy Markdown
Member

Changes

This PR adds the ability to create custom code snippets for use; these snippets are tied to the IBM i system you are connected to. The metadata is located at /etc/vscode/Code4iRepo.json, while the source files are located at /etc/vscode/Code4iRepo.

How to test this PR

You can try the steps shown in this video:

2026-08-21.17-39-11.1.mp4

Checklist

  • have tested my change
  • have created one or more test cases
  • updated relevant documentation
  • Remove any/all console.logs I added
  • have added myself to the contributors' list in CONTRIBUTING.md

@buzzia2001
buzzia2001 requested a review from a team August 21, 2026 17:39
@buzzia2001 buzzia2001 self-assigned this Aug 21, 2026
@buzzia2001 buzzia2001 added the enhancement New feature or request label Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

👋 A new build is available for this PR based on 84ac733.

@SanjulaGanepola

Copy link
Copy Markdown
Member

After further thought about this, I am wondering if this should be a feature that is implemented slightly differently and is actually in the Db2 extension and integrated with the SQL Examples view.

As requested in codefori/vscode-db2i#526, users wanted to have reusable SQL examples stored in the IFS and easily accessible in the SQL Examples view. Couldn't this be implemented as easy as having a connection specific configuration to store the IFS directories (which the user also gets to define). Essentially, when the user goes to add a Custom Examples Directory, we can prompt them if it is in the IFS or Local. Wouldn't this be a much simpler implementation of this feature that also makes the scripts viewable in the SQL Examples view?

In my opinion, I also prefer to have these reusable SQL example queries browsable in the view rather than in the content assist as I don't always start with an editor. It is nice to just find the example I need and it brings up an untitled editor with the query just ready to run.

@buzzia2001 @sebjulliand What are your thoughts?

@buzzia2001

Copy link
Copy Markdown
Member Author

After further thought about this, I am wondering if this should be a feature that is implemented slightly differently and is actually in the Db2 extension and integrated with the SQL Examples view.

As requested in codefori/vscode-db2i#526, users wanted to have reusable SQL examples stored in the IFS and easily accessible in the SQL Examples view. Couldn't this be implemented as easy as having a connection specific configuration to store the IFS directories (which the user also gets to define). Essentially, when the user goes to add a Custom Examples Directory, we can prompt them if it is in the IFS or Local. Wouldn't this be a much simpler implementation of this feature that also makes the scripts viewable in the SQL Examples view?

In my opinion, I also prefer to have these reusable SQL example queries browsable in the view rather than in the content assist as I don't always start with an editor. It is nice to just find the example I need and it brings up an untitled editor with the query just ready to run.

@buzzia2001 @sebjulliand What are your thoughts?

Hi
This PR isn't specific to SQL; maybe I misunderstood the request for the SQL code repository…
I mean, I see it more as something for RPG or CL… In any case, users can actually view the list of snippets, and with a good description, they can paste them directly from the connection menu…

@buzzia2001

Copy link
Copy Markdown
Member Author

If we want to add custom examples in db2 extension, we can open another pr

@SanjulaGanepola

Copy link
Copy Markdown
Member

I mean, I see it more as something for RPG or CL… In any case, users can actually view the list of snippets, and with a good description, they can paste them directly from the connection menu

Good point. I guess there can be different ways this same type of feature is used.

If we do plan to keep this shared templates feature, what do you think about better aligning the name of this feature with what VS Code calls it: snippets. Beyond just the name, I would say we should align the behavior as well for consistency. My thought is they should be stored in a single /etc/vscode/snippets.json file that follows the same structure that VS Code uses locally.

https://code.visualstudio.com/docs/editing/userdefinedsnippets#_create-your-own-snippets

You can check this out by using the Configure Snippets command and using New Global Snippets File... where you see something like this:

image

I am thinking we store everything in this single file instead of having another directory to store the snippet. This keeps things consistent and makes it easy to copy snippets between the IFS and local. It would be great if we could also have this placeholders feature in VS Code also for these IFS snippets.

Again, what do you think about this? 😁

If we want to add custom examples in db2 extension, we can open another pr

Yes I think we can still add support for this in the Db2 extension separately as I described. I believe I started this change a while ago, I will check later if I have the code for it still and will PR it.

@buzzia2001

Copy link
Copy Markdown
Member Author

Hi @SanjulaGanepola,

I made the requested change. The configuration is now contained in a single file and no longer in directories. I also replaced the various entries in the frontend from “templates” to “snippets.”

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants