AutoHotkey is an esoteric scripting language that only runs on Windows, so it does not have wide support among popular code editors. With that said, there is a VS Code plugin that includes a language server, which improves the DX of writing AHK scripts. To use it in Neovim however requires some manual configuration.
Clone & build the plugin
Ensure Node.js is installed and set up properly. Now git clone https://github.com/thqby/vscode-autohotkey2-lsp
into a suitable directory, then run the following commands in order:
npm ci
npm run vscode:prepublish
This will use esbuild
to build the language server so that the following Neovim config has something to point to.
Configure nvim-lspconfig
Assuming a LazyVim or lazy.nvim setup, modify the nvim-lspconfig
configuration as follows:
Now restart Neovim and open any .ahk
file. Check that the basic LSP functions are available:
- press K to view tooltips
- bad syntax should result in error highlighting
- run
:LspInfo
to see that the server is started and attached to the buffer
What about syntax highlighting?
For some reason, even though LSP does not normally affect syntax highlighting, Iโve found that syntax highlighting is slightly better with this configuration than without. Tangentially, Iโm not even sure why default Neovim (even without LazyVim) has any syntax highlighting for
.ahk
files in the first place!