1 Star 9 Fork 0

天黑请闭眼 / vscode-autohotkey2-lsp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

English | 中文

AutoHotkey v2 语言支持

installs version

仓库: Github | Gitee

AutoHotkey v2 语言支持 for VS Code, 功能实现基于 v2 语法分析。 支持在Chrome/Edge等浏览器中使用 https://vscode.devhttps://github.dev/github/dev

语言特性

重命名符号

作用域范围内的变量、函数名批量重命名。

rename

错误诊断

简单语法错误诊断。

diagnostics

智能感知

支持对作用域范围内的变量、函数、参数、类名、方法名智能补全(简单的类型推导),支持对 include 文件和函数库补全。

snippet1

snippet2

智能提示

支持对函数、方法参数的智能提示。

signature

大纲

  1. 在左侧大纲栏目显示类、方法、函数、变量、标签、热键、热字串、区块信息
  2. 按 Ctrl + P, 输入@符号名检索并跳转
  3. 您可以在函数、变量的上一行使用分号或/* */向方法添加注释, jsdoc 样式的注释可以标记变量类型
/**
 * @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()
}

语义高亮

语义高亮显示是语法高亮显示的补充,改进和改进语法中的语法突出显示。编辑器在来自语法的高亮显示之上应用来自语义标记的高亮显示。 semanticTokens

代码标记

用法: 在注释代码块中添加;;(默认)或; TODO
codeSymbole

颜色提示

计算并解析文档中的颜色,并提供颜色选择器更直观地修改颜色数据。

documentcolor

悬停提示

支持对作用域范围内变量、函数、全局类、标签的悬停提示并显示相关备注。
用法: 移动鼠标到相关符号上。
hover

转到定义

  1. 支持跳转到作用域范围内变量、函数、全局类、标签的声明位置。
  2. 用法: 按住 ctrl 然后移动鼠标到代码处点击。

gotoDefinition

查找所有引用

查看正在使用某个变量/函数的所有源代码位置。

代码格式化

用法:

  • 右键弹出菜单然后点击 格式化文档。
  • 或按 Shift+Alt+F
  • 支持在键入}时格式化代码块,在代码行结束处键入\n时格式化行并缩进。支持在代码区(非注释、字符串)输入中文标点时替换为英文标点。 (需要开启editor.format OnType)
  • 支持使用格式化指令;@format array_style: collapse, object_style: expand改变不同块的对象样式

codeFormat

自定义折叠

折叠;@region tag;@endregion之间部分, ;{;}之间部分

;@region tag
code
;@endregion

上下文菜单

快速帮助

打开帮助文件并导航到当前光标处的关键字。

运行脚本

运行当前打开的脚本。

运行选定的脚本

运行光标选择范围的代码片段。

编译脚本

编译脚本生成可执行的 EXE 文件。

调试脚本

无需额外配置即可启动已安装的调试扩展,支持带参数调试。

生成注释

为函数或方法生成 JSDOC 样式的注释文档。

在其他编辑器中使用

  1. 安装Node.js
  2. 用命令行下载 vscode-autohotkey2-lsp 服务端, 或通过vscode marketplace下载并解包。
mkdir vscode-autohotkey2-lsp
cd vscode-autohotkey2-lsp
curl -L -o install.js https://raw.githubusercontent.com/thqby/vscode-autohotkey2-lsp/main/tools/install.js
node install.js
  1. 设置支持LSP(语言服务器协议)的编辑器的 LSP 配置, 例如 Sublime Text4, Vim, Neovim, Emacs,

Sublime Text 4

  • Package Control: Install Package, 安装Sublime LSP插件
  • Preferences: LSP Settings, 增加 lsp 配置、语言选择器和语法高亮. 这是一个简单的语法高亮示例, 存放在类似路径下 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"
      ], // 更新node.exe的路径(可能已经在环境变量中,所以你不需要设置)和vscode-autohotkey2-lsp的文件夹
      "selector": "source.ahk2", // 与AutoHotkey2.sublime-syntax中的scope相同
      "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
}

Vim 和 Neovim

COC

cd $VIMRUNTIME\plugin
git clone --branch release https://github.com/neoclide/coc.nvim.git --depth=1
  • 打开(n)vim, 输入命令 :CocConfig 进入coc.nvim配置文件增加配置信息。
{
  "languageserver": {
    "lsp-ahk2": {
      "module": "<VSCODE-AUTOHOTKEY2-LSP>/server/dist/server.js",
      "filetypes": ["autohotkey"],
      "args": ["--node-ipc"],
      "initializationOptions": {
        // Same as initializationOptions for Sublime Text4
      }
    }
  }
}

nvim-lspconfig

  • 下载nvim-lspconfig
  • 将以下内容添加到您的NVIM配置中(init.lua 等). 确定cmd指向vscode-autohotkey2-lsp的安装路径,InterpreterPath指向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({})

在 Web 浏览器中使用

Chrome/Edge中打开 https://github.devhttps://vscode.dev, 然后安装thqby.vscode-autohotkey2-lsp

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

Autohotkey2 Language Support using vscode-lsp. 展开 收起
TypeScript 等 3 种语言
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/orz707/vscode-autohotkey2-lsp.git
git@gitee.com:orz707/vscode-autohotkey2-lsp.git
orz707
vscode-autohotkey2-lsp
vscode-autohotkey2-lsp
main

搜索帮助