Skip to content

Commit e2ad548

Browse files
committed
Merge branch 'dev' into master
2 parents 35f40bf + bfedeb8 commit e2ad548

28 files changed

+1718
-0
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: scottmwyant
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/cd.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: CD
2+
on:
3+
create:
4+
tag:
5+
- v\d+\.\d+\.\d+(\.[\w\d-]+)?
6+
env:
7+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8+
VSCE_PAT: ${{secrets.VSCE_PAT}}
9+
10+
jobs:
11+
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Checkout source code
17+
uses: actions/checkout@v2
18+
19+
# Make sure the version number in the tag matches the version in package.json
20+
- name: match-tag-to-package-version
21+
uses: geritol/match-tag-to-package-version@0.0.2 # https://github.com/geritol/match-tag-to-package-version
22+
env:
23+
TAG_PREFIX: refs/tags/v
24+
25+
# Parse the version number from the new tag
26+
- name: Get version
27+
id: semver
28+
uses: LykkeBusiness/get-semver-from-tag-action@v1.0.2
29+
with:
30+
tag: ${{ github.ref }}
31+
32+
# Update the 'latest' tag
33+
- name: Tag latest
34+
uses: richardsimko/update-tag@v1
35+
with:
36+
tag_name: latest
37+
38+
# Install deps, compile, and pack into .vsix
39+
- name: Build
40+
run: |
41+
npm install
42+
npx tsc --project src
43+
npm install --no-save vsce
44+
npx vsce --version
45+
npx vsce package --out ./gcode.vsix
46+
47+
# Read the changelog entry corresponding to the new version number
48+
- name: Read entry from changelog
49+
uses: mindsers/changelog-reader-action@v2 # https://github.com/mindsers/changelog-reader-action
50+
id: changelog_reader
51+
with:
52+
version: ${{ steps.semver.outputs.prefixed }}
53+
54+
# Create a new release on GitHub
55+
- name: Create a release
56+
uses: actions/create-release@v1 # https://github.com/actions/create-release/
57+
id: create_release
58+
with:
59+
tag_name: ${{ steps.semver.outputs.prefixed }}
60+
release_name: Release ${{ steps.semver.outputs.prefixed }}
61+
body: ${{ steps.changelog_reader.outputs.changes }}
62+
draft: false
63+
prerelease: false
64+
65+
# Upload the vsix to the release
66+
- name: Attach vsix
67+
uses: actions/upload-release-asset@v1 # https://github.com/actions/upload-release-asset
68+
id: upload-release-asset
69+
with:
70+
upload_url: ${{ steps.create_release.outputs.upload_url }}
71+
asset_path: ./gcode.vsix
72+
asset_name: gcode-${{ steps.semver.outputs.prefixed }}.vsix
73+
asset_content_type: application/vsix
74+
75+
# Publish the .vsix to the marketplace
76+
- name: Publish to marketplace
77+
run: npx vsce publish --packagePath gcode.vsix

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# References for .gitignore files
2+
https://www.atlassian.com/git/tutorials/saving-changes/gitignore
3+
4+
# Ignore node packages
5+
node_modules/
6+
7+
# Ignore compiled javascript files
8+
out/

.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// A launch configuration that launches the extension inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"runtimeExecutable": "${execPath}",
13+
"args": [
14+
"--extensionDevelopmentPath=${workspaceFolder}",
15+
"--disable-extensions",
16+
"${workspaceRoot}/.vscode/sample.nc"
17+
],
18+
"preLaunchTask": "${defaultBuildTask}"
19+
}
20+
]
21+
}

.vscode/sample.nc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
3+
N1 (MAR-09-2017-8:23:59AM)
4+
N2 G00 G17 G40 G90 G90 G94
5+
N100 G53 Z0
6+
N101 T20 (TA1955 : DRILL SPADE CTT 21/32 X 3.2 132POINT)
7+
N102 M6
8+
N103 T15
9+
N104 (DRILL-MT-HOLES)
10+
N105 S3735 M03
11+
N106 M12
12+
N107 G90 G54
13+
N108 G00 X24. Y-9.
14+
N109 G43 H20 Z4.1
15+
Z4.
16+
G98 G81 X24. Y-9. Z-0.291 R1.25 F45.
17+
X12. Y-9.
18+
X0. Y-9.
19+
X-12. Y-9.
20+
X-24. Y-9.
21+
X-24 Y9.
22+
X-12 Y9.
23+
X0. Y9.
24+
X12. Y9.
25+
X24. Y9.
26+
G80
27+
M05

.vscode/tasks.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "compile",
7+
"group": {
8+
"kind": "build",
9+
"isDefault": true
10+
}
11+
}
12+
]
13+
}

.vscodeignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Top level files
3+
.gitignore
4+
5+
# Top level folders
6+
.vscode/**
7+
src/**
8+
.github/**

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Change Log
2+
3+
All notable changes will be documented in this file.
4+
5+
Contributors: This document uses style guidelines from [Keep A Changelog](http://keepachangelog.com/).
6+
7+
## [v0.1.0] - 2020-11-13
8+
9+
Merge dev branch into master. This is the initial release. Previous version numbers were simply used to test the GitHub Actions continuous deployment workflow. Since this is the intial release, I won't go into much detail here, I'll just list the featuers and put the details the project's README.
10+
11+
#### Added
12+
13+
- Adaptive Syntax Highlighting
14+
- Show Definition On Hover
15+
- Line Numbering Commands
16+
- Toggle Comment Command
17+
18+
### Changed
19+
20+
- The CD workflow has been merged into the dev branch. The workflow is now triggered by new tag being pushed. The release created by the workflow will be published (no longer be left as a draft).
21+
22+
- Updated package.json. The extension is now flagged as a "preview". I don't intend to keep this flag for long. Added keys to quiet complaints from `npm` and `vsce`.
23+
24+
## [v0.0.3] - 2020-11-06
25+
26+
### Changed
27+
28+
- CI workflow will now publish to the marketplace.
29+
30+
## [v0.0.2] - 2020-11-04
31+
32+
### Changed
33+
34+
- CI workflow is now triggered by a push to the `CI` branch. This is for testing the publishing workflow.
35+
36+
## [v0.0.1] - 2020-11-04
37+
38+
### Added
39+
40+
- GitHub actions workflow to automate publishing to the marketplace.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Scott Wyant
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<br/><p align="center"><img src="https://user-images.githubusercontent.com/29161635/93551441-de870a00-f93b-11ea-82a3-48c360d2f732.png" alt="icon" width="200px"></p><br/>
2+
3+
# [G-Code for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=vscode-gcode.gcode)
4+
5+
**The premier Visual Studio Code extension for G-Code**
6+
7+
<br>
8+
9+
<!--Badges from https://shields.io-->
10+
![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/vscode-gcode.gcode) ![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/vscode-gcode.gcode?color=%23f5f5f5&logo=installs) ![Visual Studio Marketplace Rating](https://img.shields.io/visual-studio-marketplace/r/vscode-gcode.gcode)
11+
12+
## ✨ Features
13+
14+
### Adaptive Syntax Highlighting
15+
16+
**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Adapt to current theme`**
17+
18+
<p align="center"><img src="https://user-images.githubusercontent.com/29161635/96535493-f49c2900-125f-11eb-9e03-b395d231b82d.gif" alt="icon" height="400px" width="500px"></p>
19+
20+
CAD/CAM packages typically show the X-axis in red, the Y-axis in green, and the Z-Axis in blue. The G-Code extension follows that pattern. The adaptive syntax feature allows you to choose any of the supproted themes and get that familiar colorization. G-Code supports all of the themes that ship with VS Code, plus the [GitHub theme](https://marketplace.visualstudio.com/items?itemName=GitHub.github-vscode-theme) and [OneDark-Pro](https://marketplace.visualstudio.com/items?itemName=zhuangtongfa.Material-theme).
21+
22+
- When VS Code starts and the extension activates, it will check the active theme and if the extension's syntax highlighting isn't already tailored to that theme, you will be prompted to allow the extension to rewrite the files that style the code.
23+
24+
- Should you miss the prompt, you can use the `G-Code: Adapt to current theme` command to force the extension to adapt to the theme you're using (as long as it's supported).
25+
26+
27+
### On-Hover Definitions
28+
29+
<p align="center"><img src="https://user-images.githubusercontent.com/29161635/98761008-7cc6a780-23a2-11eb-819c-2f8287e03320.gif" alt="icon" height="400px" width="500px"></p>
30+
31+
You no longer need to memorize dozens of obscure G and M codes! The G-Code extension includes a mechanism for you to *provide your own definitions* for any number of codes. Definitions can even be provided *inline* with the code.
32+
33+
#### Using VS Code settings
34+
35+
Share definitions across multiple programs using VS Code's settings files. Take a look at [VS Code Docs - User and Workspace Settings](https://code.visualstudio.com/docs/getstarted/settings) if you're not familiar VS Code configuration.
36+
37+
You need to add a `gcode.definitions` key to your settings.json file (user settings, workspace settings, or both). Here's an example of what it might look like:
38+
39+
```json
40+
"gcode.definitions": {
41+
"G90": "Positioning, absolute (modal)",
42+
"G91": "Positioning, relative (modal)",
43+
"M8": "Coolant On, External to Spindle",
44+
"M9": "Coolant Off",
45+
"M51": "Coolant On, Internal to Spindle",
46+
}
47+
```
48+
49+
#### Using inline definitions
50+
51+
An inline definition is a comment in your code that matches the following format. An inline definition has a `code` and a `meaning` seperated by `:` or `=`. There may be whitespace on either side of the seperator. The text on the right side of the seperator will show up as hover text in that file. See some examples of inline definitions below.
52+
53+
Note that after you add inline definitions to a file, they won't show up in a hover until you activate the file agian. Either close that file and re-open it, or activate another file then switch back. This prevents the extension from needing to continuously scan your file for definitions.
54+
55+
Examples of inline definitions:
56+
57+
```
58+
(G4:DWELL)
59+
(G4: THIS IS A DWELL)
60+
(G4 = DWELL, USE P TO SPECIFY TIME)
61+
```
62+
63+
#### A word on leading zeros
64+
65+
When providing definitions, regardless of which method you use, don't use leading zeros. Provide a definition for `G1` not `G01`. When you hover over a code like `G01` the extension ignores the leading zero and returns a definition for `G1`.
66+
67+
### Line Numbering
68+
69+
**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Line Numbers (Add/Update)`**
70+
71+
**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Line Numbers (Remove)`**
72+
73+
<p align="center"><img src="https://user-images.githubusercontent.com/29161635/99023619-f392aa80-2532-11eb-8328-2f594652a3c4.gif" alt="icon" height="400px" width="500px"></p>
74+
75+
Addding, updating, or removing line numbers are not tasks you should ever need to do manually. A robust G-Code editor should make this easy as possible so you can focus on more important things. The G-Code extension provides commands to carry out these tasks on the active file. Don't forget that you can map commands to a keyboard shortcut of your choice. See [Key Bindings for Visual Studio Code](https://code.visualstudio.com/docs/getstarted/keybindings).
76+
77+
### Toggle Comments
78+
79+
**<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> `>G-Code: Toggle Comment`**
80+
81+
<p align="center"><img src="https://user-images.githubusercontent.com/29161635/99023050-cf829980-2531-11eb-92be-b4516f3b4e95.gif" alt="icon" height="400px" width="500px"></p>
82+
83+
VS Code ships with the ability to toggle comments. The built-in feature works by modifying one or more characters at the beginning of each selected line. Since it only affects the beginning of the line, it doesn't work for G-Code comments that need to be (in parentheses). The G-Code extension provides a command that will toggle parenthesis at the start and end of each selected line.
84+
85+
## 📓 Release Notes
86+
87+
Documentation pertaining to a specific release can be found under [releases](https://github.com/scottmwyant/vscode-gcode/releases), or in the project's [changelog](./CHANGELOG.md).
88+
89+
## 💻 Developers
90+
91+
### VS Code Token Styles
92+
93+
Early on I realized I needed a way to see how each VS Code theme styles the various language tokens. My approach was to get data for each theme by using the `Developer: Generate Color Theme From Current Settings` command then use that data to render HTML. Since that work may be intersting outside of this project, I chose to save it in [this gist](https://gist.github.com/scottmwyant/2dc64ff4315ba9e2c374fb329b399820).
94+
95+
### Automated Deployment
96+
97+
Maintainers, here's how to publish the extension to the marketplace:
98+
99+
1. Put the new version number in [package.json](./package.json). The version number must be higher than the version shown in the [marketplace](https://marketplace.visualstudio.com/items?itemName=vscode-gcode.gcode). Reference [semver.org](https://semver.org/).
100+
2. Create an entry in the [changelog](./changelog.md). Reference [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
101+
3. Push a new tag with the version number. The tag must start with a 'v', like this: `v1.2.3`.
102+
103+
As long as these requirements are met, the CD workflow should go smoothly. A release will be created, and the new version of the extension will be published to the marketplace (see [./github/workflows](./.github/workflows)).

0 commit comments

Comments
 (0)