Well, company does work with dabbrev source…However it is really far from satisfying.
Considering the quality of Julia’s REPL, it is really a pity not to have a matching completion framework.
By the way, does Julia have completion back-end anyway?
I think it would be really nice to have a completion back-end that can be used by various completion front-end, so that we have a uniformed completion framework for atom, Emacs, Vim etc etc etc.
I would already be satisfied to have something that works only for emacs. In particular I would really like to bind the completion with tab. Unfortunately, to the best of my knowledge and after some negative empirical test, this does not seem to be doable.
Also, periodically I google emacs completion (\pm julia) and typically I don’t fill any wiser. The lsp-julia using LanguageServer.jl seems interesting. Looking forward the 0.7/1.0 compatibility.
However, my ideal solution would be to embed a (possibly minimal) version of autocompletion into julia-emacs.
I have thought about this when writing julia-repl, and we discussed this recently in an issue. If someone wants to take up the Julia side (having a background process running which one can query about the names in, say, Main of the actual inferior process), then I am happy to help with the Emacs part.
Tab completion in Emacs is doable, but a little bit tricky.
You may have a look at function completion-at-point-functions that might give you some clues.
I personally wrapped my own completion function as below.
(defun complete-or-indent ()
"Complete using company-mode or indent current line by checking "
;; When in region, indent the region.
(indent-region (region-beginning) (region-end)))
;; When yasnippet is active, move to next field.
;; When it is possible to complete, do it.
((and (string-match-p company-begin-regex (char-to-string (char-before)))
I bind it to <tab> key in company-mode. Since I am using company and yasnippet, you may modify the code accordingly…
The question is not about whether this is possible, or how to do it. Replicating SLIME or equivalent is a major undertaking, and as I say in the issue, this is not something I have time for at the moment.
Thank you @sheepduke. I tried your solution but I guess I have a deeper problem with company-mode. Indeed it seems that company mode does not understand. So my first question is how make company-mode understand julia.
For instance if I open a test.jl file and I try to complete
with M-x company-complete it tells me No completion found. If I tab (after the insertion of your lisp function in my .emacs file there is no reaction from emacs side.
Perhaps could you tell me how did you set up company-mode? BTW my Company version is 0.9.6 (from a `M-x company-version).
Thanks in advance!
I have been experimenting with Swank.jl (https://github.com/RobBlackwell/Swank.jl), a Julia back end for SLIME (the Superior Lisp Interaction Mode for Emacs). It has enough features to be usable(ish), but I’d welcome feedback from other Julia / Lisp / Emacs hackers please.
This is very impressive! Thanks for doing this. Being able to use Swank with Julia would be the best solution IMO, and I would be happy to abandon julia-repl in favor of this.
A couple of minor comments:
Please consider wrapping up the Emacs side of the code in a package and making it available on MELPA. It would be easier to get updates that way.
I suspect some extra code is needed to make the keybindings you list work, is that correct? Is there a minor mode I am missing?
The inability to parse function definition boundaries on the Emacs side has been a long standing issue, see https://github.com/JuliaEditorSupport/julia-emacs/issues/88. A solution would benefit all related packages, and unless SLIME somehow helps with this perhaps the best home for it would be julia-emacs.
I will be following this project with interest and hope to contribute. Again: awesome work!
Really interesting, I will have to try it out! Do I understand this right that this is meant as a minor mode to julia-mode and replaces julia-repl but can be used jointly with other minor modes such as lsp-mode?