intellij-awk icon indicating copy to clipboard operation
intellij-awk copied to clipboard

The missing IntelliJ IDEA language support plugin for AWK

intellij-awk

Unit Tests

The missing IntelliJ IDEA language support plugin for AWK

Motivation

  • At the moment there ~~is~~was no AWK plugin for IDEA, which ~~is~~was a pity.
  • Help me develop some of my own projects in AWK.
  • Interested to sharpen my Java skills and learn some IDEA internals.

Goals v0.0.1 [done]

  • [x] Support basic AWK code highlighting
  • Support basic AWK code navigations
    • [x] show structure
    • [x] go to declaration
    • [x] find usages
  • Support completion
    • [x] function names
    • [x] variable names
    • [x] keywords
  • [x] Support only POSIX subset (aka BWK), w/o Gawk additions (this can be added later)
  • Refactoring support
    • [x] rename variable
    • [x] rename function
  • [x] Basic auto-format

Goals v0.2.0 [done]

  • [x] Add GAWK parsing mode

Goals v0.3.0 [done]

  • [x] Enforce variable naming convention (the idea taken from How I Write AWK Code)
    • [x] name for local
  • [x] Showing parameter hints for functions (Ctrl-P)
  • [x] Showing documentation for built-in functions
  • [x] Showing documentation for built-in variables (NR/NF/etc.)

Future ideas

  • [ ] Enforce variable naming convention (the idea taken from How I Write AWK Code)
    • [ ] Name for global
  • [ ] Add settings switch to select Awk dialect (Posix vs Gawk)
  • [ ] Auto-format code via gawk --pretty-print

Parser quirks

Please note, due to very ad-hoc nature of AWK syntax (namely some inherent ambiguities in its grammar) the implemented IntelliJ IDEA AWK parser has some minor limitations.

More details in parser_quirks.md

Implementation details

The chosen approach to variables resolution described in variables_resolution.md

Useful links