>_EMACS-AWK — AWK IN EMACS
Open a .awk file and the pattern/action engine lights up. emacs-awk targets awkrs, the Rust AWK implementation. awkrs-mode derives from prog-mode, font-locks AWK keywords, the 16 built-in variables, the 22 built-in functions, field references ($0 $1 $NF) and /regex/ literals, indents brace blocks, runs the buffer through awkrs (C-c C-c), serves eldoc + completion for builtins, and wires awkrs --lsp into both eglot and lsp-mode. Named awkrs-mode so it does not clash with Emacs' built-in awk-mode.
Install
The awkrs binary must be on $PATH to run buffers and for the language server (build awkrs with cargo install --path .).
;; manual (add-to-list 'load-path "/path/to/emacs-awk") (require 'awkrs-mode) ;; use-package + built-in VC (use-package awkrs-mode :mode "\\.awk\\'" :vc (:url "https://github.com/MenkeTechnologies/emacs-awk"))
Press C-c C-c to run a buffer. With eglot: M-x eglot in a .awk buffer, or (add-hook 'awkrs-mode-hook #'eglot-ensure).
What you get
Filetype detection
Every *.awk file uses awkrs-mode (auto-mode-alist); awk / awkrs shebangs are detected via interpreter-mode-alist.
Field-aware font-lock
Keywords, the 16 built-in variables, the 22 built-in functions, field references $0/$1/$NF, and /regex/ literals — with their own faces for built-in vars and fields.
Regex in operand position
A syntax-propertize rule recognizes /regex/ only where AWK allows it (after ~, (, ,, =, a keyword, line start), so division a / b is not mistaken for a regex.
Run via awkrs
awkrs-run-buffer (C-c C-c) runs the buffer's program through awkrs -f FILE in a *compilation* buffer with next-error navigation.
eldoc + completion
One-line builtin signatures in the echo area and completion-at-point over the builtin function names, from awkrs-stdlib.el.
Language server
Registers awkrs --lsp for eglot (built in since Emacs 29) and lsp-mode, both loaded lazily. Launched with --lsp only — no appended --stdio.
Verified
scripts/face-test.el byte-compiles the package and asserts the face at each probe token — proven to load and classify correctly.
Faces
| Token group | Face |
|---|---|
Keywords (BEGIN END function if for print) | font-lock-keyword-face |
Built-in variables (NR NF FS OFS RS SUBSEP) | awkrs-builtin-var-face |
Built-in functions (length substr gsub sprintf split) | font-lock-builtin-face |
Field references ($0 $1 $NF) | awkrs-field-ref-face |
| User function names | font-lock-function-name-face |
Strings / comments / /regex/ | via syntax table + syntax-propertize |
Run, language server & config
| Setting / command | Effect |
|---|---|
awkrs-executable | "awkrs" — path to the executable used to run buffers and start the server |
awkrs-indent-offset | 4 — spaces per indent level |
C-c C-c (awkrs-run-buffer) | run the buffer's program through awkrs -f FILE via compile |
M-x eglot | start the server via eglot (Emacs 29+) |
M-x lsp | start the server via lsp-mode |
Compatibility
| Target | Status |
|---|---|
| Emacs 27.1+ | Mode + font-lock + indent + run + eldoc + completion |
| eglot | Built in since Emacs 29; works on 27/28 if installed |
| lsp-mode | Registered client |
| Syntax highlighting | No binary required |