Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for OpenVSX #10

Merged
merged 2 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog

# 0.1.8 (19 Oct 2020)
* removed unneeded dependency on ms-vscode.cpptools (#10)
* added instructions for setting up native debugging (#10)

# 0.1.7 (10 Oct 2020)
* fixed `nim check` which now woks
* fixed issue highlighting from check results
Expand Down
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,62 @@ The following commands are provided by the extension:
* `Nim: Run selected file` - compile and run selected file, it uses `c` compiler by default, but you can specify `cpp` in `nim.buildCommand` config parameter.
This command available from file context menu or by `F6` keyboard shortcut.

---
### Debugging
Visual Studio Code inclues a powerful debugging system, and the Nim tooling can take advantage of that. However, in order to do so, some setup is required.

#### Setting up
First, install a debugging extension, such as [CodeLLDB](https://open-vsx.org/extension/vadimcn/vscode-lldb), and any native packages the extension may require (such as clang and lldb).

Next, you need to create a `tasks.json` file for your project, under the `.vscode` directory of your project root. Here is an example for CodeLLDB:
```jsonc
// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "nim: build current file (for debugging)",
"command": "nim",
"args": [
"compile",
"-g",
"--debugger:native",
"-o:${workspaceRoot}/bin/${fileBasenameNoExtension}",
"${relativeFile}"
],
"options": {
"cwd": "${workspaceRoot}"
},
"type": "shell",
}
]
}
```

Then, you need to create a launch configuration in the project's launch.json file. Again, this example works with CodeLLDB:
```jsonc
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "nim: debug current file",
"preLaunchTask": "nim: build current file (for debugging)",
"program": "${workspaceFolder}/bin/${fileBasenameNoExtension}",
"args": [],
"cwd": "${workspaceFolder}",
}
]
}
```

You should be set up now to be able to debug from a given file in the native VS Code(ium) debugger.

![Debugger preview screenshot](images/debugging-screenshot.png)

---
## TODO

* Clean-up
Expand All @@ -81,7 +137,6 @@ This command available from file context menu or by `F6` keyboard shortcut.
* Ignore node_modules entirely at this point
* Convert to asyncjs API
* Rename support
* Debug support
* Extract most functionality into an LSP (check existing one)
* Extract Visual Studio Code API into a separate Nimble package
* Switch to using concepts for interfaces
Expand Down
Binary file added images/debugging-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions nimvscode.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ srcDir = "src"
# Deps

requires "nim >= 1.3.7"
requires "compiler >= 1.2.0"

# Tasks
task main, "This compiles the vscode Nim extension":
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
"vsce": "^1.79.5",
"vscode-test": "^1.4.0"
},
"extensionDependencies": [
"ms-vscode.cpptools"
],
"engines": {
"vscode": "^1.27.0"
},
Expand Down