Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfishSoftware committed Oct 28, 2024
2 parents ca8608d + 2d60f67 commit 77775ed
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 69 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"OpenVSX",
"ovsx",
"resthumb",
"themable",
"tropy",
"tscn",
"typeparameters",
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
Features currently in early access are marked with 🔒 as they're restricted to [supporters].
Features previously in early access are marked with ***vX.Y.Z*** 🔓 as they're unlocked for everyone since that version.

## [0.1.1] - 2024-10-28
### Added
- GDAsset: Show engine classes as inlay hints on `ExtResource(…)` and `SubResource(…)` references.
- GDAsset: Show file paths as inlay hints on `ExtResource(…)` references.
- GDShader: Add `#error` directive to preprocessor and to syntax coloring.
- Docs: Add text content provider for doc URI, so it shows the webpage URL when peeking a class/member definition.
### Fixed
- Stronger pattern to match files with more priority than other extensions like godot-tools.
- GDAsset: Bypass max limit of 44 inlay hint characters shown per line on vector|color array parentheses.
This feature will still respect `editor.maxTokenizationLineLength` to avoid potential performance issues.
- GDAsset: Use `$"../TopNode"` instead of `$"/root/TopNode"` in the outline, as scenes are not always under root.

## [0.1.0] - 2024-10-16
### Changed
- GDShader: Disable url detection by default, since in BBCode it incorrectly includes the `[/url]` end tag too.
Expand Down Expand Up @@ -147,7 +159,8 @@ Features previously in early access are marked with ***vX.Y.Z*** 🔓 as they're
- GDAsset: Image and font previews by hovering references and paths.
- GDAsset: Hover resource references to show GDScript preload code.

[Unreleased]: https://github.com/AlfishSoftware/godot-files-vscode/compare/v0.1.0...develop
[Unreleased]: https://github.com/AlfishSoftware/godot-files-vscode/compare/v0.1.1...develop
[0.1.1]: https://github.com/AlfishSoftware/godot-files-vscode/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/AlfishSoftware/godot-files-vscode/compare/v0.0.10...v0.1.0
[0.0.10]: https://github.com/AlfishSoftware/godot-files-vscode/compare/v0.0.9...v0.0.10
[0.0.9]: https://github.com/AlfishSoftware/godot-files-vscode/compare/v0.0.8...v0.0.9
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# Godot Files

Basic GDShader support, better syntax-coloring and additional features for some Godot files.
This is *not* meant to replace the official [godot-tools] extension, but to improve on its supported files. This plugin is designed so it can work alongside it, but it's completely independent. If you're using GDScript, you'll likely want to install godot-tools too; if not, just this one is enough.
**Basic GDShader support, better syntax-coloring and additional features for some Godot files.**
Godot Editor does NOT need to be running for any features here.

[godot-tools]: https://github.com/godotengine/godot-vscode-plugin

> 🥺 Please help prevent this extension from being abandoned by [donating to the crowdfunding][donate]!
> 🥺 Please help prevent this extension from being abandoned in 2025-01-31 by [donating to the crowdfunding goal][donate]!
> 🔑 With a donation, you can **unlock early access and other rewards**! More info below.
![Showcasing various features, like GDShader errors, hovering, navigating and documentation pages](docs/showcase-all.png "* Features showcased here include those restricted to early access.")

This is not meant to fully replace the official [godot-tools] extension, but to improve on its supported files. This plugin is designed so it can work alongside it, but it's completely independent. If you're using GDScript, you'll likely want to install godot-tools too; if not, just this one is enough.
🔧 You can use the setting `files.associations` to set your preferred extension to handle `*.tscn`, `*.tres`, etc.

**Compatibility**:

- Godot: 3.x LTS and 4.0 to 4.x; official and flathub builds
- godot-tools: v2.3.0
- **Godot**: 3.x LTS and 4.0 to 4.x; official and flathub builds
- **godot-tools**: v2.3.0; *("view documentation" feature can use godot-tools)*

