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

feature: Add syntax table config #32

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
19 changes: 16 additions & 3 deletions company-fuzzy.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@
:type 'list
:group 'company-fuzzy)

(defcustom company-fuzzy-syntax-alist
'((?. . "w")
(?: . "w")
(?@ . "w"))
"Modified syntax table temporarily for getting the correct prefix."
:type 'alist
:group 'company-fuzzy)

(defcustom company-fuzzy-completion-separator "[ \t\r\n]\\|\\_<\\|\\_>"
"Use to identify the completion unit."
:type 'string
Expand Down Expand Up @@ -653,9 +661,14 @@ Insert .* between each char."

(defun company-fuzzy--get-prefix ()
"Set the prefix just right before completion."
(setq company-fuzzy--is-trigger-prefix-p nil
company-fuzzy--prefix (or (ignore-errors (company-fuzzy--generic-prefix))
(ffap-guesser))))
(with-syntax-table (copy-syntax-table)
(dolist (entry company-fuzzy-syntax-alist)
(if (consp entry)
(modify-syntax-entry (car entry) (cdr entry))
(modify-syntax-entry entry "w")))
(setq company-fuzzy--is-trigger-prefix-p nil
company-fuzzy--prefix (or (ignore-errors (company-fuzzy--generic-prefix))
(ffap-guesser)))))

(defun company-fuzzy-all-other-backends (command &optional arg &rest ignored)
"Backend source for all other backend except this backend, COMMAND, ARG, IGNORED."
Expand Down