Highlighting Bash in Lua with Neovim and Treesitter

2025-01-28

The author built a tool to synchronize packages across multiple machines, using a Lua configuration file. To improve readability and editing of Bash scripts embedded within the Lua configuration, they leveraged Neovim and the Treesitter plugin. Treesitter, through its injection feature, identifies the `script` field in Lua tables and highlights its content as Bash based on a custom query. This significantly enhances code readability and maintainability. The post details the configuration of Neovim and Treesitter, along with the custom query to achieve the Bash highlighting.

Development