Skip to content

Commit

Permalink
v2 support preview (mark-wiemer#378)
Browse files Browse the repository at this point in the history
* begin v2 support: blue icon for v2 scripts

* Change to GPL license

* Add v2 grammar

* Note grammar contributor

* Clarify extensions

* Revert license change

* Update changelog

* Update compiler error message

* Remove unused vars

* Rename settings and uncomment changelog

* Add basic compiler test

* Update icons

* Update icon size

* Add v2 base path for compilation

* Note v1-limited settings

* Change runnerPath to interpreterPath

* Add basic run test

* Update run selection test

* Fixup help test

* Fixup compile tests

* Update to interpreterPathV1

* Add help for v2

* Move useMpress to end of list

* Remove old comment

* Update known issues

* Update metadata for v2 support

* Add basic debug and run v2 tests

* Remove unused readme

* Add template snippet for v2

* Add issue template for v2

* Move help service back to main folder

* Update changelog and v2 template

* Add language version service and update metadata

* Add runSelection.ahk2

* Fixup documentation

* Update template service

* Update langaugeVersionService
  • Loading branch information
mark-wiemer authored Aug 8, 2023
1 parent aaba491 commit e124efd
Show file tree
Hide file tree
Showing 70 changed files with 2,059 additions and 147 deletions.
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ assignees: mark-wiemer

<!--
Please note the known limitations of AHK v2 support:
Please note the known limitations of AHK v2 support. These issues are already being addressed :)
- No formatting
- No snippets
- Formatting ([Issue #381](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/381))
- Snippets ([Issue #382](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/382))
<!-- -->
-->

**Is your feature request related to a problem? Please describe.**
**Is your issue related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ out
# Files
.vscode/settings.json
*.vsix
language/*.json
language/*.tmLanguage.json
*.exe
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ out
# Files
.vscode/settings.json
*.vsix
language/*.json
language/*.tmLanguage.json
*.exe
8 changes: 5 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"preLaunchTask": "npm: compile"
},
// TODO untested
{
"type": "ahk",
"request": "launch",
"name": "Autohotkey v1 Debugger",
"program": "${workspaceFolder}/demos/demo_for_ahk_v1.ahk",
"program": "${workspaceFolder}/demos/v1Demo.ahk",
"runtime": "C:\\Program Files\\Autohotkey\\AutoHotkeyU64.exe",
"stopOnEntry": false,
"dbgpSettings": {
"max_children": 149
}
},
// TODO untested
{
"type": "ahk",
"type": "ahk2",
"request": "launch",
"name": "Autohotkey v2 Debugger",
"program": "${workspaceFolder}/demos/demo_for_ahk_v2.ahk",
"program": "${workspaceFolder}/demos/v2Demo.ahk",
"runtime": "C:\\Program Files\\AutoHotkey\\v2-alpha\\x64\\AutoHotkey.exe", // Default value of Scite for ahk v2
"stopOnEntry": false,
"dbgpSettings": {
Expand Down
40 changes: 40 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,46 @@
<!-- PRs -- Find: `#([0-9]+)`, Replace `[PR #$1](https://github.com/vscode-autohotkey/ahkpp/pull/$1)` -->
<!-- Issues -- Find: `#([0-9]+)`, Replace `[#$1](https://github.com/vscode-autohotkey/ahkpp/issues/$1)` -->

## 5.0.0 - Unreleased ✌️

AutoHotkey v2 support now in preview! Please test it out and [report any issues](https://github.com/mark-wiemer-org/ahkpp/issues/new?assignees=mark-wiemer&labels=AHK+v2&projects=&template=v2.md&title=%5Bv2%5D+), you'll help the community of 120,000+ users of this extension!

Be sure to go to the settings and update the new `V2` settings in case the defaults aren't correct 😊

### Breaking changes

- Rename some settings. Users will have to manually adjust these new settings from the defaults to match their old settings:
- `ahk++.compiler.compileBaseFile` is now `ahk++.compiler.compileBaseFileV1`
- `ahk++.file.compilePath` is now `ahk++.file.compilerPath`
- `ahk++.file.executePath` is now `ahk++.file.interpreterPathV1`
- `ahk++.file.helpPath` is now `ahk++.file.helpPathV1`
- `ahk++.file.templateSnippetName` is now `ahk++.file.templateSnippetNameV1` with default value `AhkTemplateV1`

### Other changes

- Allow `.ahk1` and `.ah1` extensions for v1 scripts, `.ahk2` and `.ah2` for v2 scripts. `.ahk` and `.ext` can be used for either version and still default to v1.
- Automatically change AHK version to match the `#Requires` directive near the top of any script the first time that script is opened
- Allow running and debugging v1 or v2 scripts without changing settings
- "Open help" (Ctrl + F1) now opens version-specific help
- Add full syntax highlighting for v2 scripts thanks to [AutoHotkey v2 Language Support by thqby](https://marketplace.visualstudio.com/items?itemName=thqby.vscode-autohotkey2-lsp)
- Update icons (found next to a script's name in the explorer)
- v2 scripts will have official green icons, while v1 scripts now have modified blue icons
- Icons are a bit smaller to align with existing VS Code icons

### Known issues

Some features are not added to this initial preview release, but will be coming soon!

- Missing features for AHK v2:
- Formatting ([Issue #381](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/381))
- Snippets ([Issue #382](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/382))

### Thank you!

This update relies heavily on open-source code from [thqby](https://github.com/thqby) and [Steve Gray (Lexikos)](https://github.com/Lexikos). Thank you for your awesome work!

<!-- -->

## 4.1.0 - 2023-08-03 🙋

- Add quick help, adapted from thqby's AutoHotkey v2 Language Support
Expand Down
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

Files are licensed under MIT License by default. Files licensed under GNU GPLv3 are marked as such at the top of the file.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---

GNU GENERAL PUBLIC LICENSE
Expand Down
39 changes: 29 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# AutoHotkey Plus Plus (AHK++)

AutoHotkey Plus Plus (AHK++) provides AutoHotkey language support for VS Code. This includes:
AutoHotkey Plus Plus (AHK++) provides AutoHotkey v1 and v2 language support for VS Code. This includes:

- IntelliSense
- code highlighting
- basic debug support
- debug support
- code formatting
- ...and more!

AHK++ is a fork of [AutoHotkey Plus by cweijan](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-autohotkey-plus) with the primary goal of fixing bugs and adding user-requested features.
## 5.0.0 - AutoHotkey v2 support now in preview!

> View this README on [GitHub](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus#readme)
AutoHotkey v2 support has been a [long-requested feature](https://github.com/mark-wiemer-org/ahkpp/issues/96), and this release now supports nearly all functionality!

> Currently, AHK++ officially supports only AHK v1. AHK v2 will likely work, but please open issues and be patient if complex workflows are not supported. See [issue 146: Support AHK v2](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/146)
Supported features include:

- Running and debugging v1 and v2 scripts without changing settings
- "Open help" (Ctrl + F1) opens language-specific help (and includes your text selection!)
- Full syntax highlighting for v2 scripts
- Unique icons for v1 (blue) and v2 (green)

See the full changes at the [changelog](https://github.com/mark-wiemer-org/ahkpp/blob/main/Changelog.md).

As always, please [report any issues](https://github.com/mark-wiemer-org/ahkpp/issues/new/choose)!

## Contents

Expand All @@ -31,15 +40,17 @@ AHK++ is a fork of [AutoHotkey Plus by cweijan](https://marketplace.visualstudio
- [Code format](#code-format)
- [Formatter directives](#formatter-directives)
- [Credits](#credits)
- [Links](#links)

## Why AutoHotkey Plus Plus?

AutoHotkey Plus Plus is one of many extensions that offer VS Code language support. So why should you use this one?

- **IntelliSense**: Smart code completion, syntax highlighting, code navigation, and more.
- **Supports both v1 and v2**: AHK++ now has support for AutoHotkey v2 (in preview), making it the only extension to support both major versions of AutoHotkey!
- **Actively maintained**: Any issues encountered while using this extension can be reported and fixed. With other extensions, anything that's broken will stay broken forever. You can report any issues with AHK++ (and view all issues) through the [issue tracker](https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues).
- **IntelliSense**: Smart code completion, syntax highlighting, code navigation, and more.
- **Debug support**: Run and debug AHK scripts from VS Code.
- **New features**: Another benefit to active maintenance is that AHK++ can add new features as users request them.
- **New features**: Another benefit to active maintenance is that AHK++ can add new features as users request them. For example, quick help, formatter directives, and custom new file templates were all added based on user feedback!

## Install

Expand Down Expand Up @@ -161,7 +172,15 @@ Formatter directives instruct the formatter to behave a certain way on sections
## Credits
Previous extensions:
This extension relies heavily on open-source code. A huge thank you to all these open-source participants who made the extension what it is today!
- [AutoHotkey Plus by cweijan](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-autohotkey-plus): AHK++ is a fork of AutoHotkey Plus by cweijan (Weijan Chen)
- [Contributions to AHK++ by kyklish](https://github.com/mark-wiemer-org/ahkpp/commits/main?author=kyklish): Greatly improved formatting and snippets by both fixing bugs and adding features
- [AutoHotkey v2 Language Support by thqby](https://marketplace.visualstudio.com/items?itemName=thqby.vscode-autohotkey2-lsp): The source of the v2 grammar and other great contributions
- [Lexikos/vscode-auto-select](https://github.com/Lexikos/vscode-auto-select): The core code for automatically switching AHK versions
- [AutoHotkey by stef-levesque](https://marketplace.visualstudio.com/items?itemName=slevesque.vscode-autohotkey): AutoHotkey Plus is a fork of stef-levesque's original AutoHotkey extension, which provided the original grammar and snippets for AHK
## Links
- [AutoHotkey Plus by cweijan](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-autohotkey-plus)
- [AutoHotkey by stef-levesque](https://marketplace.visualstudio.com/items?itemName=slevesque.vscode-autohotkey)
- [GitHub](https://github.com/mark-wiemer-org/ahkpp): View code, file bugs, and join discussions
- [Reviews](https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus&ssr=false#review-details): Help others discover AHK++ by leaving a review
3 changes: 0 additions & 3 deletions demos/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions demos/manualTests/compile.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Requires AutoHotkey 1.1.33+
#SingleInstance force

MsgBox % "Hello world!"
ExitApp

; Settings: No compile base file v1
; Open Ahk2Exe.exe and set base file to a v1 interpreter. Save as default.
; Ctrl+Shift+F9 to compile this script

; Settings: Compile base file v1 set to v1 interpreter.
; C:/Program Files/AutoHotkey/v1.1.37.01/AutoHotkeyU64.exe
; Open Ahk2Exe.exe and set base file to a v2 interpreter. Save as default.
; Ctrl+Shift+F9 to compile this script
14 changes: 14 additions & 0 deletions demos/manualTests/compile.ahk2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Requires AutoHotkey 2+
#SingleInstance force

MsgBox("Hello world v2!")
ExitApp()

; Settings: No base file v2.
; Open Ahk2Exe.exe and set base file to a v2 interpreter. Save as default.
; Ctrl+Shift+F9 to compile this script

; Settings: Base file v2 set to v2 interpreter:
; C:/Program Files/AutoHotkey/v2/AutoHotkey64.exe
; Open Ahk2Exe.exe and set base file to a v1 interpreter. Save as default.
; Ctrl+Shift+F9 to compile this script
1 change: 1 addition & 0 deletions demos/manualTests/debugger.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

; Basic debugger test
; Ensure you've run `npm i` before running this test
; 0. Debug button should appear in title bar
; 1. Stop on breakpoint
; 2. Step forward works -- Global variables updates
; 3. No errors in Debug Console
Expand Down
13 changes: 13 additions & 0 deletions demos/manualTests/debugger.ahk2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey 2+
#SingleInstance

; Basic debugger test
; Ensure you've run `npm i` before running this test
; 0. Debug button should appear in title bar
; 1. Stop on breakpoint
; 2. Step forward works -- Global variables updates
; 3. No errors in Debug Console

x := 1
y := 2 ; Breakpoint here
z := 3
2 changes: 1 addition & 1 deletion demos/manualTests/help.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
; Click on a word (but don't select it), open help should still search that word
; Use open help when your cursor is on a blank line--no errors should occur

"potato" ; selecting that value (including strings) should not cause an error
"potato" ; selecting that value (including quotes) should not cause an error

; Try 10 different words to ensure values load consistently
10 changes: 10 additions & 0 deletions demos/manualTests/help.ahk2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Requires AutoHotkey 2+
#SingleInstance

; Select a word and use Ctrl+F1 to open help
; Click on a word (but don't select it), open help should still search that word
; Use open help when your cursor is on a blank line--no errors should occur

"potato" ; selecting that value (including quotes) should not cause an error

; Try 10 different words to ensure values load consistently
5 changes: 5 additions & 0 deletions demos/manualTests/languageVersion-1.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
; #Requires AutoHotkey v1 ; ignores commented directives
#Requires AutoHotkey v2

; When opening this file, language should be set to AHK v2 with info message
; Changing the Requires directive should not cause language to switch back until extension is restarted.
2 changes: 2 additions & 0 deletions demos/manualTests/languageVersion-2.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; No directives--no attempt to switch to undefined.
; This file should stay with its default language version
13 changes: 13 additions & 0 deletions demos/manualTests/languageVersion-3.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey v2
; Pick an extension from below
; Change requires version to opposite of that extension
; Then change file name to end with that extension
; Extensions:
; ahk
; ext
; ah1
; ah2
; ahk1
; ahk2
;
; Repeat for every extension, it should work every time
13 changes: 13 additions & 0 deletions demos/manualTests/languageVersion-4.ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey v2
; Pick an extension from below
; Change requires version to opposite of that extension
; Then change file name to end with that extension
; Extensions:
; ahk
; ext
; ah1
; ah2
; ahk1
; ahk2
;
; Repeat for every extension, it should work every time
13 changes: 13 additions & 0 deletions demos/manualTests/languageVersion-5.ah1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey v2
; Pick an extension from below
; Change requires version to opposite of that extension
; Then change file name to end with that extension
; Extensions:
; ahk
; ext
; ah1
; ah2
; ahk1
; ahk2
;
; Repeat for every extension, it should work every time
13 changes: 13 additions & 0 deletions demos/manualTests/languageVersion-6.ah2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey v1
; Pick an extension from below
; Change requires version to opposite of that extension
; Then change file name to end with that extension
; Extensions:
; ahk
; ext
; ah1
; ah2
; ahk1
; ahk2
;
; Repeat for every extension, it should work every time
13 changes: 13 additions & 0 deletions demos/manualTests/languageVersion-7.ahk1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey v2
; Pick an extension from below
; Change requires version to opposite of that extension
; Then change file name to end with that extension
; Extensions:
; ahk
; ext
; ah1
; ah2
; ahk1
; ahk2
;
; Repeat for every extension, it should work every time
13 changes: 13 additions & 0 deletions demos/manualTests/languageVersion-8.ahk2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Requires AutoHotkey v1
; Pick an extension from below
; Change requires version to opposite of that extension
; Then change file name to end with that extension
; Extensions:
; ahk
; ext
; ah1
; ah2
; ahk1
; ahk2
;
; Repeat for every extension, it should work every time
8 changes: 8 additions & 0 deletions demos/manualTests/run.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Requires AutoHotkey 1.1.33+
#SingleInstance force

; Ctrl+F9 to run

MsgBox % "You did it!"

ExitApp
8 changes: 8 additions & 0 deletions demos/manualTests/run.ahk2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Requires AutoHotkey 2+
#SingleInstance

; Ctrl+F9 to run

MsgBox("You did it!")

ExitApp()
Loading

0 comments on commit e124efd

Please sign in to comment.