ninjudd / clojure-complete Goto Github PK
View Code? Open in Web Editor NEWStandalone Clojure completion library adapted from swank-clojure.
License: Eclipse Public License 1.0
Standalone Clojure completion library adapted from swank-clojure.
License: Eclipse Public License 1.0
Consider the following command:
=> (pprint (completions "clojure.core"))
nil
("clojure.core"
"clojure.core.ArrayChunk"
"clojure.core.ArrayManager"
"clojure.core.IVecImpl"
"clojure.core.Vec"
"clojure.core.VecNode"
"clojure.core.VecSeq"
"clojure.core.protocols"
"clojure.core.protocols.InternalReduce")
first is a namespace, then some classes, then a namespace, then some classes
What do you think about having things sorted first by "kind", then by alphabetical name ?
kinds could be sorted as is: first namespaces then vars then classes then instance members then static members
e.g. having this behaviour instead:
=> (pprint (completions "clojure.core"))
nil
("clojure.core"
"clojure.core.protocols"
"clojure.core.ArrayChunk"
"clojure.core.ArrayManager"
"clojure.core.IVecImpl"
"clojure.core.Vec"
"clojure.core.VecNode"
"clojure.core.VecSeq"
"clojure.core.protocols.InternalReduce")
A feature I'd like to have in Counterclockwise is "Textmate-completion" style.
e.g. asking completion for "sbc" would match "set-bundle-classloader!" var.
@trptcolin what do you think of moving this repo to the flatland organization since I'm not really the primary contributor anymore?
Hello,
I don't know where else to start discussing this, so why not the bug tracker?
In a nutshell: I'm considering dropping the current "legacy" code used by Counterclockwise (the Eclipse plugin for Clojure) in favor of a shared external library like clojure-complete.
So in order to evaluate the feasibility, here are some questions:
To serve the purpose of several kinds of "displays" (console, editors, etc.), it would be interesting to not drop "too early" information on the results. E.G. once a var, a Class, a MethodHandler have been "rendered"/"reified" to a String, it's too late for easily sorting/displaying/further filtering the result in different ways.
Maybe we could have first the non-reified results returned, and construct above this (respecting the current "API" to not break existing client code) a default textual rendering layer.
For example, for Counterclockwise's purpose, I may enrich the "bare list" with more information such as repeating the namespace the var was aliased/used from, the type of the completion (:var, :namespace, :class, :static-member, :instance-member, etc.), the arglist, the documentation, etc.
Are you able to cut a new release of this to include #20?
There should be a function that performs a "deep complete" inside namespaces. For example, f I complete clojure.co
, it should show me clojure.core
, as well as everything under that namespace: clojure.core/seq
, clojure.core/vals
, ...
The big advantage of having such a function is that it allows Emacs to do partial completions in all cases. Right now, if I complete l-s
using the partial completion style, lazy-seq
will be an option. This is because Emacs will first complete l
, and do the rest of the matching itself, as lazy-seq
will be one of the matches. But if I try to complete clojure.core/l-s
, partial completion will fail, as it will first try to complete clojure.core
. Since this will return no additional completions, Emacs will erroneously say it can't complete clojure.core/l-s
.
One work around for the preceding example is to add a new completion style that checks for a namespace and triggers completion for clojure.core/l
. I'm doing this as a workaround for now, but the big disadvantage of such an approach is that I can't complete partially specified namespaces such as c.c/l-s
.
It's simple enough to do a deep complete, but I won't submit a patch as I don't know what angle you all would like to take. I could see this being computationally intensive, so maybe there is a smarter solution that clojure-complete and Emacs (and maybe repl-y?) could meet halfway on.
(Also crossref'ing #5 as similar, although I find it a bit funny that the completion style in question is being called "textmate-style" :-))
Everything's in the title.
Before adding new features, I'd be happy adding more tests to the test suite :
We could get inspiration from Enclojure's great documentation website for the coverage of the tests.
Bit of an oddly specific bug, I know.
TL;DR - if I type clojure.co
and then try to tab-complete, an NPE is triggered. Tab-completion works fine if I hit tab at cloj
or at clojure.core/
, but after that first period and before the slash I'll get NPE'd. I ran into this on a project and then was able to reproduce outside of a project context.
Now the expected behavior would be for tab completion to work the way it did when I hit tab at cloj
, i.e. to show me the list of namespaces that are potential results for what I've typed so far.
Full command history and stacktrace:
▸ lein repl
nREPL server started on port 55883 on host 127.0.0.1 - nrepl://127.0.0.1:55883
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 9.0.1+11
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> clojure.corNullPointerException complete.core/fn--632/iter--624--633/fn--634 (core.clj:66)
CompilerException java.lang.ClassNotFoundException: clojure.cor, compiling:(null:0:0)
user=> (pst)
clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: clojure.cor, compiling:(null:0:0)
Compiler.java:6688 clojure.lang.Compiler.analyze
Compiler.java:6625 clojure.lang.Compiler.analyze
Compiler.java:6931 clojure.lang.Compiler.eval
Compiler.java:6890 clojure.lang.Compiler.eval
core.clj:3105 clojure.core/eval
core.clj:3101 clojure.core/eval
main.clj:240 clojure.main/repl[fn]
main.clj:240 clojure.main/repl[fn]
main.clj:258 clojure.main/repl[fn]
main.clj:258 clojure.main/repl
main.clj:174 clojure.main/repl
RestFn.java:1523 clojure.lang.RestFn.invoke
interruptible_eval.clj:87 clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
AFn.java:152 clojure.lang.AFn.applyToHelper
AFn.java:144 clojure.lang.AFn.applyTo
core.clj:646 clojure.core/apply
core.clj:1881 clojure.core/with-bindings*
core.clj:1881 clojure.core/with-bindings*
RestFn.java:425 clojure.lang.RestFn.invoke
interruptible_eval.clj:85 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:55 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:224 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
interruptible_eval.clj:192 clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
AFn.java:22 clojure.lang.AFn.run
ThreadPoolExecutor.java:1167 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:641 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:844 java.lang.Thread.run
Caused by: java.lang.ClassNotFoundException: clojure.cor
URLClassLoader.java:466 java.net.URLClassLoader.findClass
DynamicClassLoader.java:69 clojure.lang.DynamicClassLoader.findClass
ClassLoader.java:563 java.lang.ClassLoader.loadClass
DynamicClassLoader.java:77 clojure.lang.DynamicClassLoader.loadClass
ClassLoader.java:496 java.lang.ClassLoader.loadClass
(Unknown Source) java.lang.Class.forName0
Class.java:375 java.lang.Class.forName
RT.java:2168 clojure.lang.RT.classForName
RT.java:2177 clojure.lang.RT.classForName
Compiler.java:7145 clojure.lang.Compiler.resolveIn
Compiler.java:7108 clojure.lang.Compiler.resolve
Compiler.java:7069 clojure.lang.Compiler.analyzeSymbol
Compiler.java:6648 clojure.lang.Compiler.analyze
nil
Originally reported as a Leiningen issue here: technomancy/leiningen#2380
It is possible that a user has 'used (or 'aliased) in the current namespace another namespace, but is triggering completion with the fully qualified namespace (maybe he doesn't remember the namespace has been 'used or 'aliased, maybe he wants to "filter" the search to this particular namespace).
In that case, instead of suggesting the var's symbol as provided by the user, we could/should (?) suggest the bare symbol (resp. aliased symbol) :
example:
(ns 'user)
(require 'clojure.set)
(completions "clojure.set/un")
; => ( "clojure.set/union")
(require '[clojure.set :as set])
(completions "clojure.set/un")
; => ("set/union")
(use '[clojure.set :only [union]])
(completions "clojure.set/un")
; => ("union")
(completions "set/un")
; => ("union")
I have modified the code to auto-complete a partial classname,
without needing the package name (makes it very easy to
find/enter class when you forget the package name or even the
exact class name). I found it useful in my personal work, so
thought could help others too.
It behaves as below:
user> (complete.core/completions "JFr")
("javax.swing.JFrame")
user> (complete.core/completions "Rob")
("java.awt.Robot" "java.awt.peer.RobotPeer")
Wildcard '*' is supported and can be used as below:
user> (complete.core/completions "Win*Ad")
("java.awt.event.WindowAdapter")
user> (complete.core/completions "Mou*Li")
("java.awt.event.MouseListener" "java.awt.event.MouseMotionListener"
"java.awt.event.MouseWheelListener" "javax.swing.event.MouseInputListener")
user> (complete.core/completions "Mou*In*L")
("javax.swing.event.MouseInputListener")
Uploaded patch here: https://gist.github.com/3117608
Changes:
potential-completions
when there is a capitalstartsWith
, use regular expression match to supportre-match
).Let me know what you guys think about it.
Thank you
a feature Counterclockwise had is completion for java interop calls.
e.g. ".toSr" would get suggestions for ".toString", etc.
There are several things to discuss about the detail.
Side note: question about function ns-java-methods: I see ":when (static? ..." where I would have expected ":when (not (static? ..."
compliment provides more features than clojure-complete
and is actively maintained. As this project seems dormant I guess it makes sense to formally deprecated it in favour of compliment
.
Hello there,
Completions such as clojure.core$unchecked_remainder_int
or the more extreme ring.adapter.jetty/ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0
can be pretty noisy both in terms of number and length, especially when leveraging popup-based completions such as ac-nrepl.
Can these be disabled? If that was the case, a nice config mechanism surely would be providing a key at one's project.clj.
Thanks - Victor
This library is a dependency for leiningen itself and it would
be really great if the published version in clojars (0.2.3)
had a matching tag here. Would you please tag the repo with 0.2.3?
Thanks!
So in ubuntu xenial, using openjdk 9, it seems like java.ext.dirs isn't present. This may be due to a change in the structure of how java is distributed/runs according to http://openjdk.java.net/jeps/220. In any case, the behaviour I'm getting when trying to use repl completion is this:
https://gist.github.com/pcn/6272f116e6884728a66a
It was suggested in IRC that this is the root of the problem:
clojure-complete/src/complete/core.clj
Line 66 in 09827b3
I'm not sure what an appropriate fix would be, but I'm reporting this in the hope that it helps.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.