Turn off all backends except snippets in Tab stop fields #1377
-
Hello, when doing a completion I only want my snippets coming up. How do I disable other backends Setting it with I tried this in my snippet: # -*- mode: snippet -*-
# name: sub
# key: sub
# type: command
# --
(let ((company-backends '((:separate company-yasnippet ))))
(yas-expand-snippet "${1:Enter Subheading$$(when (and yas-modified-p yas-moving-away-p )(my/s-center yas-text :len \"large\" :beg \"[\" :end \"]\" ))}")) Here is my company setup if needed: (setq company-tooltip-align-annotations t ; aligns annotation to the right
company-tooltip-limit 12 ; bigger popup window
company-idle-delay 0 ; decrease delay before autocompletion popup shows
company-echo-delay (if (display-graphic-p) nil 0)
company-minimum-prefix-length 2
company-require-match nil
company-dabbrev-ignore-case nil
company-dabbrev-downcase nil
company-dabbrev-minimum-length 10 ; Use buffer completion at 10 charcters.
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))
;; This puts snippet completion first.
company-backends '((:separate company-yasnippet company-files company-bbdb company-semantic company-cmake company-capf company-clang
company-dabbrev-code company-gtags company-keywords
company-oddmuse company-dabbrev))) I noticed that one suggestion is Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Using let-binding as in your example doesn't work because To exclude all completions except yasnippet's, you could set To do this alteration temporarily you could use yasnippet's hooks, such as I'm not quite sure why you would limit completion to snippets (I would rarely invoke snippet expansion inside another snippet), but the above is how you could do it. |
Beta Was this translation helpful? Give feedback.
-
Thanks, that worked. Here is the code. (add-hook 'yas-before-expand-snippet-hook (lambda () (setq-local company-backends '(company-yasnippet))))
(add-hook 'yas-after-exit-snippet-hook (lambda () (kill-local-variable 'company-backends)))
Because I'm trying to type something in the tab stop fields like
The reason for that is because I have snippets that create different sizes of a comment box. The snippets |
Beta Was this translation helpful? Give feedback.
-
The suggestions would be useful if I was writing function that took those keys like most The problem was I had Thanks |
Beta Was this translation helpful? Give feedback.
-
@dgutov I have a similar issue. I'm trying to setup react on Emacs but the problem is I have to (setq evil-want-C-d-scroll nil) ; rjsx-mode-map
(use-package rjsx-mode
:straight t
:config
(evil-define-key 'insert rjsx-mode-map (kbd "C-d") #'(lambda ()(interactive)
(let ((company-backends '((:separate company-yasnippet ))))
(call-interactively 'rjsx-delete-creates-full-tag)
)))
:mode ("\\.js\\'" . rjsx-mode)) Thanks in advance. In this video:
company-mode-react.mov |
Beta Was this translation helpful? Give feedback.
Using let-binding as in your example doesn't work because
yas-expand-snippet
exits right after it inserts the template with all the necessary structures into the buffer, so that snippet expansion works, but before you're able continue typing, initiate completion, etc.To exclude all completions except yasnippet's, you could set
company-backends
to'(company-yasnippet)
(a simpler value than in your example, though yours should also work). Maybe do it buffer-locally (seesetq-local
), to avoid affecting other buffers. Depending on whether the value is buffer-local already, you could back up the previous value to some new var, to be able to restore it later.To do this alteration temporarily …