🌐 This extension also works on browser IDEs ([vscode.dev](https://vscode.dev) and [github.dev](https://github.dev)), with limited functionality.
🌐 This extension also works on browser IDEs ([vscode.dev](https://vscode.dev) and [github.dev](https://github.dev)), with minor limitations.

## Features
Features are supported on these languages:
Expand Down Expand Up @@ -43,7 +46,7 @@ Syntax-coloring of valid embedded code is supported.
Note that you should always put the inner code in its own lines verbatim, without the leading `*`, or any extra leading indentation.
![Showcasing how you should embed code in GDShader docs BBCode](docs/showcase-gdshader-docs-embed-code.webp)

The inner code doesn't break the container code syntax, as long as it's valid code (without partial contructs like unterminated strings/comments, mismatched brackets, etc). Some cases are being handled, but it's not viable to try to safeguard against every possible case of invalid code; this is a limitation of the IDE.
The inner code doesn't break the container code syntax, as long as it's valid code (without partial constructs like unterminated strings/comments, mismatched brackets, etc). Some cases are being handled, but it's not viable to try to safeguard against every possible case of invalid code; this is a limitation of the IDE.

### Document Symbols
Symbol definitions are provided for:
Expand All @@ -58,7 +61,7 @@ These features are supported in textual Scene and Resource files.

- **Navigate to the definition** of `SubResource` and `ExtResource` references, and to resource paths.
![Showcasing navigate to definition](docs/showcase-goto-definition.png)
Going to the definition of a built-in engine type (on `type="SomeType"` or `some_field = SomeType(...)`) will open its Godot API Documentation. This will be handled by the *godot-tools* extension, unless you're online and enabled [early access][donate] (see below).
Going to the definition of a built-in engine type (on `type="SomeType"`, `some_field = SomeType(...)` or in inlay hints) will open its Godot API Documentation. This will be handled by the *godot-tools* extension, unless you're online and enabled [early access][donate] (see below).

- **See GDScript code for loading** a resource reference or path by hovering (`preload(…)`, `load(…)` or `FileAccess.open(…)`).
![Showcasing code for loading when previewing user path](docs/showcase-user-path-load.webp)
Expand Down Expand Up @@ -86,6 +89,12 @@ These features are supported in textual Scene and Resource files.
As well as any other resource files that have a thumbnail in Godot Editor:
![Showcasing thumbnail preview of a material resource](docs/showcase-material-thumb.webp)

- 🌟 **New**:
**See inferred class and path of resource references** in inlay hints. You can <kbd>Ctrl</kbd>+Click them to navigate. You can also hover paths.
✳️ Paths are only shown at the end of a line (so not within arrays, you can still hover the code itself to see the path in this case).
🔧 You can control this feature in the settings under `godotFiles.clarifyReferences` (`.class` and `.filePath`). By default, the class is only hinted where it cannot be inferred from the context, so in Godot 4 it will typically not be shown for `SubResource`, as it's already in the id (unless you set it to `always`).
![Showcasing classes and paths as inlay hints on resource references](docs/showcase-inlay-hints-resource-refs.webp)

- **Edit a color by hovering its inline decorator** on `Color(…)` values or within an array. You can also see its hex value.
🔧 You can disable this feature with the settings under `godotFiles.inlineColors` (`.single` and `.array`).
![Showcasing inline color decorators](docs/showcase-color-decorators.webp)
Expand All @@ -94,9 +103,9 @@ These features are supported in textual Scene and Resource files.
#### Latest feature no longer restricted
🌟 This is now out of early access:

- **See implied parentheses in packed arrays** of vectors or colors with the inlay hints that surround items.
✳️ This is *not* supported syntax in asset files! These parentheses are only shown for clarity.
- **See implied parentheses in packed arrays** of vectors or colors that surround items, similar to inlay hints.
🔧 You can toggle this feature with the settings under `godotFiles.clarifyArrays` (`.vector` and `.color`).
✳️ This feature respects `editor.maxTokenizationLineLength` to avoid potential performance issues on very long lines.
![Showcasing implied parentheses in array items as inlay hints](docs/showcase-parentheses-hint-in-arrays.webp)

If you want **more features**, check the sections **Early Access**, **Crowdfunding** and **Potential Future Development** below.
Expand Down
Binary file added docs/showcase-inlay-hints-resource-refs.webp
Binary file not shown.
26 changes: 23 additions & 3 deletions lang.gdshader/gdshader.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
]
},
"text": {
"patterns": [
{ "include": "#comment" },
{ "include": "#string" }
]
},
"comment": {
"patterns": [
{ "include": "#commentLine" },
{ "include": "#commentBlockDocumentation" },
{ "include": "#commentBlock" },
{ "include": "#string" }
{ "include": "#commentBlock" }
]
},
"code": {
Expand Down Expand Up @@ -595,7 +600,8 @@
{ "include": "#directivePragma" },
{ "include": "#directiveDefineMacro" },
{ "include": "#directiveDefine" },
{ "include": "#directiveConditional" }
{ "include": "#directiveConditional" },
{ "include": "#directiveError" }
]
},
"directiveInclude": {
Expand Down Expand Up @@ -662,6 +668,20 @@
"1": { "name": "punctuation.definition.directive.gdshader" }
}
},
"directiveError": {
"name": "meta.preprocessor.error.gdshader",
"begin": "((\\#)error)\\b\\s*",
"beginCaptures": {
"1": { "name": "keyword.control.directive.error.gdshader" },
"2": { "name": "punctuation.definition.directive.gdshader" }
},
"end": "(?<!\\\\)$",
"patterns": [
{ "include": "#text" },
{ "include": "#lineContinuation" },
{ "match": "[^\\\\/\"\\r\\n]+|/|\"", "name": "string.unquoted.error-msg.gdshader" }
]
},
"parenthesisedPreprocessor": {
"name": "meta.parenthesis.gdshader",
"begin": "\\(",
Expand Down
2 changes: 1 addition & 1 deletion lang.godot-docs/godot-docs-webview.inject.htm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
function otherVersionLink(version) {
const href = otherVersionUri(version);
const a = document.createElement('a');
a.href = href;
a.href = href.replaceAll('classes/', 'classes%2F'); // to avoid the docs icon ::after the link
a.innerText = `[${version}]`;
return a;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 57 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"publisher": "alfish",
"name": "godot-files",
"version": "0.1.0",
"version": "0.1.1",
"license": "Unlicense",
"displayName": "Godot Files",
"description": "Basic GDShader support, better syntax-coloring and additional features for some Godot files.",
Expand Down Expand Up @@ -98,6 +98,10 @@
".tres",
".gdns"
],
"filenamePatterns": [
"*.tres",
"*.gdns"
],
"icon": {
"dark": "./lang.gdasset/godot-resource.dark.svg",
"light": "./lang.gdasset/godot-resource.light.svg"
Expand All @@ -118,6 +122,9 @@
".tscn",
".escn"
],
"filenamePatterns": [
"*.[te]scn"
],
"icon": {
"dark": "./lang.gdasset/godot-scene.dark.svg",
"light": "./lang.gdasset/godot-scene.light.svg"
Expand Down Expand Up @@ -146,7 +153,11 @@
],
"filenamePatterns": [
"**/.godot/**/*.cfg",
"**/.godot/imported/*.md5"
"**/.godot/imported/*.md5",
"*.import",
"*.gdnlib",
"*.tet",
"*.remap"
],
"icon": {
"dark": "./lang.gdasset/godot-asset.dark.svg",
Expand Down Expand Up @@ -492,33 +503,65 @@
"default": true,
"description": "Disable if you don't want tooltips to show an image preview of the resource or a link to it."
},
"godotFiles.inlineColors.single": {
"order": 100,
"godotFiles.clarifyReferences.class": {
"order": 200,
"scope": "language-overridable",
"type": "boolean",
"default": true,
"markdownDescription": "Show inline color decorators on `Color(…)` values."
"type": "string",
"default": "auto",
"markdownDescription": "Show implied engine classes as inlay hints on `ExtResource(…)` and `SubResource(…)` references.",
"enum": [
"never",
"auto",
"always"
],
"enumDescriptions": [
"Disable showing these inlay hints.",
"Show inlay hints only when the class cannot be inferred from the context.",
"Always show these inlay hints."
]
},
"godotFiles.inlineColors.array": {
"order": 101,
"godotFiles.clarifyReferences.filePath": {
"order": 201,
"scope": "language-overridable",
"type": "boolean",
"default": true,
"description": "Show inline color decorators on color values within arrays."
"type": "string",
"default": "exact",
"markdownDescription": "Show implied file paths as inlay hints after `ExtResource(…)` references.",
"enum": [
"none",
"exact"
],
"enumDescriptions": [
"Disable showing these inlay hints.",
"Show the path reference exactly as declared."
]
},
"godotFiles.clarifyArrays.vector": {
"order": 200,
"order": 210,
"scope": "language-overridable",
"type": "boolean",
"default": true,
"description": "Show implied parentheses around each vector in a packed array."
},
"godotFiles.clarifyArrays.color": {
"order": 201,
"order": 211,
"scope": "language-overridable",
"type": "boolean",
"default": false,
"description": "Show implied parentheses around each color in a packed array."
},
"godotFiles.inlineColors.single": {
"order": 220,
"scope": "language-overridable",
"type": "boolean",
"default": true,
"markdownDescription": "Show inline color decorators on `Color(…)` values."
},
"godotFiles.inlineColors.array": {
"order": 221,
"scope": "language-overridable",
"type": "boolean",
"default": true,
"description": "Show inline color decorators on color values within packed arrays."
}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/ExtensionEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ export async function activate(context: ExtensionContext) {
// imports that may depend on this extension's state
const { default: GDAssetProvider } = await import('./GDAsset/GDAssetProvider');
const { default: GDShaderProvider } = await import('./GDShader/GDShaderProvider');
const { default: GodotContentTextProvider } = await import('./GodotContentTextProvider');
const {
GodotDocumentationProvider, openApiDocs, activeDocsFindNext, activeDocsFindPrevious,
activeDocsGoBack, activeDocsGoForward, activeDocsReload, activeDocsOpenInBrowser,
} = await import('./GodotDocs');
// register multi-platform providers
ctx.subscriptions.push(
workspace.registerTextDocumentContentProvider(ctx.extension.id, new GodotContentTextProvider()),
window.registerCustomEditorProvider(GodotDocumentationProvider.viewType, new GodotDocumentationProvider(), {
webviewOptions: { retainContextWhenHidden: true, enableFindWidget: true }
}),
Expand Down
4 changes: 3 additions & 1 deletion src/GDAsset/GDAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import GDAssetProvider from './GDAssetProvider';

export class GDResource {
path!: string;
pathRange?: Range;
type!: string;
typeRange?: Range;
symbol!: DocumentSymbol;
}

Expand All @@ -31,7 +33,7 @@ export default class GDAsset {
rootNode: string | undefined = undefined;
nodePath(n: string) {
if (!this.rootNode || !n) return n;
if (n == '.') return GDAsset.nodeCode('/root/' + this.rootNode);
if (n == '.') return GDAsset.nodeCode('../' + this.rootNode);
if (n.startsWith('./')) return GDAsset.nodeCode(n.substring(2));
return GDAsset.nodeCode(n);
}
Expand Down
Loading

0 comments on commit 77775ed

Please sign in to comment.