-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurable user scripts location via env var
* Add smoke test for user-activate * Add JS example script to default user scripts content Addressing #136 TODO: * [ ] Add more smoke tests * [ ] Handle new my-lib location somehow
- Loading branch information
Showing
8 changed files
with
136 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
assets/getting-started-content/user/hello_joyride_user_script.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const vscode = require("vscode"); | ||
|
||
// You can write your Joyride scripts in JavaScript, if you want. | ||
|
||
const hello = () => { | ||
return "Hello World!"; | ||
}; | ||
|
||
const showHelloMessage = async () => { | ||
const button = await vscode.window.showInformationMessage("Hello World!", "Cancel", "OK"); | ||
if (button === "OK") { | ||
vscode.window.showInformationMessage("You clicked OK! Try clicking Cancel too?."); | ||
} else { | ||
const name = await vscode.window.showInputBox({ | ||
title: "CIA wants to know", | ||
prompt: "What is your name?", | ||
}); | ||
vscode.window.showInformationMessage(`Hello ${name}!`); | ||
} | ||
}; | ||
|
||
hello(); | ||
showHelloMessage(); | ||
|
||
exports = { | ||
hello, | ||
showHelloMessage, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(ns problem-hover | ||
(:require ["vscode" :as vscode])) | ||
|
||
;; Adding diagnostics info to the top of the hover to get it above the fold | ||
|
||
(defonce !problems (atom {})) | ||
|
||
(defn on-changed-diagnostics [event] | ||
(doseq [uri (.-uris event)] | ||
(swap! !problems assoc (.-fsPath uri) (vscode/languages.getDiagnostics uri)))) | ||
|
||
(defn- provide-hover [document position] | ||
(let [hover (vscode/MarkdownString.) | ||
problems (->> (get @!problems (-> document .-uri .-fsPath)) | ||
(keep (fn [problem] | ||
(let [range (.-range problem)] | ||
(when (.contains range position) | ||
problem)))))] | ||
(doseq [problem problems] | ||
(.appendCodeblock hover (str (.-message problem) | ||
"; " (.-source problem) | ||
(when (.-code problem) | ||
(str "(" (.-code problem) ")"))) | ||
; highlight hover as 'ini', because works | ||
"ini")) | ||
(new vscode/Hover #js [hover]))) | ||
|
||
(defn register-diagnostics-handler! [] | ||
(vscode/languages.onDidChangeDiagnostics on-changed-diagnostics)) | ||
|
||
(defn register-provider! [] | ||
; Use "*" instead of "clojure" to add this to all file types | ||
(vscode/languages.registerHoverProvider "clojure" #js {:provideHover provide-hover})) | ||
|
||
(comment | ||
foo | ||
(remove 1 2 3) | ||
:rcf) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
vscode-test-runner/workspace-1/.joyride/src/integration_test/user_activate_test.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(ns integration-test.user-activate-test | ||
(:require [cljs.test :refer [deftest testing is]] | ||
["path" :as path])) | ||
|
||
(deftest user-activate | ||
(testing "User activation script is required" | ||
(is #_{:clj-kondo/ignore [:unresolved-namespace]} | ||
(= #'user-activate/!db | ||
((ns-publics 'user-activate) '!db)))) | ||
|
||
(testing "my-lib is required" | ||
(is (seq | ||
(ns-publics 'my-lib))))) |