Open Pitometsu opened 7 years ago
UPD: in case of
import Foundation
var ⬛
Where ⬛ is point,
it show all the completions for yasnippet. But. Without var
it do nothing.
Hmm what's the output of M-x describe-variable <RET> company-backends <RET>
?
company-backends is a variable defined in ‘company.el’. Its value is shown below.
This variable is safe as a file local variable if its value satisfies the predicate ‘company-safe-backends-p’.
Documentation: TL;TD
Value:
(company-sourcekit company-files company-keywords company-capf company-yasnippet company-abbrev company-dabbrev company-dabbrev-code)
Original value was
(company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files (company-dabbrev-code company-gtags company-etags company-keywords) company-oddmuse company-dabbrev)
Local in buffer
the-buffer-name.swift
; global value is(company-files company-keywords company-capf company-yasnippet company-abbrev company-dabbrev company-dabbrev-code)
-U:%%- *Help* Top (1,0) (Help) ---------------------------------------------------------
@Pitometsu try putting company-sourcekit
at the end of that list :) In general most source-specific completers will work better at the tail of the stack
@nathankot, thank you for explanation, it works now!
@nathankot one more question here:
This solution works with yasnippet
backend. So, when it have to snippets to complete, sourcekit
backend will start as fallback.
But when I add also company-keywoards
or company-dabbrew-code
, they are usually have too much completions and will newer loose. So sourcekit
will never start.
On the other hand, if I put sourcekit
before, it will never release completion for other backends.
You see, where is the problem? If there's even no candidates, sourcekit
do not let company-completion
fallback to other backens. If previous backends have too much variants, it even don't start to make requests.
My current configuration:
(setq company-echo-delay 0)
(setq company-backends
'((company-yasnippet
company-etags
company-keywords
company-capf
company-dabbrev-code
company-files
company-abbrev
company-dabbrev)))
(defun company-sourcekit-init ()
"Enable sourcekit backend for company."
(eval-after-load 'company
'(add-to-list
; vvvvv
; if uncomment, it will not even start
;; (last (make-local-variable 'company-backends))
; now it mute other backends even if have no variants
(make-local-variable 'company-backends)
; ^^^^^
'company-sourcekit t))
(eval-after-load 'company-keywords
'(add-to-list 'company-keywords-alist
'(swift-mode "true" "false" "nil" "available" "column" "elseif" "else" "endif" "file" "function" "if" "line" "selector" "associatedtype" "class" "deinit" "enum" "extension" "fileprivate" "func" "import" "init" "inout" "internal" "let" "open" "operator" "private" "protocol" "public" "static" "struct" "subscript" "typealias" "var" "break" "case" "continue" "default" "defer" "do" "else" "fallthrough" "for" "guard" "if" "in" "repeat" "return" "switch" "where" "while" "as" "catch" "dynamicType" "is" "rethrows" "super" "self" "Self" "throws" "throw" "try" "Protocol" "Type" "and" "assignment" "associativity" "convenience" "didSet" "dynamic" "final" "get" "higherThan" "indirect" "infix" "lazy" "left" "lowerThan" "mutating" "none" "nonmutating" "optional" "override" "postfix" "precedence" "precedencegroup" "prefix" "required" "right" "set" "unowned" "weak" "willSet"))))
(add-hook 'swift-mode-hook 'company-sourcekit-init)
I have
and
so,
company-sourcekit
mostly works for now. Butcompany-yasnippet
work only when I manually callM-x company-yasnippet
. Generalcompany-complete
or show sourcekit variants only, or do just nothing at all.