Registry / devops / prettier-plugin-glsl

prettier-plugin-glsl

JSON →
library0.2.5jsnpmunverified

A Prettier plugin for formatting GLSL (OpenGL Shading Language) files. Version 0.2.5 is the latest stable release, built on Chevrotain parser with no external parsing dependencies. It supports Prettier 3.x and includes TypeScript type definitions. Key differentiators: automatic detection of common GLSL extensions, formatting of #define macros as top-level declarations, markdown formatting for /** comments, and high compatibility with Shadertoy shaders (95%+). Active development with potential breaking changes in any version.

npm install prettier-plugin-glsl
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-GL
P
prettier-plugin-glsl
devopsjavascriptv0.2.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import plugin from 'prettier-plugin-glsl'
const plugin = require('prettier-plugin-glsl')
The plugin is a default export. Prettier auto-discovers plugins, so explicit import is usually unnecessary.
glsl-parser
import { parsers } from 'prettier-plugin-glsl'; const glslParser = parsers['glsl-parser'];
import { glsl-parser } from 'prettier-plugin-glsl'
The parser name is a string key, not a named export. Access via parsers object.
printers
import { printers } from 'prettier-plugin-glsl'
import printers from 'prettier-plugin-glsl/printers'
Printers are exported as a named export from the package root.

Installation, configuration, and basic formatting of a GLSL vertex shader file.

// Install prettier and plugin // npm install --save-dev prettier prettier-plugin-glsl // .prettierrc { "plugins": ["prettier-plugin-glsl"], "overrides": [ { "files": ["*.frag", "*.vert", "*.glsl"], "options": { "parser": "glsl-parser" } } ] } // Format all GLSL files in project // npx prettier --write "**/*.{glsl,frag,vert}" // Example input.vs #version 330 core layout(location = 0) in vec3 aPos; void main() { gl_Position = vec4(aPos, 1.0); } // After formatting: npx prettier --write input.vs // Output: #version 330 core layout(location = 0) in vec3 aPos; void main() { gl_Position = vec4(aPos, 1.0); }
prettier --version
Debug
Known issues
breakingThis plugin requires Prettier version ^3.0.0. It will not work with Prettier 2.x.
fix
Upgrade Prettier to version 3 or later: npm install prettier@latest
affects: <3.0.0 (of prettier)
deprecatedThe plugin is in active development; breaking formatting changes may occur in any minor or patch version.
fix
Pin to a specific version if stability is required: "prettier-plugin-glsl": "0.2.5"
affects: >=0.0.0
gotchaFiles with .frag extension are recognized as JavaScript by default. Override the parser in Prettier config to format them as GLSL.
fix
Add overrides in Prettier config: { "overrides": [{ "files": ["*.frag"], "options": { "parser": "glsl-parser" } }] }
affects: >=0.0.0
gotchaComplex #if/#else/#endif mixed with if/else can produce invalid output. The plugin treats preprocessor directives as statements, not as block modifiers.
fix
Restructure code to avoid mixing preprocessor conditionals with C-style if/else blocks, or manually verify formatting.
affects: >=0.0.0
gotchaPlugin auto-recognizes only certain file extensions (e.g., .glsl, .vert, .frag). Custom extensions may require explicit parser option.
fix
Specify parser in Prettier config: { "overrides": [{ "files": ["*.custom"], "options": { "parser": "glsl-parser" } }] }
affects: >=0.0.0
Errors
Common errors & fixes
Error: Couldn't resolve plugin "prettier-plugin-glsl"
Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev prettier-plugin-glsl' and ensure it appears in package.json devDependencies.
Cannot find module 'prettier-plugin-glsl'
Plugin is not installed or path resolution issue with Prettier 3.x plugin resolution.
fix
Verify installation: npm list prettier-plugin-glsl. If using Yarn PnP, add plugin to pluggable dependencies.
[error] Invalid configuration file: "parser" option is not a valid parser name
Typo in parser name, e.g., 'glsl' instead of 'glsl-parser'.
fix
Use correct parser name: "glsl-parser" as exported by the plugin.
TypeError: prettier.getSupportInfo is not a function
Using an older version of Prettier (<3.0.0) that doesn't support plugin API used by this plugin.
fix
Upgrade Prettier to version 3 or later: npm install prettier@latest
Upgrade
Version history
0.2.5latest on npm
Audit
Dependencies
prettierrequiredpeer dependency - required for the plugin to function
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-glsl — npm install prettier-plugin-glsl · libregistry