From f3dbeec5dc38a04261b99df3e0fb893e956867c6 Mon Sep 17 00:00:00 2001 From: Nir Friedman Date: Sun, 5 Nov 2017 09:55:32 -0500 Subject: [PATCH] Add manual semantic completion function for company to ycmd layer --- layers/+tools/ycmd/README.org | 4 ++-- layers/+tools/ycmd/funcs.el | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/layers/+tools/ycmd/README.org b/layers/+tools/ycmd/README.org index de1e9c115..7d256c1ac 100644 --- a/layers/+tools/ycmd/README.org +++ b/layers/+tools/ycmd/README.org @@ -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 "") 'spacemacs/company-ycmd-manual-semantic-complete) +(global-set-key (kbd "") 'ycmd/manual-semantic-company-completer) #+END_SRC This function will automatically cancel out of any active completers, and offer diff --git a/layers/+tools/ycmd/funcs.el b/layers/+tools/ycmd/funcs.el index ddb1adbb3..77c676b06 100644 --- a/layers/+tools/ycmd/funcs.el +++ b/layers/+tools/ycmd/funcs.el @@ -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 +;; 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)))