Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
https://conjure.oli.me.uk
The Unlicense
1.76k stars 109 forks source link

Common Lisp Go To Definition #606

Open mjcurciojr opened 1 month ago

mjcurciojr commented 1 month ago

Hi @Olical,

I noticed that currently go to definition is not supported for common lisp, attempting to use the binding on some symbol results in the error message:

E5108: Error executing lua: Vim:Error executing Lua callback: Conjure client 'conjure.client.common-lisp.swank' doesn't support function: def-str
stack traceback:
    [builtin#19]: at 0x010359758c
    [C]: at 0x0102b8e91c
stack traceback:
    [C]: at 0x0102b8e91c

Similar to the common lisp completions, if desired, we can leverage a feature of swank basically 1 to 1 in order to add this capability by using SWANK:FIND-DEFINITION-FOR-EMACS. Here's a sample request-response:

Read: (:EMACS-REX (SWANK:FIND-DEFINITIONS-FOR-EMACS "compile-plan") "PIKE" :REPL-THREAD 44)
Write: (:RETURN
 (:OK
  (("(DEFGENERIC COMPILE-PLAN
    (PS))"
    (:ERROR
     "Error: DEFINITION-SOURCE of generic-function COMPILE-PLAN did not contain meaningful information."))
   ("(DEFMETHOD COMPILE-PLAN PIKE-SESSION)"
    (:LOCATION
     (:FILE "/home/steve/mtk/workspaces/primary/pike/src/compile-plan.lisp")
     (:POSITION 1940)
     (:SNIPPET "(defmethod compile-plan ((ps pike-session))
  \"Top-level compilation function. This prepares
   Pike for execution, and may throw errors if problems
   are detected.\"

  ;; TODO - check success for each for each of these!
  ;; Use signals, etc. Make sure e")))))
 44)

(Sourced from Neil Lindquist's great repository, sample found here).

Is this something that is currently on the roadmap or that is being worked on, or is this something that we'd be interested in having in Conjure proper? I understand from reading other issues that some capabilities may be better left to plugins. If it is something we are wanting then I am more than happy to take a swing at the first PR as well.

Thanks!

Olical commented 1 month ago

That looks really interesting and I'm fully open to this being in the core repo. The idea of 3rd party plugins is just to make it easier for maintainers other than myself to maintain a client for something they deeply care about a little easier. Or if they want to add lots of clever features that I might consider feature creep or I worry about maintaining indefinitely once they're gone is all.

Adding completion to a client or go to Def is well within the scope of this repo though. If you would like to have a go at this, please use the new main branch which requires you to have Olical/nfnl installed.

It will automatically compile the Lua as you write the Fennel files, so no compile step or custom CLI tooling is required these days.

No worries if you can't or won't dive into the code yourself though, this info is still helpful!

On Tue, 10 Sept 2024, 08:36 Michael Curcio, @.***> wrote:

Hi @Olical https://github.com/Olical,

I noticed that currently go to definition is not support for common lisp, attempting to use the binding on some symbol results in the error message:

E5108: Error executing lua: Vim:Error executing Lua callback: Conjure client 'conjure.client.common-lisp.swank' doesn't support function: def-str stack traceback: [builtin#19]: at 0x010359758c [C]: at 0x0102b8e91c stack traceback: [C]: at 0x0102b8e91c

Similar to the common lisp completions, if desired, we can leverage a feature of swank basically 1 to 1 in order to add this capability by using the SWANK:FIND-DEFINITION-FOR-EMACS. Here's a sample request-response:

Read: (:EMACS-REX (SWANK:FIND-DEFINITIONS-FOR-EMACS "compile-plan") "PIKE" :REPL-THREAD 44) Write: (:RETURN (:OK (("(DEFGENERIC COMPILE-PLAN (PS))" (:ERROR "Error: DEFINITION-SOURCE of generic-function COMPILE-PLAN did not contain meaningful information.")) ("(DEFMETHOD COMPILE-PLAN PIKE-SESSION)" (:LOCATION (:FILE "/home/steve/mtk/workspaces/primary/pike/src/compile-plan.lisp") (:POSITION 1940) (:SNIPPET "(defmethod compile-plan ((ps pike-session)) \"Top-level compilation function. This prepares Pike for execution, and may throw errors if problems are detected.\"

;; TODO - check success for each for each of these! ;; Use signals, etc. Make sure e"))))) 44)

(Sourced from Neil Lindquist's great repository, sample found here https://github.com/neil-lindquist/swank-client/tree/master/notes.

Is this something that is currently on the roadmap or that is being worked on, or is this something that we'd be interested in having in Conjure proper? I understand from reading other issues that some capabilities may be better left to plugins. If it is something we are wanting then I am more than happy to take a swing at the first PR as well.

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/Olical/conjure/issues/606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XLP22RQWCO5L7433C3ZV2ORRAVCNFSM6AAAAABN6DRBGKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUYTKNRVGAYDANA . You are receiving this because you were mentioned.Message ID: @.***>

russtoku commented 1 month ago

Thanks for the link to the swank request-response library. I’m willing to help if you want a collaborator.