Hey guys! (@MinusGix)
This PR is a followup on issue #603
I created a draft PR in order for us to have some grounds to discuss and make progress - The current work is by all means WIP.
~Another important note - since my previous pr (#615) is not yet merged, I started to work from my branch - so it contains the changes from the previous branch as well.
I'm really sorry for the inconvenience, but once #615 will be merged I'll re-arrange this PR / open a new one.
In the meanwhile - please take a look at the last commit in this PR.~
Edit (June 20th): I rebased from master so the mess is gone 🙂 (still a wip, no code changed)
Now that the technical notes are said, let me lay out my current work:
- I created a new LSP request to
textDocument/codeLens
- I added a command with prefix
$
to the palette, which queries the LSP for code lens and presents all possible runnable commands for the current file:
The debug prints at this point show the raw command returned from the LSP.
Note This LSP request works for every runnable entry point in the file, including fn main()
for example:
- I created a hook for when a runnable from the above palette is being chosen, which currently does nothing but debugging the command:
Running command: Command { title: "â–¶\u{fe0e} Run Tests", command: "rust-analyzer.runSingle", arguments: Some([Object({"args": Object({"cargoArgs": Array([String("test"), String("--package"), String("lapce-core"), String("--lib")]), "cargoExtraArgs": Array([]), "executableArgs": Array([String("syntax::tests"), String("--nocapture")]), "overrideCargo": Null, "workspaceRoot": String("/home/yoni/lapce")}), "kind": String("cargo"), "label": String("test-mod syntax::tests"), "location": Object({"targetRange": Object({"end": Object({"character": Number(1), "line": Number(475)}), "start": Object({"character": Number(0), "line": Number(439)})}), "targetSelectionRange": Object({"end": Object({"character": Number(9), "line": Number(440)}), "start": Object({"character": Number(4), "line": Number(440)})}), "targetUri": String("file:///home/yoni/lapce/lapce-core/src/syntax.rs")})})]) }
Next steps and open questions
- Decide on the UX / DX (developer experience) of this feature - I prefer to have a green arrow near each runnable entry (like JetBrains)
i. If we do decide on this UX, It'd be nice if you guys could suggest some relevant code references etc. on how to implement it, because to be frank I kinda got lost a bit there 😅
ii. Another option is to move forward with the palette option, just make it a bit more user friendly (with icons etc.)
iii. A third option is to join the party over the
CodeActions
area (gutter.rs
- the light bulb thingy) - and just add a Run test
command there when relevant.
- Implement running the command itself - There's an LSP request for this as well, just need to pass the data all the way back through the proxy and all...
Looking forward to hearing from you guys, please lmk how do you find the current progress and what you think about the next steps!
A-lsp