lsp

teodorlu 2024-08-13T13:04:24.831519Z

Idea for a code action: copy symbol with namespace

(ns my.app)
(defn f [x] 3)
Place cursor on f, run "copy symbol with namespace", then my.app/f is on the clipboard. Not sure if this is possible from inside an LSP process, perhaps somebody can correct me if it won't work? Use case: "I'm looking at a symbol and want to discuss the code with other people"

2
ericdallo 2024-08-13T13:29:29.255829Z

it's possible from java process, not sure if graalvm supports it, even so looks like a quite specific code action

👍 1
borkdude 2024-08-13T14:05:37.078979Z

This seems like a thing that any editor could support without lsp, copy the current token to the clipboard...

teodorlu 2024-08-13T14:16:38.295809Z

True!

ericdallo 2024-08-13T14:42:47.526169Z

I think no editor will know/have a logic that copying f will result in copying

borkdude 2024-08-13T14:43:20.168729Z

oh right

borkdude 2024-08-13T14:43:51.949839Z

now I understand your question, my bad

mkvlr 2024-08-13T14:45:08.176529Z

I use the repl for this (symbol #'f)

👍 1
ericdallo 2024-08-13T14:46:47.203249Z

yeah, that's something more suitable for REPL

mkvlr 2024-08-13T14:49:00.000859Z

could also shell out to pbcopy for the clipboard part or build a variant of cider-eval that copies the result to the clipboard (or just copy the normal eval output 🙃 )

borkdude 2024-08-13T14:49:02.225139Z

I mean, it's something clojure-lsp/kondo could easily do, but it's the copy/paste thing that is gnarly in the JVM ;)

borkdude 2024-08-13T14:49:48.360839Z

or just hand-write the symbol... ;)

mkvlr 2024-08-13T14:51:07.058519Z

or use the sharp quote. Nice thing about the var is autocompletion and errors on typos though

👍 1
lilactown 2024-08-13T18:20:51.461569Z

I think that's something that the editor should handle. You could easily write an Emacs command that runs (symbol (var ,,,)) on the current form and put it on the kill ring / native clipboard

lilactown 2024-08-13T18:22:54.020569Z

maybe there's an LSP command to return the fully qualified symbol?