gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
236 stars 23 forks source link

better company support #47

Closed untoreh closed 3 years ago

untoreh commented 3 years ago

I modified the comp functions to support documentation like this

(defun julia-snail-company-doc-buffer (str)
  (let* ((module (julia-snail--module-at-point))
         (name (s-concat (s-join "." module) "." str))
         (doc (julia-snail--send-to-server
                :Main
                (format "@doc %s" name)
                :display-error-buffer-on-failure? nil
                :async nil)))
    (let ((buf (julia-snail--message-buffer
                julia-snail-repl-buffer
                "doc-buffer"
                (if (eq :nothing doc)
                    "Documentation not found!\nDouble-check your package activation and imports."
                  doc)
                :markdown nil)))
      (with-current-buffer buf
        (font-lock-ensure))
      buf)))

(defun julia-snail-company-capf ()
  (interactive)
  (let* ((comp (julia-snail-repl-completion-at-point))
         (doc (list :company-doc-buffer
                    #'julia-snail-company-doc-buffer)))
    (concatenate 'list comp doc)))

I tried to add :annotation-function (with like methods(%s).ms[1].sig) but I always get :nothing from the server, it only returns the result for @doc calls

Although adding annotation like this (and checking for icons too) is very slow since it is doing lots of queries..

gcv commented 3 years ago

Even if it's slow, (1) it might be a good thing to allow users to turn on as an option, (2) Snail can aggressively cache the docstrings.

I have never customized company-mode beyond enabling it for basic capf. How do I enable this to try it out?

untoreh commented 3 years ago

replace julia-snail-repl-completion-at-point with julia-snail-company-capf in completion-at-point-functions

gcv commented 3 years ago

Commit 563be34 shouldn't have referenced this ticket.

gcv commented 3 years ago

@untoreh: Sorry it took me so long to try out your suggestion. It's now enabled in bebeb7f and should automatically turn on if you have company-mode loaded before Snail. In my testing, it works pretty well with company-quickhelp. Thanks!!