>_VSCODE-AWK — AWK IN VS CODE
Open a .awk file and the whole language lights up. AWK is a pattern/action text-processing language; awkrs is its Rust implementation (POSIX / gawk / mawk-style union CLI). vscode-awk registers the awk language for *.awk files and AWK shebangs, highlights with a standalone TextMate grammar (source.awk) covering the BEGIN / END special patterns, control keywords, built-in variables and functions, field references, and /.../ regex literals, starts the awkrs --lsp language server via vscode-languageclient, and debugs through awkrs --dap.
Install
The awkrs binary must be on $PATH for the language server and debugging (cargo install awkrs). Build and install the .vsix locally:
git clone https://github.com/MenkeTechnologies/vscode-awk cd vscode-awk npm install npx @vscode/vsce package # vscode-awk-<version>.vsix code --install-extension vscode-awk-*.vsix
Or clone straight into your extensions dir for development: ~/.vscode/extensions/vscode-awk.
What you get
Filetype detection
Every *.awk file becomes the awk language. Files with a #!/usr/bin/awk -f or #!/usr/bin/env awk shebang are detected via firstLine.
Standalone grammar
A TextMate grammar (source.awk) — special patterns, keywords, built-in variables and functions, field refs, regex literals, strings, numbers, operators.
Language server
Launches awkrs --lsp (stdio JSON-RPC) through vscode-languageclient — diagnostics, hover, completion as the server provides.
Run
AWK: Run File (Ctrl+F5 / editor-title ▶) saves and runs the active file as awkrs -f <file> in an integrated terminal.
Debugging
Breakpoints, step over/into/out, call stack, scopes, variables, watch / hover, and run-without-debugging via the native debug adapter (awkrs --dap).
Verified
A vscode-textmate + vscode-oniguruma test tokenizes a sample and asserts the scopes, so the grammar is proven to load and classify correctly.
Scopes
| Token group | Scope |
|---|---|
Special patterns (BEGIN END) | keyword.other.special-pattern.awk |
Control flow (if while for next exit) | keyword.control.awk |
I/O statements (print printf getline) | keyword.other.io.awk |
Function intro (function) | storage.type.function.awk |
Built-in variables (NR NF FS OFS RS) | variable.language.awk |
String functions (split gsub substr sprintf) | support.function.string.awk |
Math functions (sqrt atan2 rand) | support.function.math.awk |
I/O functions (system close fflush) | support.function.io.awk |
Field references ($0 $1 $NF) | variable.language.field.awk |
Match operators (~ !~) | keyword.operator.match.awk |
Strings (double-quoted with escapes), /.../ regex literals, numbers (integer / float / scientific / hex), comments (#), and the operator set (assignment, comparison, logical, arithmetic, ternary, pipe) are scoped too.
Language server settings
| Setting | Default & effect |
|---|---|
awk.path | awkrs — path to the executable |
awk.lsp.enabled | true — start the server; set false for highlighting only |
awk.lsp.args | ["--lsp"] — args to start the server |
The transport is omitted so the client spawns bare awkrs --lsp and never appends --stdio. If the binary is missing, the extension shows one non-fatal warning and highlighting keeps working.
Compatibility
| Target | Status |
|---|---|
| VS Code 1.75+ | Grammar + LSP + DAP |
| VSCodium / OSS builds | Same extension |
| Syntax highlighting | No binary required |
| Language server & debug | Requires awkrs on PATH |