Add manual semantic completion function for company to ycmd layer

This commit is contained in:
Nir Friedman 2017-11-05 09:55:32 -05:00 committed by syl20bnr
parent 2ce1e367c0
commit f3dbeec5dc
2 changed files with 22 additions and 9 deletions

View File

@ -89,13 +89,13 @@ with almost any build system.
* Functions
If ~company-ycmd~ is used, then a function
~spacemacs/company-ycmd-manual-semantic-complete~ is defined. This function is
~ycmd/manual-semantic-company-completer~ is defined. This function is
useful if you want to get semantic completions only when you press a
keybinding; in larger projects ycmd may not be performant for as-you-type
auto-completion to work well. You can bind it like so:
#+BEGIN_SRC emacs-lisp
(global-set-key (kbd "<C-tab>") 'spacemacs/company-ycmd-manual-semantic-complete)
(global-set-key (kbd "<C-tab>") 'ycmd/manual-semantic-company-completer)
#+END_SRC
This function will automatically cancel out of any active completers, and offer

View File

@ -1,7 +1,20 @@
(when (configuration-layer/package-usedp 'company-ycmd)
(defun spacemacs/company-ycmd-manual-semantic-complete ()
(interactive)
(company-cancel)
(let ((ycmd-force-semantic-completion (not (company-ycmd--in-include))))
(setq company-backend 'company-ycmd)
(company-manual-begin))))
;;; funcs.el --- Ycmd Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2017 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun ycmd/manual-semantic-company-completer ()
"A useful function that can be bound, if users prefer to trigger company
completion manually"
(interactive)
(company-cancel)
(let ((ycmd-force-semantic-completion (not (company-ycmd--in-include))))
(setq company-backend 'company-ycmd)
(company-manual-begin)))