Skip to content

Commit

Permalink
Update npm package dependencies, in order to support the latest versi…
Browse files Browse the repository at this point in the history
…on of the Language Server Protocol (#3)

* * build fixes

* + added a config option for tracing the communication between the client and the language server

* * ran 'npm audit fix'

* * update some npm packages

* * upgraded the vscode-languageclient dependency to the latest version

* * fixed plugin crash on language server startup, due to API change after the version upgrade of vscode-languageclient

* * replaced vsmarketplacebadge.apphb.com with vsmarketplacebadges.dev as suggested by:
  https://code.visualstudio.com/api/references/extension-manifest#approved-badges
  Without this, 'nimble vsix' doesn't work

* * bump compiler dependency to 1.6.16 version (the latest stable Nim in the 1.6.x series)

* * updated build instructions for newer Nim compilers (adds a workaround for the fact that the `nim` package no longer provides the nimsuggest sources)
  • Loading branch information
nickysn authored Nov 30, 2023
1 parent 38e88cd commit 78ad644
Show file tree
Hide file tree
Showing 8 changed files with 3,118 additions and 1,585 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules
nimsuggest/nimcache
nimsuggest/nimsuggest.exe
nimsuggest/nimsuggest
*.vsix
*.vsix
nimble.develop
nimble.paths
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ This extension relies on nimsuggest for code completion. Nimsuggest is basically
## Developing the Extension

* If this is the first time you're building the extension on your machine, do an npm install to get the dependencies
* You should also copy (or create a symlink to) the `nimsuggest` directory from the Nim compiler sources into `src/nimsuggest`
* Press `F5` or whatever your `Run -> Start Debugging` command short cut is
* If prompted choose launch `Extension`
* This launches a new VS Code Window which is running your patched extension
Expand Down
2 changes: 1 addition & 1 deletion nim.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

define:nimsuggest
define:nodejs
define:js
#define:js
21 changes: 10 additions & 11 deletions nimvscode.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ bin = @["nimvscode"]

# Deps

requires "nim >= 1.3.7"
requires "compiler >= 1.3.7"
requires "nim == 1.6.16"

import std/os

Expand All @@ -22,18 +21,18 @@ proc initialNpmInstall =

# Tasks
task main, "This compiles the vscode Nim extension":
exec "nim js --outdir:out --checks:on --sourceMap src"/"nimvscode.nim"
exec "nim js --outdir:out --checks:on --sourceMap src/nimvscode.nim"

task release, "This compiles a release version":
exec "nim js -d:release -d:danger --outdir:out --checks:off --sourceMap src"/"nimvscode.nim"
exec "nim js -d:release -d:danger --outdir:out --checks:off --sourceMap src/nimvscode.nim"

task vsix, "Build VSIX package":
initialNpmInstall()
exec "npm exec -c 'vsce package --out out"/"nimvscode-" & version & ".vsix'"
exec "npm exec -c 'vsce package --out out/nimvscode-" & version & ".vsix'"

task install_vsix, "Install the VSIX package":
initialNpmInstall()
exec "code --install-extension out"/"nimvscode-" & version & ".vsix"
exec "code --install-extension out/nimvscode-" & version & ".vsix"

# Tasks for maintenance
task audit_node_deps, "Audit Node.js dependencies":
Expand All @@ -47,8 +46,8 @@ task upgrade_node_deps, "Upgrade Node.js dependencies":
exec "npm install"
echo "NOTE: 'engines' versions in 'package.json' need manually upgraded"

# Tasks for publishing the extension
task extReleasePatch, "Patch release on vscode marketplace and openvsx registry":
initialNpmInstall()
exec "npm exec -c 'vsce publish patch'" # this bumps the version number
exec "npm exec -c 'ovsx publish out"/"nimvscode-" & version & ".vsix'"
# # Tasks for publishing the extension
# task extReleasePatch, "Patch release on vscode marketplace and openvsx registry":
# initialNpmInstall()
# exec "npm exec -c 'vsce publish patch'" # this bumps the version number
# exec "npm exec -c 'ovsx publish " & out/nimvscode-" & version & ".vsix & "'"
4,646 changes: 3,080 additions & 1,566 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
"vscode:prepublish": "nimble release"
},
"dependencies": {
"vscode-languageclient": "7.0.0"
"vscode-languageclient": "^9.0.1"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/node": "^10.17.17",
"@types/vscode": "^1.27.0",
"@vscode/vsce": "^2.21.1",
"js-yaml": "^4.1.0",
"npm-check-updates": "^16.10.15",
"ovsx": "^0.2.1",
"ovsx": "^0.8.3",
"typescript": "^2.6.1",
"vsce": "^1.95.0",
"vscode-test": "^1.4.0"
},
"engines": {
Expand Down Expand Up @@ -295,6 +295,17 @@
"default": 80,
"description": "Nimpretty: set the desired maximum line length (default: 80).",
"scope": "resource"
},
"nimlangserver.trace.server": {
"scope": "window",
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Traces the communication between VS Code and the Nim language server."
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/nimLsp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ proc startLanguageServer(tryInstall: bool, state: ExtensionState) =
console.log("Starting nimlangserver.")
let
serverOptions = ServerOptions{
run: Executable{command: nimlangserver, transport: "stdio" },
debug: Executable{command: nimlangserver, transport: "stdio" }
run: Executable{command: nimlangserver, transport: TransportKind.stdio },
debug: Executable{command: nimlangserver, transport: TransportKind.stdio }
}
clientOptions = LanguageClientOptions{
documentSelector: @[DocumentFilter(scheme: cstring("file"),
Expand Down
8 changes: 7 additions & 1 deletion src/platform/languageClientApi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ type
VscodeLanguageClient* = ref VscodeLanguageClientObj
VscodeLanguageClientObj {.importc.} = object of JsRoot

TransportKind* {.pure.} = enum
stdio = 0,
ipc = 1,
pipe = 2,
socket = 3

Executable* = ref ExecutableObj
ExecutableObj {.importc.} = object of JsObject
command*: cstring
transport*: cstring
transport*: TransportKind

ServerOptions* = ref ServerOptionsObj
ServerOptionsObj* {.importc.} = object of JsObject
Expand Down

0 comments on commit 78ad644

Please sign in to comment.