I'm developing an extension in VS Code to add language support for OpenSCAD (Script-based 3D modeling program). Currently, I have been working on a way to open / preview a file in OpenSCAD from VS Code, which I have been able to do successfully using my own preview manager.
My issue is that I want to add configurable naming formats when exporting an OpenSCAD file that use environment variables similar to those used in the tasks.json file. More info can be found here: https://code.visualstudio.com/docs/editor/variables-reference. As an example, taking the file test.scad and the export configuration ${fileBasenameNoExtension}.stl would export to the file test.stl.
Additionally, I want to add a custom variable, ${#} that would evaluate after all other variables as a unique version number to avoid duplicate exported files. Using the example file: test.scad and the export configuration, ${fileBasenameNoExtension}_${#}.stl, the extension would export to the file test_1.stl for the first time. Then, seeing that test_1.stl exists, it would export to test_2.stl, and so on. I implement similar functionality in all of my exporting utilities, so it is important I can implement it here.
Now that the intro is done, on to the actual question: To anyone who knows more about the VS Code API than I do, in order to best get the functionality described above, should I implement environment variable evaluation into my custom preview manager or reimplement the preview manager I have using tasks? Because I have already implemented my own preview manager that I am happy with, I would prefer to do the former. However, I have been unable to find any functions in the VS Code API that will evaluate the environment variables in a string. Is there a typescript function to evaluate environment variables in the API that I have missed?
If re-implementing this functionality using tasks is a better way to achieve my goal, would I have to sacrifice the control I have in my preview manager, such as being able to selectively kill open previews and dispalying active exports?
Or, is there a compromise that could use all of the power from tasks without losing any functionality I've already developed?
Link to branch of my extension's repository: https://github.com/Antyos/vscode-openscad/tree/PreviewModel
Related
I have stored a JavaScript file in a TYPO3 extension (under Resources/Public/Css/JavaScript/Backend/Iconpack.js), which is used as a JavaScript module in the backend.
However, when developing the extension, I packed the file full of console.log() to allow debugging, and also to better document certain things.
Of course I want that in the final extension as well as when downloading via composer, only a minimized version of this JavaScript is loaded, but not the original source file.
On the other hand, of course, I want the original source file to be stored somewhere in the git repository, so that you can actually continue working on it.
In the frontend, I would normally just store Iconpack.js, for example, in the same folder, create a minimized version from it, i.e. Iconpack.min.js, and use this minimized file.
But unfortunately that doesn't work in this case, because the file path for JavaScript modules is also the namespace.
What would be the best way to solve this?
To summarize:
The minimized version should be able to be used directly in the backend via Iconpack.js.
The namespace should be TYPO3/CMS/Iconpack/Backend/Iconpack and not TYPO3/CMS/Iconpack/Backend/Iconpack.min or similar.
The source file should not end up in TER or be loaded via composer.
But the source file should be accessible via Github.
I was able to find out that I can at least prevent a certain file from being loaded via composer with .gitattributes.
Unfortunately, that doesn't solve the question of where I should best place it so that other developers have it easier and it's clear that it's the source file.
Currently I only have the minimized version stored in git for this reason, but that makes little sense for an open source repository: https://github.com/quellenform/t3x-iconpack/tree/main/Resources/Public/JavaScript/Backend
Ideas?
I am developing a VS Code extension that offers auto completion and hover information about my custom web components library.
I am using Custom Data Extension API to do that, but I have found that the only allowed contribution point are HTML and CSS, and that's a problem for me as I want to make my extension work in JSX files that uses my components in their React version (for instance: <MyComponent> instead of <my-component>)
I have not been able to find if this is possible, or so far, it seems not to be.
Any idea if this is supported by the current VSCode API?
Originally answered by Simon Chan on Github
Usually providing completions for JSX is by writing a TypeScript definition file. The documentation is at https://www.typescriptlang.org/docs/handbook/jsx.html#intrinsic-elements
This file is usually distributed in an NPM package. I can't remember the rule for loading ambient definitions #mjbvz. Maybe it must be a #types/X package, otherwise the user has to edit their tsconfig.json or adding a /// <reference in their source files.
If you want to go the hard way by creating a plugin for TypeScript server that provides custom completions, I can only say it's not impossible. The related contribution point is typescriptServerPlugins: https://code.visualstudio.com/api/references/contribution-points#contributes.typescriptServerPlugins.
Problem:
So, I've been using vscode primarily for go and the default experience was so nice I almost never had to dive into vscode settings to improve it. It spoiled me though.
I'm now learning powershell and I miss things like being able to hover over a custom type to see its definition, and autocompletion for things being automatically available without having to run part of a script for them to become available.
I like strongly typed programming and am creating a lot of custom classes in powershell to organize the code but whenever I go to instantiate a custom class I find myself losing time to searching for the class definition if I happened to forget what I named a property.
Question:
I'm hoping to improve the vscode powershell experience by putting completed custom classes and functions in a powershell module that is autoloaded by the workspace for the project when vscode opens. I'm thinking this will be the best way to get close to the go coding experience I've had previously where I can start calling a function or instantiate a custom class and have autocompletion available so I don't have to go searching for definitions If I happen to forget my parameter or property names.
Would that be the right way to go about addressing the issue and can be done? Or would there be a better way to go about this with powershell and vscode? I've seen suggestions to use powershell preview and vscode insider for better intellisense features in powershell but unfortunately I didn't see any difference.
After googling it a little more it looks like my complaint is a known limitation of the powershell extension for VSCode.
The powershell extension FAQ has:
PowerShell classes don't have proper reference/symbol support - #3
One of the blockers for this was that we still supported Windows PowerShell v3 and v4. However, we don't support v3 and v4 anymore so we can do this work but it's not on the roadmap at this time.
And the issue is being tracked by: Implement document and workspace symbol providers for classes #3
I'm looking to improve my own productivity by trying to figure out how to provide cmd+click functionality for variables declared at runtime. I work with a library that allows you to register objects to it at runtime to be accessed later — it would be great if I could cmd+click to definitions of these! How do you think I could achieve this? I'm open to any ideas. Thanks!
Edit:
Thoughts I have so far inspired by feedback from various Slack communities:
There is no such thing as 'runtime' when providing functionality in IDEs
We need to be able to teach the IDE about what definitions to expect. Whether this means writing an extension to use the VS Code API specifically for my use-case, or otherwise working within a system that generates files that the IDE already knows to look for, which allows it to connect the dots and provide the precious peek / goto definition functionality
Edit:
I'm starting work on a VS Code extension that reads a dotfile for configuration — I'll share what I find out as I go!
I'm working with a game engine named ORX which is data driven. That means, that you define object behaviours, configurations, etc. in .ini files, making it possible to change things without recompiling your code. There are two template files for how to write these .ini files for your game: CreationTemplate.ini and SettingsTemplate.ini.
What I would like to achieve is an autocompletion feature for Visual Studio (or if it's not possible, then for ReSharper), where in a new .ini file the IDE uses this two templates to suggest solutions.
I haven't found any options to extend the existing autocomplete functionality with custom rules, so I'm thinking about writing an extension for it. Only, I have never done this before and I have no idea where to start or how hard/long would it be/take.
Could you give me some tips and starting points for this project? Thank you for your help in advance.