-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Report special case for company backend #12
Comments
@jcs090218 Can't get candidates with |
@TrunovS Hi! I have tested |
@jcs090218 Found the culprit! When variable (defun company-c-headers--candidates (prefix)
"Return candidates for PREFIX."
(let ((p (if (equal (aref prefix 0) ?\")
(call-if-function company-c-headers-path-user)
(call-if-function company-c-headers-path-system)))
(next (when (equal (aref prefix 0) ?\")
(call-if-function company-c-headers-path-system)))
candidates)
(while p
(when (file-directory-p (car p))
(setq candidates (append candidates (company-c-headers--candidates-for prefix (car p)))))
(setq p (or (cdr p)
(let ((tmp next))
(setq next nil)
tmp)))
)
(cl-remove-duplicates candidates :test 'equal)
))
In system include directories everything works fine.) |
Okay, there are many problems here. company-c-headers don't return list of candidates without the correct prefix, which are |
current package-version - emacs-version - 27.1 company-version - Update : Can confirm that it is working until this commit - 2f70e6f
|
You sure about this? It works on my side. 😕 The newest version of (setq company-backends
(append
;; --- Internal ---
'(company-capf company-semantic)
'(company-abbrev company-dabbrev company-dabbrev-code)
'(company-files)
'(company-etags company-gtags)
'(company-keywords company-yasnippet)
;; --- External ---
'(company-emoji))) The only issue I figured it out is that (setq company-backends
(append
;; --- Internal ---
'(company-capf company-semantic)
'(company-keywords) ; Put infront of `company-dabbrev'
'(company-abbrev company-dabbrev company-dabbrev-code)
'(company-files)
'(company-etags company-gtags)
'(company-yasnippet)
;; --- External ---
'(company-emoji))) Does |
Yes I just tested it with Here is my company configuration - (use-package company
:diminish
:defines (company-dabbrev-ignore-case company-dabbrev-downcase)
:commands (company-cancel
company-complete-common)
:bind (("M-s-÷" . company-complete);;my-personal-config
("C-M-i" . company-complete)
("M-s-ƒ" . company-files)
("M-s-i" . company-complete);;my-personal-config
("M-s-k" . company-keywords)
("M-s-p" . company-dabbrev)
("M-s-f" . company-files)
:map company-mode-map
("<backtab>" . company-yasnippet)
:map company-active-map
("C-p" . company-select-previous)
("C-n" . company-select-next)
("<tab>" . company-complete-common-or-cycle)
("<backtab>" . my-company-yasnippet)
:map company-search-map
("C-p" . company-select-previous)
("C-n" . company-select-next))
:hook (after-init . global-company-mode)
:init
(setq company-tooltip-align-annotations t
company-tooltip-limit 12
company-idle-delay 0
company-echo-delay (if (display-graphic-p) nil 0)
company-minimum-prefix-length 1
company-show-numbers 'left ;;my-personal-config
company-require-match nil
company-dabbrev-code-everywhere t
company-dabbrev-code-modes t
company-dabbrev-other-buffers 'all
company-dabbrev-code-other-buffers 'all
company-dabbrev-ignore-case t
company-dabbrev-char-regexp "\\(\\sw\\|\\s_\\|_\\|-\\)"
company-dabbrev-downcase nil
;; company backend is my-personal-config
;; company-backends '(company-capf
;; (company-dabbrev-code company-gtags company-etags
;; company-keywords)
;; company-files
;; company-dabbrev)
;; company backend is my-personal-config
company-global-modes '(not erc-mode message-mode help-mode
gud-mode eshell-mode shell-mode)
company-backends '((company-capf :with company-yasnippet)
(company-dabbrev-code company-keywords company-files)
company-dabbrev))
(defun my-company-yasnippet ()
"Hide the current completeions and show snippets."
(interactive)
(company-cancel)
(call-interactively 'company-yasnippet))
:config
;; `yasnippet' integration
(with-no-warnings
(with-eval-after-load 'yasnippet
(defun company-backend-with-yas (backend)
"Add `yasnippet' to company backend."
(if (and (listp backend) (member 'company-yasnippet backend))
backend
(append (if (consp backend) backend (list backend))
'(:with company-yasnippet))))
(defun my-company-enbale-yas (&rest _)
"Enable `yasnippet' in `company'."
(setq company-backends (mapcar #'company-backend-with-yas company-backends)))
(defun my-lsp-fix-company-capf ()
"Remove redundant `comapny-capf'."
(setq company-backends
(remove 'company-backends (remq 'company-capf company-backends))))
(advice-add #'lsp-completion--enable :after #'my-lsp-fix-company-capf)
(defun my-company-yasnippet-disable-inline (fun command &optional arg &rest _ignore)
"Enable yasnippet but disable it inline."
(if (eq command 'prefix)
(when-let ((prefix (funcall fun 'prefix)))
(unless (memq (char-before (- (point) (length prefix)))
'(?. ?< ?> ?\( ?\) ?\[ ?{ ?} ?\" ?' ?`))
prefix))
(progn
(when (and (bound-and-true-p lsp-mode)
arg (not (get-text-property 0 'yas-annotation-patch arg)))
(let* ((name (get-text-property 0 'yas-annotation arg))
(snip (format "%s (Snippet)" name))
(len (length arg)))
(put-text-property 0 len 'yas-annotation snip arg)
(put-text-property 0 len 'yas-annotation-patch t arg)))
(funcall fun command arg))))
(advice-add #'company-yasnippet :around #'my-company-yasnippet-disable-inline)))
;; remove completion on numbers
;; https://emacs.stackexchange.com/questions/9835/how-can-i-prevent-company-mode-completing-numbers
;; https://emacs.stackexchange.com/questions/35345/how-to-turn-off-autocompletion-for-numbers-and-numbers-only-in-company-mode-in
;; https://github.com/company-mode/company-mode/issues/358
(push (apply-partially #'cl-remove-if
(lambda (c)
(or (string-match-p "[^\x00-\x7F]+" c)
(string-match-p "[0-9]+" c)
(string-match-p "\\`[0-9]+\\'" c)
;;(if (equal major-mode "org")
;; (>= (length c) 15))
)))
company-transformers)
;; my-personal - remove competion on numbers - end
;; Better sorting and filtering
(use-package company-prescient
:init (company-prescient-mode 1))
;; Icons and quickhelp
(when emacs/>=26p
(use-package company-box
:diminish
:defines company-box-icons-all-the-icons
:hook (company-mode . company-box-mode)
:init (setq company-box-enable-icon centaur-icon
company-box-backends-colors nil
company-box-doc-delay 0.3
company-box-highlight-prefix t
)
:config
(with-no-warnings
;; Prettify icons
(defun my-company-box-icons--elisp (candidate)
(when (or (derived-mode-p 'emacs-lisp-mode) (derived-mode-p 'lisp-mode))
(let ((sym (intern candidate)))
(cond ((fboundp sym) 'Function)
((featurep sym) 'Module)
((facep sym) 'Color)
((boundp sym) 'Variable)
((symbolp sym) 'Text)
(t . nil)))))
(advice-add #'company-box-icons--elisp :override #'my-company-box-icons--elisp))
(when (icons-displayable-p)
(declare-function all-the-icons-faicon 'all-the-icons)
(declare-function all-the-icons-material 'all-the-icons)
(declare-function all-the-icons-octicon 'all-the-icons)
(setq company-box-icons-all-the-icons
`((Unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :v-adjust -0.15))
(Text . ,(all-the-icons-faicon "text-width" :height 0.8 :v-adjust -0.02))
(Method . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(Function . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(Constructor . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(Field . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
(Variable . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
(Class . ,(all-the-icons-material "settings_input_component" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
(Interface . ,(all-the-icons-material "share" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(Module . ,(all-the-icons-material "view_module" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(Property . ,(all-the-icons-faicon "wrench" :height 0.8 :v-adjust -0.02))
(Unit . ,(all-the-icons-material "settings_system_daydream" :height 0.8 :v-adjust -0.15))
(Value . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(Enum . ,(all-the-icons-material "storage" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
(Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.8 :v-adjust -0.15))
(Snippet . ,(all-the-icons-material "format_align_center" :height 0.8 :v-adjust -0.15))
(Color . ,(all-the-icons-material "palette" :height 0.8 :v-adjust -0.15))
(File . ,(all-the-icons-faicon "file-o" :height 0.8 :v-adjust -0.02))
(Reference . ,(all-the-icons-material "collections_bookmark" :height 0.8 :v-adjust -0.15))
(Folder . ,(all-the-icons-faicon "folder-open" :height 0.8 :v-adjust -0.02))
(EnumMember . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15))
(Constant . ,(all-the-icons-faicon "square-o" :height 0.8 :v-adjust -0.1))
(Struct . ,(all-the-icons-material "settings_input_component" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
(Event . ,(all-the-icons-octicon "zap" :height 0.8 :v-adjust 0 :face 'all-the-icons-orange))
(Operator . ,(all-the-icons-material "control_point" :height 0.8 :v-adjust -0.15))
(TypeParameter . ,(all-the-icons-faicon "arrows" :height 0.8 :v-adjust -0.02))
(Template . ,(all-the-icons-material "format_align_left" :height 0.8 :v-adjust -0.15)))
company-box-icons-alist 'company-box-icons-all-the-icons))))
;; Popup documentation for completion candidates
(when (and (not emacs/>=26p) (display-graphic-p))
(use-package company-quickhelp
:defines company-quickhelp-delay
:bind (:map company-active-map
([remap company-show-doc-buffer] . company-quickhelp-manual-begin))
:hook (global-company-mode . company-quickhelp-mode)
:init (setq company-quickhelp-delay 0.5)))) |
Hmm... Since this isn't issue about handling company backend in the different way. Can you open in another issue and so we can discuss over there? Thanks! |
The
This might be a constraint of |
This issue may no longer be useful since this package should able to handle ALL backends after version Except some special backends. e.g. |
This thread is a special thread to let other users to report the company backends that isn't working properly with this package. Please report any company backend that isn't working properly with this package.
These backends are special backends that have to implemented individually.
🔍 Backends must take it's own prefix
(company-files 'prefix)
to get the correct prefix.🔍 Backends parse prefix with no strong connection between
candidates
andprefix
commandsargs
wouldn't work all the time. (Resolved, see below)🔍 Unresolved (not working)
Here is list of confirmed normal cases. That said, you don't have to do any special implementation to these backends. And do NOT add it to
company-fuzzy-history-backends
list.🔍 Normal (working properly)
1.4.1
.1.3.0
.company-yasnippet--completions-for-prefix
function, we fix this by adding the advice around it, see fix(history): Fix long lasting company-yasnippet bug #30.async
backends after1.3.0
.The text was updated successfully, but these errors were encountered: