This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-06
Channels
- # announcements (3)
- # babashka (1)
- # beginners (26)
- # calva (1)
- # cider (17)
- # clj-commons (16)
- # clj-kondo (11)
- # clojure (21)
- # clojure-europe (9)
- # clojure-norway (1)
- # clojure-portugal (2)
- # clojure-spec (8)
- # clojure-uk (4)
- # clojurescript (35)
- # datomic (5)
- # emacs (9)
- # figwheel-main (15)
- # fulcro (26)
- # honeysql (1)
- # lsp (5)
- # off-topic (2)
- # polylith (1)
- # rdf (6)
- # re-frame (4)
- # reagent (15)
- # reitit (9)
- # releases (2)
- # shadow-cljs (4)
- # sql (25)
- # squint (2)
- # xtdb (7)
I followed the instructions to get fuzzy candidate matching in cider here https://docs.cider.mx/cider/usage/code_completion.html#fuzzy-candidate-matching here is the variable
cider-repl-mode-hook is a variable defined in 'cider-repl.el'.
Its value is
(cider-company-enable-fuzzy-completion spacemacs/toggle-evil-safe-lisp-structural-editing-on spacemacs//activate-smartparens eldoc-mode spacemacs//init-company-cider-repl-mode company-mode)
But i don't get fuzzy matching. (see picture) What should i try next?complete does seem to have the fuzzy matches
(cider.nrepl.middleware.complete/complete {:ns 'core
;; grab all functions starting by c:
:prefix "mi"})
;; => ({:candidate "min", :type :function, :ns "clojure.core"}
;; {:candidate "min-key", :type :function, :ns "clojure.core"}
;; {:candidate "map-indexed", :type :function, :ns "clojure.core"}
;; {:candidate "mix-collection-hash", :type :function, :ns "clojure.core"})
this is going to be because lsp is doing the completion or something. I remember this being annoying like a year ago.
same...
ELISP> (cider-sync-request:complete "mi" (cider-completion-get-context) )
((dict "candidate" "min" "ns" "clojure.core" "type" "function")
(dict "candidate" "min-key" "ns" "clojure.core" "type" "function")
(dict "candidate" "map-indexed" "ns" "clojure.core" "type" "function")
(dict "candidate" "mix-collection-hash" "ns" "clojure.core" "type" "function"))
Only slightly related, i also tried to follow the instructions here to change my https://nrepl.org/nrepl/usage/misc.html#code-completion
You can either specify a custom completion function in the requests (via the complete-fn key) or by setting nrepl.middleware.completion/*complete-fn*.
user=> (set! nrepl.middleware.completion/*complete-fn* my.namespace/my-completion)
And it threw an exception when i called set! (see picture ty š )cider version 1.5.0.
generally only a few dyn vars (those bundled with a clojure repl) can be freely set!-table
you need to use binding
instead
@U45T93RA6 i'm starting to think that nrepl doesn't use the compliment library directly sense version 0.8. I traced nrepl.middleware.completion/complete-fn to This
(ns nrepl.util.completion
"Code completion functionality.
The functionality here is experimental and
the API is subject to changes."
{:author "Bozhidar Batsov"
:added "0.8"}
(:require [clojure.main]
[nrepl.misc :as misc])
(:import [java.util.jar JarFile]
[ File]
[java.lang.reflect Field Member]
[java.util.jar JarEntry]
[java.util.concurrent ConcurrentHashMap]))
;; Code adapted from Compliment ()
and I'm going to be reading this post from 2020 about completion changes.
Just sharing with you in case it's news to you as well.
https://metaredux.com/posts/2020/06/15/nrepl-0-8-evolving-the-protocol.htmlyou are assessing nrepl, while you should be assessing cider-nrepl
for what concerns us here, nrepl.util.completion
powers completions in e.g. lein repl
completions, but is otherwise irrelevant to cider's machinery
in the end nrepl can be thought of simply as a pipe - https://github.com/clojure-emacs/cider-nrepl has most if not all of the features you get to use in CIDER
By lein repl, were talking about the repl started at the command line by lein?
@drewverlee Iād suggest filing a couple of tickets, so we can properly follow up on both issues.
How do i ask emacs to tell me what's doing the completion? I suspect this might not even be a cider issue. This has been nagging me for years and i can't seem to figure it out, in part because i don't know how to get good diagnostic info to share with anyone. :(
i think the completion-styles-alist might be what lists all the completion functions (the name is misleading if so)
fwiw, i more or less did https://github.com/clojure-emacs/cider-nrepl/issues/732 a year ago, and though the context (shadow-cljs) was slightly different, i don't think those differences matter much here, and I think my confusion and the reason completion doesn't work as expected in multiple areas is probably the same. fwiw trying the completion across two emacs profiles. Spacemacs and a nearly fresh install of Doom. but sure ill open another ticket in the morning š .