返回资讯中心
外部精选
软件工程
#开发者实时流

Show HN: WGSL linter with Tint parity and a full suite of LSP niceties

Made a WGSL linter for a VS Code extension with validation matching Chrome's Tint compiler. Plus navigation, rename, layout hints and other LSP niceties; in template strings too. Feedback is very welcome!

Hacker News 最新Elringus2026/10/17 · 2026/10/175 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

WGSL language support for .wgsl files and WGSL templates embedded in JS/TS: a VS Code extension, the wgsl-lint command-line tool and a dependency-free analyzer library. Shaders are validated the way Chrome does, with all the errors reported at once.

Diagnostics including const-evaluation, uniformity analysis, memory layout and entry-point IO.

Hover with types, values, memory layout and spec descriptions of the builtins.

Completion of names in scope, members, swizzles, builtins, attributes and enumerants, with signature help.

Inlay hints with the inferred types.

Go to definition, references, rename, symbols, highlights and folding.

Formatting that keeps the source's line breaks.

Semantic highlighting.

All but semantic highlighting also work in JS/TS template literals tagged wgsl:

const shader = wgsl ${common} @compute @workgroup_size(${size}) fn main() {};

Diagnostics depending on the ${} substitutions are suppressed. Templates are formatted with the "Format WGSL template" code action.

wgsl-lint [--tag <name>]... [--prelude <file>] <file or directory>...

Reports the diagnostics of the .wgsl files and, with --tag, of the tagged templates in JS/TS files; exits with 1 on errors.

import { Document, hover, lint } from "wgsl-linter";

const diagnostics = lint(source); const info = hover(new Document(source), offset);

Positions are UTF-16 offsets.

import { register } from "wgsl-linter/vscode";

export function activate(context: vscode.ExtensionContext) { register(context, { tags: ["wgsl", "shader"], prelude: engineDeclarations }); }

tags: tags of the template literals holding WGSL; wgsl by default.

prelude: WGSL declarations available to all the shaders, such as engine-provided structs.

extensions, features: the enable-extensions and language features the target supports; Chrome's by default.

For highlighting, contribute the wgsl language with the configuration and grammars in syntaxes, as this repository's package.json does.

To format all the templates in a document at once, for example from a command, call formatTemplates(editor, edit, tags) within a text editor command.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →