conjure
conjure copied to clipboard
Common Lisp Completion
It'd be awesome to get Conjure to provide completion for Common Lisp. I've looked far and wide, and couldn't find any suitable language server or other completion provider that's easy to integrate into nvim-cmp. Considering that Conjure otherwise makes for an amazing development environment, it'd be great to expand it further.
I'm not sure about this. In my perspective, conjure is designed as an evaluation environment, rather than a completion source.
Also does that require common lisp codes in this project?
What's preventing you from writing a common lisp language server? That feels more modular than just integrate the feature you request for in this project.
I'm very strongly leaning towards "just use LSP" for anything like this these days. The tooling outside and inside of Neovim has come along so far. LSP + DAP cover 90% of what everyone needs beautifully, Conjure should narrow it's focus down onto running your program and executing chunks of code, allowing you to merge the concept of editor and REPL. I'm going to close this in favour of recommending LSP for now, feel free to reopen or comment with opinions against this!
This isn't an option, mainly since I've not found an LSP that works, but also because there is not really a way to do an LSP in the traditional sense in Common Lisp. The whole language environment is so dynamic that static analysis like what an LSP would typically do is impossible. The only way an LSP in CL could possibly work is if it were running under the same runtime as the REPL server Conjure is connected to. However, such an LSP does not exist.
Considering that this would then mean having 2 connections between the CL runtime and Neovim (1 for Conjure, 1 for this hypothetical LSP) whereas the SWANK API Conjure uses already provides LSP-like APIs for completion and such (I believe?), this solution makes little to no sense.
Ah interesting, I didn't realise static analysis was kinda not valid in the CL space, I've never looked into it too closely and have very surface level knowledge. Thanks for explaining! I'll reopen and keep it in the backlog of things to enhance if there's no LSP with autocomplete for CL, I just thought it'd be similar to Clojure or something where yes there's REPL state, but it should almost perfectly reflect the static analysis anyway.
Well then the codebase should be shifted to another project that implement LSP based on Sly/Swank or whatever. BTW, Olical says he will likely to redesign this plugin (reference here ). I guess by then people can implement whatever they want in a separate plugin rather than keep throwing everything together.
Alternatives to LSP:
- nvim-cmp-vlime is an nvim-cmp completion source for Common Lisp via Vlime (see List of sources). Downside: duplicated REPLs and more set-up.
- Another project to build an nvim-cmp completion source plugin that would use the Conjure Common Lisp client's connection to a Common Lisp REPL running the Swank LISP code. Downside: a bit convoluted but, hopefully, less work than building an LSP server.
Having said that, if the future direction of Conjure stil includes completions as a client feature, then it would be reasonable to add the functionality to the Common Lisp client.
Of course, someone needs to implement the completion functionality whether the "mode" is LSP, nvim-cmp source, or client feature.
Hmm we already have a cmp source I think? And conjure clients have a hook for completions, each client needs to implement it though.
So if we implement that function in the CL client we just need to know which code to eval to complete a given string. This is all in conjure already and how Clojure does it.
On Sat, 8 Jul 2023, 02:46 Russ Tokuyama, @.***> wrote:
Alternatives to LSP:
- nvim-cmp-vlime https://github.com/HiPhish/nvim-cmp-vlime is an nvim-cmp completion source for Common Lisp via Vlime https://github.com/vlime/vlime (see List of sources https://github.com/hrsh7th/nvim-cmp/wiki/List-of-sources). Downside: duplicated REPLs and more set-up.
- Another project to build an nvim-cmp completion source plugin that would use the Conjure Common Lisp client's connection to a Common Lisp REPL running the Swank LISP code. Downside: a bit convoluted but, hopefully, less work than building an LSP server.
Having said that, if the future direction of Conjure stil includes completions https://github.com/Olical/conjure/wiki/Client-features#completions as a client feature, then it would be reasonable to add the functionality to the Common Lisp client.
Of course, someone needs to implement the completion functionality whether the "mode" is LSP, nvim-cmp source, or client feature.
— Reply to this email directly, view it on GitHub https://github.com/Olical/conjure/issues/466#issuecomment-1626422157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XPFHVYQ3OJSWBXYMVLXPC3YFANCNFSM6AAAAAAVF5QLPM . You are receiving this because you modified the open/close state.Message ID: @.***>
I just don't know what CL to execute to get completions...
On Sat, 8 Jul 2023, 10:19 Oliver Caldwell, @.***> wrote:
Hmm we already have a cmp source I think? And conjure clients have a hook for completions, each client needs to implement it though.
So if we implement that function in the CL client we just need to know which code to eval to complete a given string. This is all in conjure already and how Clojure does it.
On Sat, 8 Jul 2023, 02:46 Russ Tokuyama, @.***> wrote:
Alternatives to LSP:
- nvim-cmp-vlime https://github.com/HiPhish/nvim-cmp-vlime is an nvim-cmp completion source for Common Lisp via Vlime https://github.com/vlime/vlime (see List of sources https://github.com/hrsh7th/nvim-cmp/wiki/List-of-sources). Downside: duplicated REPLs and more set-up.
- Another project to build an nvim-cmp completion source plugin that would use the Conjure Common Lisp client's connection to a Common Lisp REPL running the Swank LISP code. Downside: a bit convoluted but, hopefully, less work than building an LSP server.
Having said that, if the future direction of Conjure stil includes completions https://github.com/Olical/conjure/wiki/Client-features#completions as a client feature, then it would be reasonable to add the functionality to the Common Lisp client.
Of course, someone needs to implement the completion functionality whether the "mode" is LSP, nvim-cmp source, or client feature.
— Reply to this email directly, view it on GitHub https://github.com/Olical/conjure/issues/466#issuecomment-1626422157, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XPFHVYQ3OJSWBXYMVLXPC3YFANCNFSM6AAAAAAVF5QLPM . You are receiving this because you modified the open/close state.Message ID: @.***>
Looking at the Slimv plugin, it appears that these should ask Swank (running in the Common Lisp REPL) for completions:
- Simple completions
'(swank:simple-completions "symbol" "package")'
- Fuzzy completions
'(swank:fuzzy-completions "symbol" "package" :limit 2000 :time-limit-in-msec 2000)'
Slimv uses a Python provider to talk to Swank. https://github.com/kovisoft/slimv
@LordMZTE, how do you have your Common Lisp set up with Swank? I haven't used Comon Lisp before and was going to try set up Conjure to talk to sbcl.
Oops! I just saw that there is a dev/common-lisp/README.adoc file. I'll read that.
Also https://github.com/Olical/conjure/wiki/Quick-start:-Common-Lisp-(Swank) if you prefer roswell.
@LordMZTE, how do you have your Common Lisp set up with Swank? I haven't used Comon Lisp before and was going to try set up Conjure to talk to sbcl.
I use cl-repl as a command-line REPL. I've set up a custom command to start swank, so I just have to open cl-repl and type %swank
to start a swank server. For the custom command, see my config.
Thanks @glyh and @LordMZTE !
I opened the dev/common-lisp/sandbox.lisp
file and evaluated the forms there to verify that Swank is working.
Then I tried evaluating some forms that I thought might coax Swank into replying with some suggested words for completions. The simple-completions
appear to work.
(swank:simple-completions "get" "")
; (("get" "get-decoded-time" "get-dispatch-macro-character"
; "get-internal-real-time" "get-internal-run-time" "get-macro-character"
; "get-output-stream-string" "get-properties" "get-setf-expansion"
; "get-universal-time" "getf" "gethash")
; "get")
(swank:simple-completions "flo" "")
; (("float" "float-digits" "float-precision" "float-radix" "float-sign"
; "floating-point-inexact" "floating-point-invalid-operation"
; "floating-point-overflow" "floating-point-underflow" "floatp" "floor")
; "flo")
But fuzzy-completions
doesn't work because there's no package loaded for it.
(swank:fuzzy-completions "flo" "" :limit 2000 :time-limit-in-msec 2000)
; The function SWANK:FUZZY-COMPLETIONS is undefined.
This should provide some starting point to flesh out a completions
function in the Common Lisp client (fnl/conjure/client/common-lisp/swank.fnl
). At least a simple one as mentioned in the Client features - Wiki.
@LordMZTE and @glyh, please try my PR and see if it helps.
This is now merged into develop
, thank you so much @russtoku 🎉