Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: toggle completion caching whether number of candidates reaches limit #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions company-phpactor.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
(require 'company)
(require 'phpactor)

; this should have the same value as phpactor's completion.completor.class.limit value
; by default, phpactor sets this to 100
(defvar company-phpactor--completion-limit 100)
(defvar company-phpactor--ignore-cache nil)

(defun company-phpactor--grab-symbol ()
"If point is at the end of a symbol, return it.
Otherwise, if point is not inside a symbol, return an empty string.
Expand All @@ -54,6 +59,7 @@ Here we create a temporary syntax table in order to add $ to symbols."
(defun company-phpactor--get-candidates ()
"Build a list of candidates with text-properties extracted from phpactor's output."
(let ((suggestions (company-phpactor--get-suggestions)) candidate)
(setq company-phpactor--ignore-cache (= (length suggestions) company-phpactor--completion-limit))
(mapcar
(lambda (suggestion)
(setq candidate (plist-get suggestion :name))
Expand All @@ -80,6 +86,7 @@ Here we create a temporary syntax table in order to add $ to symbols."
(save-restriction
(widen)
(cl-case command
(no-cache company-phpactor--ignore-cache)
(post-completion (company-phpactor--post-completion arg))
(annotation (company-phpactor--annotation arg))
(interactive (company-begin-backend 'company-phpactor))
Expand Down