English | 中文
AutoHotkey v2 Language support for VS Code, features realization based on v2 syntax analysis.
Supports running on the Web, such as Chrome/Edge
. https://vscode.dev or https://github.dev/github/dev
Rename variables and function names in the scope in batches.
Simple syntax error diagnosis.
Supports intelligent completion of variables, functions, parameters, class names, and method names within the scope (by simple type deduction), and supports the completion of include files and function libraries.
Support for intelligent prompts for function parameters.
/**
* @param {Array} a - a param
* @return {Integer}
*/
fn(a*) {
/** @type {Map} */
d := Map()
/**
* @var {Map} e
* @var {Object} f
*/
e := Map(), f := {}
/** @type {(a,b)=>Integer} */
cb := (a, b) => a + b
/** @type {ComObject<Excel.Sheet.12,Workbook>} */
wb := ComObject('Excel.Sheet.12')
return a[1] + a[2]
}
class abc {
/** @type {Map} */
p := dosomethingandreturnmap()
}
Semantic highlighting is an addition to syntax highlighting, resolves symbols in the context of a project. The editor applies the highlighting from semantic tokens on top of the highlighting from grammars.
usage: Add ;;
(default) or ; TODO
to the comment code Tags.
Compute and resolve colors inside a document to provide color picker in editor.
Supports hover prompts and comments for scoped variables, functions, global classes, and labels.
usage: Move the mouse over the symbol.
See all the source code locations where a certain variable/function is being used.
usage:
Shift+Alt+F
.editor.formatOnType
needs to be enabled);@format array_style: collapse, object_style: expand
to change the object style of different blocksFold the part between ;@region tag
and ;@endregion
, ;{
and ;}
;#region tag
code
;#endregion
The declaration file is a file with the suffix of .d.ahk
as the file name, which is used to describe the implemented functions or classes, etc., does not contain the implementation part of the code, and is referenced by the ahk file with the same name by default, and the syntax refers to ahk2.d.ahk
provided by the extension. The declaration file can extend or rewrite the declaration of ahk built-in functions or classes, and the annotation document can be separated from the source code to provide a multilingual version of intellisense.
; array.d.ahk
; #ClsName represents the ahk built-in class
/** @extends {#Array} */
class Array<T = Any> {
/** jsdoc-default */
Filter(FilterFunc) => Array<T>
}
; array.zh-cn.d.ahk
; #ClsName 表示ahk内置类
/** @extends {#Array} */
class Array<T = Any> {
/** jsdoc-zh */
Filter(FilterFunc) => Array<T>
}
; array.ahk
; %A_Locale% is VSCode's Display Language
;@reference array.%A_Locale%.d.ahk
Array.Prototype.DefineProp('Filter', { call: Array_Filter_impl })
Open the help file and navigate to the keyword at the current cursor.
Run the currently open script.
Run the code snippet at the cursor selection.
Compile the script to generate executable EXE files.
No additional configuration is required to start the installed Debug extensions, and support debugging with parameters.
Generate JSDOC-style comments for a function or method.
mkdir vscode-autohotkey2-lsp
cd vscode-autohotkey2-lsp
curl.exe -L -o install.js https://raw.githubusercontent.com/thqby/vscode-autohotkey2-lsp/main/tools/install.js
node install.js
Package Control: Install Package
, and install Sublime LSP plug-in.Preferences: LSP Settings
, add lsp configuration, language selector, and syntax highlighting. This is a simple example syntax highlighting, save the file in a similar path C:\Users\<USERNAME>\AppData\Roaming\Sublime Text\Packages\User\LSP-ahk2\AutoHotkey2.sublime-syntax
.{
"clients": {
"lsp-ahk2": {
"enabled": true,
"command": [
"node",
"<VSCODE-AUTOHOTKEY2-LSP>/server/dist/server.js",
"--stdio"
], // Update the path of node.exe(maybe it's already in PATH, so you don't need to set it) and the folder of vscode-autohotkey2-lsp
"selector": "source.ahk2", // Same as scope in AutoHotkey2.sublime-syntax
"schemes": ["file", "buffer", "res"],
"initializationOptions": {
"locale": "en-us", // or "zh-cn"
"AutoLibInclude": "Disabled", // or "Local" or "User and Standard" or "All"
"CommentTags": "^;;\\s*(?<tag>.+)",
"CompleteFunctionParens": false,
"Diagnostics": {
"ClassStaticMemberCheck": true,
"ParamsCheck": true
},
"ActionWhenV1IsDetected": "Continue",
"FormatOptions": {
"array_style": "none", // or "collapse" or "expand"
"break_chained_methods": false,
"ignore_comment": false,
"indent_string": "\t",
"max_preserve_newlines": 2,
"brace_style": "One True Brace", // or "Allman" or "One True Brace Variant"
"object_style": "none", // or "collapse" or "expand"
"preserve_newlines": true,
"space_after_double_colon": true,
"space_before_conditional": true,
"space_in_empty_paren": false,
"space_in_other": true,
"space_in_paren": false,
"wrap_line_length": 0
},
"InterpreterPath": "C:/Program Files/AutoHotkey/v2/AutoHotkey.exe",
"WorkingDirs": [],
"SymbolFoldingFromOpenBrace": false
}
}
},
"semantic_highlighting": true
}
cd $VIMRUNTIME\plugin
git clone --branch release https://github.com/neoclide/coc.nvim.git --depth=1
:CocConfig
to enter the coc.nvim
configuration file to add configuration information.{
"languageserver": {
"lsp-ahk2": {
"module": "<VSCODE-AUTOHOTKEY2-LSP>/server/dist/server.js",
"filetypes": ["autohotkey"],
"args": ["--node-ipc"],
"initializationOptions": {
// Same as initializationOptions for Sublime Text4
}
}
}
}
cmd
points to the path of your vscode-autohotkey2-lsp installation and InterpreterPath
points to your AHK exe.local function custom_attach(client, bufnr)
require("lsp_signature").on_attach({
bind = true,
use_lspsaga = false,
floating_window = true,
fix_pos = true,
hint_enable = true,
hi_parameter = "Search",
handler_opts = { "double" },
})
end
local ahk2_configs = {
autostart = true,
cmd = {
"node",
vim.fn.expand("$HOME/vscode-autohotkey2-lsp/server/dist/server.js"),
"--stdio"
},
filetypes = { "ahk", "autohotkey", "ah2" },
init_options = {
locale = "en-us",
InterpreterPath = "C:/Program Files/AutoHotkey/v2/AutoHotkey.exe",
-- Same as initializationOptions for Sublime Text4, convert json literal to lua dictionary literal
},
single_file_support = true,
flags = { debounce_text_changes = 500 },
capabilities = capabilities,
on_attach = custom_attach,
}
local configs = require "lspconfig.configs"
configs["ahk2"] = { default_config = ahk2_configs }
local nvim_lsp = require("lspconfig")
nvim_lsp.ahk2.setup({})
(add-to-list 'eglot-server-programs '(ahk-mode "node" "<VSCODE-AUTOHOTKEY2-LSP>/server/dist/server.js" "--stdio"))
visit https://github.dev or https://vscode.dev in Chrome/Edge
, and install thqby.vscode-autohotkey2-lsp