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!