skeeto / skewer-mode

Live web development in Emacs
The Unlicense
1.09k stars 57 forks source link

Simple autocompletion for the REPL (fixes #59) #76

Closed TatriX closed 7 years ago

skeeto commented 7 years ago

Thanks for giving this a shot. There are two minor things still needed: (require 'company) and adding company (0.9.2?) as a new dependency in skewer-mode-pkg.el.

But more importantly, how do I use this? I've never used company-mode before. I fired up the REPL, enabled company-mode, and can't really get it to do anything. I can tell roughly what it's doing — figuring out the name of the object to query and fetching its properties — but I don't know how that connects to company-mode.

TatriX commented 7 years ago

Usually company mode will run a completion after a short delay if there are more then company-minimum-prefix-length characters in the prefix.

(add-hook 'after-init-hook 'global-company-mode)
(global-set-key (kbd "C-M-i") 'company-complete)

2017-01-21-202516_384x451_scrot

TatriX commented 7 years ago

I believe users don't need company mode to use the skewer-mode. When buffer enters the skewer-repl-mode it just sets local variable:

(setq-local company-backends '(company-skewer-repl))

So if user has company mode installed it completion should work out of the box. If no company mode available nothing happens.

skeeto commented 7 years ago

Opportunistic use of company-mode is perfect! I've merged with additional changes.

(skewer-eval-synchronously "document.location"
                           :type "completions"
                           :extra '((regexp . "^h")))

;; => ((value . ["href" "host" "hostname" "hash"])
;;     (status . "success")
;;     (type . "completions")
;;     (id . "24219a5f06cbc5c"))
TatriX commented 7 years ago

Awesome, thank you!