Refactor and simplify company backends declaration

Enabling a company backend for a specific mode was a tedious tasks with code
scattered at different locations, one for local variable definitions, one for
company hook function definitions and another where the backends were pushed to
the local variables (which was problematic, since we ended up pushing the same
backends over and over again with `SPC f e R`, pushes have been replaced by
add-to-list calls in the new macro).

All these steps are now put together at one place with the new macro
spacemacs|add-company-backends, check its docstring for more info on its
arguments.

This macro also allows to define arbitrary buffer local variables to tune
company for specific modes (similar to layer variables via a keyword :variables)

The code related to company backends management has been moved to the
auto-completion layer in the funcs.el file. A nice side effect of this move is
that it enforces correct encapsulation of company backends related code. We can
now easily detect if there is some configuration leakage when the
auto-completion layer is not used. But we loose macro expansion at file loading
time (not sue it is a big concern though).

The function spacemacs|enable-auto-complete was never used so it has been
deleted which led to the deletion of the now empty file core-auto-completion.el.

The example in LAYERS.org regarding auto-completion is now out of date and has
been deleted. An example to setup auto-completion is provided in the README.org
file of the auto-completion layer.
This commit is contained in:
syl20bnr 2017-01-02 00:39:04 -05:00
parent bdd4e6c23f
commit 74fdbb6795
89 changed files with 330 additions and 565 deletions

View file

@ -1,83 +0,0 @@
;;; core-auto-completion.el --- Spacemacs Core File
;;
;; Copyright (c) 2012-2016 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
;; Company -------------------------------------------------------------------
(defvar spacemacs-default-company-backends
'((company-dabbrev-code company-gtags company-etags company-keywords)
company-files company-dabbrev)
"The list of default company backends used by spacemacs.
This variable is used to configure mode-specific company backends in spacemacs.
Backends in this list will always be active in these modes, as well as any
backends added by individual spacemacs layers.")
(defmacro spacemacs|defvar-company-backends (mode)
"Define a MODE specific company backend variable with default backends.
The variable name format is company-backends-MODE."
`(defvar ,(intern (format "company-backends-%S" mode))
',spacemacs-default-company-backends
,(format "Company backend list for %S" mode)))
(defmacro spacemacs|add-company-hook (mode)
"Enable company for the given MODE.
MODE must match the symbol passed in `spacemacs|defvar-company-backends'.
The initialization function is hooked to `MODE-hook'."
(let ((mode-hook (intern (format "%S-hook" mode)))
(func (intern (format "spacemacs//init-company-%S" mode)))
(backend-list (intern (format "company-backends-%S" mode))))
`(when (configuration-layer/package-usedp 'company)
(defun ,func ()
,(format "Initialize company for %S" mode)
(when auto-completion-enable-snippets-in-popup
(setq ,backend-list (mapcar 'spacemacs//show-snippets-in-company
,backend-list)))
(set (make-variable-buffer-local 'auto-completion-front-end)
'company)
(set (make-variable-buffer-local 'company-backends)
,backend-list))
(add-hook ',mode-hook ',func t)
(add-hook ',mode-hook 'company-mode t))))
(defmacro spacemacs|disable-company (mode)
"Disable company for the given MODE.
MODE parameter must match the parameter used in the call to
`spacemacs|add-company-hook'."
(let ((mode-hook (intern (format "%S-hook" mode)))
(func (intern (format "spacemacs//init-company-%S" mode))))
`(progn
(remove-hook ',mode-hook ',func)
(remove-hook ',mode-hook 'company-mode))))
(defun spacemacs//show-snippets-in-company (backend)
(if (or (not auto-completion-enable-snippets-in-popup)
(and (listp backend) (member 'company-yasnippet backend)))
backend
(append (if (consp backend) backend (list backend))
'(:with company-yasnippet))))
;; Auto-complete -------------------------------------------------------------
(defmacro spacemacs|enable-auto-complete (mode)
"Enable auto-complete for the given MODE.
The initialization function is hooked to `MODE-hook'."
(let ((mode-hook (intern (format "%S-hook" mode)))
(func (intern (format "spacemacs//init-auto-complete-%S" mode))))
`(when (configuration-layer/package-usedp 'auto-complete)
(defun ,func ()
,(format "Initialize auto-complete for %S" mode)
(set (make-variable-buffer-local 'auto-completion-front-end)
'auto-complete)
(set (make-variable-buffer-local 'company-backends)
,(intern (format "company-backends-%S" mode))))
(add-hook ',mode-hook ',func)
(add-hook ',mode-hook 'auto-complete-mode))))
(provide 'core-auto-completion)

View file

@ -18,7 +18,6 @@
(require 'core-dotspacemacs)
(require 'core-custom-settings)
(require 'core-release-management)
(require 'core-auto-completion)
(require 'core-jump)
(require 'core-display-init)
(require 'core-themes-support)

View file

@ -29,8 +29,6 @@
- [[#load-ordering][Load ordering]]
- [[#no-require][No require]]
- [[#auto-load-everything][Auto-load everything]]
- [[#how-do-i--idiomatically][How do I ... idiomatically?]]
- [[#setup-auto-completion-for-a-major-mode][Setup auto-completion for a major mode]]
* Introduction
This document is intended as a tutorial for users who are interested in writing
@ -463,7 +461,6 @@ would have been installed even if the =auto-completion= layer had been disabled,
which is not what we want.
* Layer tips and tricks
** Cross-dependencies
Spacemacs provides a couple of additional useful functions you can use to check
whether other layers or packages are included.
@ -570,54 +567,3 @@ missing appropriate auto-loads.
Defer everything. You should have a very good reason not to defer the loading
of a package.
* How do I ... idiomatically?
** Setup auto-completion for a major mode
In your layer's =config.el=, call =spacemacs|defvar-company-backends=.
#+begin_src emacs-lisp
(spacemacs|defvar-company-backends yoyo-mode)
#+end_src
This creates a variable called =company-backends-yoyo-mode=. In the package
=init= functions, you should push backends to this variable. But of course, only
if the =auto-completion= layer is enabled.
#+begin_src emacs-lisp
(defconst yoyo-packages '(
;; ...
some-weird-package
;; ...
)
(when (configuration-layer/package-usedp 'company)
(defun yoyo/init-some-weird-package ()
(use-package some-weird-package
:defer t
;; This has to be in init because it's a package entry point
:init
(push 'some-weird-backend company-backends-yoyo-mode))))
#+end_src
Finally, we must make sure company is started when we enter =yoyo-mode=, but
again only if the =auto-completion= layer is enabled.
#+begin_src emacs-lisp
(defconst yoyo-packages '(
;; ...
yoyo-mode
;; ...
))
(defun yoyo/init-yoyo-mode ()
(use-package yoyo-mode
;; Some configuration goes here, however nothing relating to company
;; since this function may be called even if company is not installed!
))
(when (configuration-layer/package-usedp 'company)
(defun yoyo/post-init-yoyo-mode ()
;; This makes no reference to `some-weird-package', which may have
;; been excluded by the user
(spacemacs|add-company-hook yoyo-mode)))
#+end_src

View file

@ -20,5 +20,3 @@
(defvar erc-server-list nil
"If non nil, connect automatically to the specified servers with the given credentials.")
(spacemacs|defvar-company-backends erc-mode)

View file

@ -35,11 +35,10 @@
(push 'erc-terminal-notifier erc-packages))
(defun erc/post-init-company ()
(spacemacs|add-company-hook erc-mode)
(push 'company-capf company-backends-erc-mode))
(spacemacs|add-company-backends :backends company-capf :modes erc-mode))
(defun erc/post-init-company-emoji ()
(push 'company-emoji company-backends-erc-mode))
(spacemacs|add-company-backends :backends company-emoji :modes erc-mode))
(defun erc/post-init-emoji-cheat-sheet-plus ()
(add-hook 'erc-mode-hook 'emoji-cheat-sheet-plus-display-mode))

View file

@ -22,5 +22,3 @@
(defvar rcirc-spacemacs-layout-binding "i"
"Binding used in the setup for `spacemacs-layouts' micro-state")
(spacemacs|defvar-company-backends rcirc-mode)

View file

@ -13,11 +13,10 @@
))
(defun rcirc/post-init-company ()
(spacemacs|add-company-hook rcirc-mode)
(push 'company-capf company-backends-rcirc-mode))
(spacemacs|add-company-backends :backends company-capf :modes rcirc-mode))
(defun rcirc/post-init-company-emoji ()
(push 'company-emoji company-backends-rcirc-mode))
(spacemacs|add-company-backends :backends company-emoji :modes rcirc-mode))
(defun rcirc/post-init-emoji-cheat-sheet-plus ()
(add-hook 'rcirc-mode-hook 'emoji-cheat-sheet-plus-display-mode))

View file

@ -12,8 +12,6 @@
- [[#enable-company-or-auto-complete-globally][Enable company or auto-complete globally]]
- [[#replacing-company-by-auto-complete][Replacing company by auto-complete]]
- [[#add-auto-completion-in-a-layer][Add auto-completion in a layer]]
- [[#in-configel][In =config.el=]]
- [[#in-packagesel][In =packages.el=]]
- [[#completion-back-ends][Completion back ends]]
- [[#improved-faces][Improved faces]]
- [[#key-bindings-1][Key Bindings]]
@ -152,32 +150,26 @@ You can disable =company= by adding it to the =dotspacemacs-excluded-packages=
variable, then you are free to enable =auto-complete= globally.
** Add auto-completion in a layer
Here is an example to add =company= auto-completion to python buffer:
Here is an example to add =company= auto-completion to python buffers via the
package =company-anaconda=.
*** In =config.el=
#+BEGIN_SRC emacs-lisp
;; Define the buffer local company backend variable
(spacemacs|defvar-company-backends python-mode)
#+END_SRC
In the file =packages.el= of the python layer:
*** In =packages.el=
#+BEGIN_SRC emacs-lisp
;; Add the relevant packages to the layer
;; here it is `company-anaconda'
(setq python-packages
'(...
company
(company-anaconda :toggle (configuration-layer/package-usedp 'company))
...))
;; Hook company to python-mode
(defun python/post-init-company ()
(spacemacs|add-company-hook python-mode))
;; Add the backend to the major-mode specific backend list
(defun python/init-company-anaconda ()
(use-package company-anaconda
:defer t
:init (push 'company-anaconda company-backends-python-mode)))
:init
(spacemacs|add-company-backends
:backends 'company-anaconda
:modes python-mode)))
#+END_SRC
** Completion back ends

View file

@ -11,6 +11,14 @@
;; Company -------------------------------------------------------------------
(defvar spacemacs-default-company-backends
'((company-dabbrev-code company-gtags company-etags company-keywords)
company-files company-dabbrev)
"The list of default company backends used by spacemacs.
This variable is used to configure mode-specific company backends in spacemacs.
Backends in this list will always be active in these modes, as well as any
backends added by individual spacemacs layers.")
(defvar-local auto-completion-front-end 'company
"Which auto-completion front end to use.")

View file

@ -32,6 +32,100 @@
:documentation "Enable auto-completion."
:evil-leader "ta")
;; company backends declaration macro
(defmacro spacemacs|add-company-backends (&rest props)
"Add and enable company backends.
This function should be called exclusively in `post-init-company' functions or
`init-company-xxx' function where xxx is company backend package.
Available PROPS:
`:backends BACKENDS'
One or several symbols or lists representing a company backend or a list of
company backends.
`:modes MODES'
One or several modes where BACKENDS will be added.
`:variables VAR VALUE'
One or several VAR VALUE pairs (similar to layer variables).
These variables are made buffer local so their values are set only for
the given MODES.
`:from SYMBOL'
Advanced property aimed at avoiding hook function name conflicts when
`:variables' property is used in several calls to this macro for the same
MODES."
(declare (indent 0))
(let* ((backends (spacemacs/mplist-get props :backends))
(modes (spacemacs/mplist-get props :modes))
(variables (spacemacs/mplist-get props :variables))
(from (plist-get props :from))
(result '(progn)))
(dolist (mode modes)
(let ((backends-var-name (intern (format "company-backends-%S" mode)))
(init-func-name (intern (format "spacemacs//init-company-%S" mode)))
(vars-func-name (intern
(format "spacemacs//init-company-vars-%S%s" mode
(if from (format "-%S" from) ""))))
(mode-hook-name (intern (format "%S-hook" mode))))
;; declare buffer local company-backends variable
(push `(defvar ,backends-var-name
',spacemacs-default-company-backends
,(format "Company backend list for %S." mode)) result)
;; add backends
(dolist (backend backends)
(push `(add-to-list ',backends-var-name ',backend) result))
;; define initialization hook function
(push `(defun ,init-func-name ()
,(format "Initialize company for %S." mode)
(when auto-completion-enable-snippets-in-popup
(setq ,backends-var-name
(mapcar 'spacemacs//show-snippets-in-company
,backends-var-name)))
(set (make-variable-buffer-local 'auto-completion-front-end)
'company)
(set (make-variable-buffer-local 'company-backends)
,backends-var-name)) result)
(push `(add-hook ',mode-hook-name ',init-func-name t) result)
;; define variables hook function
(when variables
(let ((vars-func `(defun ,vars-func-name ()
,(format "Define company local variables for %S."
mode)))
vars)
(while variables
(let* ((var (pop variables))
(forms
(when (consp variables)
`(set (make-variable-buffer-local ',var)
,(eval (pop variables))))))
(when forms (push forms vars))))
(push (append vars-func vars) result))
(push `(add-hook ',mode-hook-name ',vars-func-name t) result))
(push `(add-hook ',mode-hook-name 'company-mode t) result)))
;; return the expanded macro in correct order
(reverse result)))
(defmacro spacemacs|disable-company (mode)
"Disable company for the given MODE.
MODE parameter must match the :modes values used in the call to
`spacemacs|add-company-backends'."
(let ((mode-hook-name (intern (format "%S-hook" mode)))
(func (intern (format "spacemacs//init-company-%S" mode))))
`(progn
(remove-hook ',mode-hook-name ',func)
(remove-hook ',mode-hook-name 'company-mode))))
(defun spacemacs//show-snippets-in-company (backend)
(if (or (not auto-completion-enable-snippets-in-popup)
(and (listp backend) (member 'company-yasnippet backend)))
backend
(append (if (consp backend) backend (list backend))
'(:with company-yasnippet))))
;; auto-completion key bindings functions

View file

@ -28,5 +28,3 @@ used.")
(defvar org-enable-org-journal-support nil
"If non-nil org-journal is configured.")
(spacemacs|defvar-company-backends org-mode)

View file

@ -40,11 +40,10 @@
))
(defun org/post-init-company ()
(spacemacs|add-company-hook org-mode)
(push 'company-capf company-backends-org-mode))
(spacemacs|add-company-backends :backends company-capf :modes org-mode))
(defun org/post-init-company-emoji ()
(push 'company-emoji company-backends-org-mode))
(spacemacs|add-company-backends :backends company-emoji :modes org-mode))
(defun org/post-init-emoji-cheat-sheet-plus ()
(add-hook 'org-mode-hook 'spacemacs/delay-emoji-cheat-sheet-hook))

View file

@ -11,6 +11,4 @@
;; Variables
(spacemacs|defvar-company-backends react-mode)
(spacemacs|define-jump-handlers react-mode)

View file

@ -11,7 +11,6 @@
(setq react-packages
'(
company
company-tern
emmet-mode
evil-matchit
@ -23,11 +22,8 @@
web-mode
))
(defun react/post-init-company ()
(spacemacs|add-company-hook react-mode))
(defun react/post-init-company-tern ()
(push 'company-tern company-backends-react-mode))
(spacemacs|add-company-backends :backends company-tern :modes react-mode))
(defun react/post-init-emmet-mode ()
(add-hook 'react-mode-hook 'emmet-mode))

View file

@ -16,4 +16,3 @@ Emacs. If `use-helper', the `agda-mode' executable is used to
find its location.")
(spacemacs|define-jump-handlers agda2-mode agda2-goto-definition-keyboard)
(spacemacs|defvar-company-backends agda2-mode)

View file

@ -15,8 +15,7 @@
golden-ratio))
(defun agda/post-init-company ()
(spacemacs|add-company-hook agda2-mode)
(push 'company-capf company-backends-agda2-mode))
(spacemacs|add-company-backends :backends company-capf :modes agda2-mode))
(defun agda/init-agda ()
(if (and (eq 'use-helper agda-mode-path)

View file

@ -10,7 +10,5 @@
;;; License: GPLv3
;; variables
(spacemacs|defvar-company-backends asm-mode)
(spacemacs|defvar-company-backends nasm-mode)
(spacemacs|define-jump-handlers asm-mode)

View file

@ -61,8 +61,7 @@
(setq x86-lookup-browse-pdf-function 'x86-lookup-browse-pdf-pdf-tools)))))
(defun asm/post-init-company ()
(spacemacs|add-company-hook asm-mode)
(spacemacs|add-company-hook nasm-mode))
(spacemacs|add-company-backends :modes asm-mode nasm-mode))
(defun asm/post-init-ggtags ()
(add-hook 'asm-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))

View file

@ -14,9 +14,6 @@
(defvar c-c++-enable-clang-support nil
"If non nil Clang related packages and configuration are enabled.")
(spacemacs|defvar-company-backends c-mode-common)
(spacemacs|defvar-company-backends cmake-mode)
(spacemacs|define-jump-handlers c++-mode)
(spacemacs|define-jump-handlers c-mode)

View file

@ -9,6 +9,10 @@
;;
;;; License: GPLv3
(defun company-mode/more-than-prefix-guesser ()
(c-c++/load-clang-args)
(company-clang-guess-prefix))
;; Based on the Sarcasm/irony-mode compilation database code.
(defun company-mode/find-clang-complete-file ()
(when buffer-file-name

View file

@ -66,26 +66,26 @@
(defun c-c++/init-cmake-mode ()
(use-package cmake-mode
:mode (("CMakeLists\\.txt\\'" . cmake-mode) ("\\.cmake\\'" . cmake-mode))
:init (push 'company-cmake company-backends-cmake-mode)))
:init (spacemacs|add-company-backends
:backends company-cmake
:modes cmake-mode)))
(defun c-c++/post-init-company ()
(spacemacs|add-company-hook c-mode-common)
(spacemacs|add-company-hook cmake-mode)
(when (configuration-layer/package-usedp 'cmake-mode)
(spacemacs|add-company-backends :backends company-cmake :modes cmake-mode))
(when c-c++-enable-clang-support
(push 'company-clang company-backends-c-mode-common)
(defun company-mode/more-than-prefix-guesser ()
(c-c++/load-clang-args)
(company-clang-guess-prefix))
(spacemacs|add-company-backends :backends company-clang
:modes c-mode-common)
(setq company-clang-prefix-guesser 'company-mode/more-than-prefix-guesser)
(spacemacs/add-to-hooks 'c-c++/load-clang-args '(c-mode-hook c++-mode-hook))))
(spacemacs/add-to-hooks 'c-c++/load-clang-args
'(c-mode-hook c++-mode-hook))))
(defun c-c++/init-company-c-headers ()
(use-package company-c-headers
:defer t
:init (push 'company-c-headers company-backends-c-mode-common)))
:init (spacemacs|add-company-backends
:backends company-c-headers
:modes c-mode-common)))
(defun c-c++/post-init-flycheck ()
(dolist (mode '(c-mode c++-mode))
@ -132,7 +132,7 @@
"gG" 'ycmd-goto-imprecise)))
(defun c-c++/post-init-company-ycmd ()
(push 'company-ycmd company-backends-c-mode-common))
(spacemacs|add-company-backends :backends company-ycmd :modes c-mode-common))
(defun c-c++/pre-init-xcscope ()
(spacemacs|use-package-add-hook xcscope

View file

@ -9,15 +9,8 @@
;;
;;; License: GPLv3
;; ---------------------------------------------------------------------------
;; Prefixes
;; ---------------------------------------------------------------------------
;; Variables
(spacemacs|defvar-company-backends cider-mode)
(spacemacs|defvar-company-backends cider-repl-mode)
(spacemacs|define-jump-handlers clojure-mode)
(spacemacs|define-jump-handlers clojurec-mode)
(spacemacs|define-jump-handlers clojurescript-mode)

View file

@ -275,10 +275,11 @@
(add-hook 'cider-mode-hook 'subword-mode))
(defun clojure/post-init-company ()
(push 'company-capf company-backends-cider-mode)
(spacemacs|add-company-hook cider-mode)
(push 'company-capf company-backends-cider-repl-mode)
(spacemacs|add-company-hook cider-repl-mode))
(spacemacs|add-company-backends
:backends company-capf
:modes
company-backends-cider-mode
company-backends-cider-repl-mode))
(defun clojure/post-init-ggtags ()
(add-hook 'clojure-mode-local-vars-hook #'spacemacs/ggtags-mode-enable))

View file

@ -11,6 +11,4 @@
;; variables
(spacemacs|defvar-company-backends csharp-mode)
(spacemacs|define-jump-handlers csharp-mode)

View file

@ -20,7 +20,8 @@
))
(defun csharp/init-omnisharp ()
;; Load omnisharp-mode with csharp-mode, this should start the omnisharp server automatically
;; Load omnisharp-mode with csharp-mode,
;; this should start the omnisharp server automatically
(add-hook 'csharp-mode-hook 'omnisharp-mode)
(use-package omnisharp
:defer t
@ -31,7 +32,6 @@
;; Note: if you are using a roslyn based omnisharp server you can
;; set back this variable to t.
(setq omnisharp-auto-complete-want-documentation nil))
(push 'company-omnisharp company-backends-csharp-mode)
(add-to-list 'spacemacs-jump-handlers-csharp-mode
'omnisharp-go-to-definition))
:config
@ -39,13 +39,15 @@
(spacemacs/declare-prefix-for-mode 'csharp-mode "mc" "csharp/compile")
(spacemacs/declare-prefix-for-mode 'csharp-mode "mf" "csharp/file")
(spacemacs/declare-prefix-for-mode 'csharp-mode "mg" "csharp/navigation")
(spacemacs/declare-prefix-for-mode 'csharp-mode "mh" "csharp/documentation")
(spacemacs/declare-prefix-for-mode 'csharp-mode "mh"
"csharp/documentation")
(spacemacs/declare-prefix-for-mode 'csharp-mode "mr" "csharp/refactoring")
(spacemacs/declare-prefix-for-mode 'csharp-mode "ms" "csharp/server")
(spacemacs/declare-prefix-for-mode 'csharp-mode "mt" "csharp/tests")
(spacemacs/set-leader-keys-for-major-mode 'csharp-mode
;; Compile
"cc" 'omnisharp-build-in-emacs ;; Only one compile command so use top-level
;; Only one compile command so use top-level
"cc" 'omnisharp-build-in-emacs
;; Solution/project manipulation
"fa" 'omnisharp-add-to-solution-current-file
"fA" 'omnisharp-add-to-solution-dired-selected-files
@ -72,7 +74,8 @@
"rm" 'omnisharp-rename
"rM" 'omnisharp-rename-interactively
"rr" 'omnisharp-run-code-action-refactoring
;; Server manipulation, inspired spacemacs REPL bindings since C# does not provice a REPL
;; Server manipulation, inspired spacemacs REPL bindings since C# does
;; not provice a REPL
"ss" 'omnisharp-start-omnisharp-server
"sS" 'omnisharp-stop-server
"sr" 'omnisharp-reload-solution
@ -86,7 +89,10 @@
"=" 'omnisharp-code-format))))
(defun csharp/post-init-company ()
(spacemacs|add-company-hook csharp-mode))
(when (configuration-layer/package-usedp 'omnisharp)
(spacemacs|add-company-backends
:backends company-omnisharp
:modes csharp-mode)))
(defun csharp/init-csharp-mode ()
(use-package csharp-mode
@ -94,7 +100,8 @@
(defun csharp/post-init-evil-matchit ()
(with-eval-after-load 'evil-matchit
(plist-put evilmi-plugins 'csharp-mode '((evilmi-simple-get-tag evilmi-simple-jump)
(plist-put evilmi-plugins 'csharp-mode
'((evilmi-simple-get-tag evilmi-simple-jump)
(evilmi-c-get-tag evilmi-c-jump))))
(add-hook 'csharp-mode-hook 'turn-on-evil-matchit-mode))

View file

@ -11,6 +11,4 @@
;; Variables
(spacemacs|defvar-company-backends d-mode)
(spacemacs|define-jump-handlers d-mode)

View file

@ -24,16 +24,15 @@
(defun d/post-init-company ()
;; Need to convince company that this C-derived mode is a code mode.
(with-eval-after-load 'company-dabbrev-code (push 'd-mode company-dabbrev-code-modes))
(spacemacs|add-company-hook d-mode))
(with-eval-after-load 'company-dabbrev-code
(push 'd-mode company-dabbrev-code-modes)))
(defun d/init-company-dcd ()
(use-package company-dcd
:defer t
:init
(progn
(add-hook 'd-mode-hook 'company-dcd-mode)
(push 'company-dcd company-backends-d-mode)
(spacemacs|add-company-backends :backends company-dcd :modes d-mode)
(spacemacs/set-leader-keys-for-major-mode 'd-mode
"gg" 'company-dcd-goto-definition
"gb" 'company-dcd-goto-def-pop-marker

View file

@ -17,7 +17,4 @@ Default is nil because Elixir compilation is based on macros and thus it
is unsafe. Activate this option only for trusted code, usage of a
directory variable is recommended.")
(spacemacs|defvar-company-backends elixir-mode)
(spacemacs|defvar-company-backends alchemist-iex-mode)
(spacemacs|define-jump-handlers elixir-mode)

View file

@ -24,8 +24,10 @@
))
(defun elixir/post-init-company ()
(spacemacs|add-company-hook elixir-mode)
(spacemacs|add-company-hook alchemist-iex-mode))
(when (configuration-layer/package-usedp 'alchemist)
(spacemacs|add-company-backends
:backends alchemist-company
:modes elixir-mode alchemist-iex-mode)))
(defun elixir/init-alchemist ()
(use-package alchemist
@ -36,9 +38,6 @@
(add-hook 'elixir-mode-hook 'alchemist-mode)
(setq alchemist-project-compile-when-needed t
alchemist-test-status-modeline nil)
;; setup company backends
(push 'alchemist-company company-backends-elixir-mode)
(push 'alchemist-company company-backends-alchemist-iex-mode)
(add-to-list 'spacemacs-jump-handlers-elixir-mode
'alchemist-goto-definition-at-point))
:config

View file

@ -1,12 +0,0 @@
;;; config.el --- elm Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 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
(spacemacs|defvar-company-backends elm-mode)

View file

@ -20,9 +20,8 @@
))
(defun elm/post-init-company ()
(spacemacs|add-company-hook elm-mode)
(add-hook 'elm-mode-hook 'elm-oracle-setup-completion)
(push 'company-elm company-backends-elm-mode))
(spacemacs|add-company-backends :backends company-elm :modes elm-mode)
(add-hook 'elm-mode-hook 'elm-oracle-setup-completion))
(defun elm/post-init-flycheck ()
(add-hook 'elm-mode-hook 'flycheck-mode)

View file

@ -11,8 +11,5 @@
;; Variables
(spacemacs|defvar-company-backends emacs-lisp-mode)
(spacemacs|defvar-company-backends ielm-mode)
(spacemacs|define-jump-handlers emacs-lisp-mode)
(spacemacs|define-jump-handlers lisp-interaction-mode)

View file

@ -46,8 +46,10 @@
(lisp-indent-line))))))
(defun emacs-lisp/post-init-company ()
(spacemacs|add-company-hook ielm-mode)
(push '(company-files company-capf) company-backends-ielm-mode))
(spacemacs|add-company-backends :backends company-capf
:modes emacs-lisp-mode)
(spacemacs|add-company-backends :backends (company-files company-capf)
:modes ielm-mode))
(defun emacs-lisp/post-init-eldoc ()
(add-hook 'emacs-lisp-mode-hook 'eldoc-mode))
@ -101,10 +103,7 @@
"gG" 'spacemacs/nav-find-elisp-thing-at-point-other-window
"," 'lisp-state-toggle-lisp-state
"tb" 'spacemacs/ert-run-tests-buffer
"tq" 'ert))
;; company support
(push 'company-capf company-backends-emacs-lisp-mode)
(spacemacs|add-company-hook emacs-lisp-mode))
"tq" 'ert)))
(defun emacs-lisp/init-macrostep ()
(use-package macrostep

View file

@ -11,6 +11,4 @@
;; Variables
(spacemacs|defvar-company-backends faust-mode)
(spacemacs|define-jump-handlers faust-mode)

View file

@ -17,7 +17,7 @@
yasnippet))
(defun faust/post-init-company ()
(spacemacs|add-company-hook faust-mode))
(spacemacs|add-company-backends :modes faust-mode))
(defun faust/init-faust-mode ()
(use-package faust-mode

View file

@ -11,8 +11,6 @@
;; variables
(spacemacs|defvar-company-backends go-mode)
(spacemacs|define-jump-handlers go-mode godef-jump)
(defvar go-use-gocheck-for-testing nil

View file

@ -1,6 +1,5 @@
(setq go-packages
'(
company
(company-go :toggle (configuration-layer/package-usedp 'company))
flycheck
(flycheck-gometalinter :toggle (and go-use-gometalinter
@ -15,16 +14,14 @@
))
(defun go/post-init-company ()
(spacemacs|add-company-hook go-mode))
(defun go/init-company-go ()
(use-package company-go
:defer t
:init
(progn
(setq company-go-show-annotation t)
(push 'company-go company-backends-go-mode))))
(spacemacs|add-company-backends
:backends company-go
:modes go-mode
:variables company-go-show-annotation t)))
(defun go/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'go-mode))

View file

@ -13,10 +13,6 @@
(setq haskell-modes '(haskell-mode literate-haskell-mode))
(spacemacs|defvar-company-backends haskell-mode)
(spacemacs|defvar-company-backends haskell-cabal-mode)
(spacemacs|defvar-company-backends intero-repl-mode)
(spacemacs|define-jump-handlers haskell-mode haskell-mode-jump-to-def-or-tag)
(defvar haskell-completion-backend 'ghci
@ -25,4 +21,6 @@ Available options are `ghci', `intero' and `ghc-mod'. Default is
`ghci'.")
(defvar haskell-enable-hindent-style nil
"Style to use for formatting with hindent; available are: fundamental johan-tibell chris-done gibiansky. If nil hindent is disabled.")
"Style to use for formatting with hindent; available are:
fundamental johan-tibell chris-done gibiansky.
If nil hindent is disabled.")

View file

@ -20,12 +20,14 @@
(`intero (spacemacs-haskell//setup-intero)))))
(defun spacemacs-haskell//setup-ghci ()
(add-to-list 'company-backends-haskell-mode
'(company-ghci company-dabbrev-code company-yasnippet)))
(spacemacs|add-company-backends
:backends (company-ghci company-dabbrev-code company-yasnippet)
:modes haskell-mode))
(defun spacemacs-haskell//setup-ghc-mod ()
(add-to-list 'company-backends-haskell-mode
'(company-ghc company-dabbrev-code company-yasnippet))
(spacemacs|add-company-backends
:backends (company-ghc company-dabbrev-code company-yasnippet)
:modes haskell-mode)
(ghc-init)
(dolist (mode haskell-modes)
(spacemacs/declare-prefix-for-mode mode "mm" "haskell/ghc-mod")
@ -47,8 +49,9 @@
(set-face-attribute 'ghc-face-warn nil :underline nil)))
(defun spacemacs-haskell//setup-intero ()
(add-to-list 'company-backends-haskell-mode
'(company-intero company-dabbrev-code company-yasnippet))
(spacemacs|add-company-backends
:backends (company-intero company-dabbrev-code company-yasnippet)
:modes haskell-mode)
(push 'intero-goto-definition spacemacs-jump-handlers)
(intero-mode)
(dolist (mode haskell-modes)

View file

@ -12,7 +12,6 @@
(setq haskell-packages
'(
cmm-mode
company
(company-cabal :toggle (configuration-layer/package-usedp 'company))
company-ghci
company-ghc
@ -33,19 +32,12 @@
(use-package cmm-mode
:defer t))
(defun haskell/post-init-company ()
(spacemacs|add-company-hook haskell-mode)
(spacemacs|add-company-hook haskell-cabal-mode)
(when (eq haskell-completion-backend 'intero)
(spacemacs|add-company-hook intero-repl-mode)))
(defun haskell/init-company-cabal ()
(use-package company-cabal
:if (configuration-layer/package-usedp 'company)
:defer t
:init
(push '(company-cabal)
company-backends-haskell-cabal-mode)))
:init (spacemacs|add-company-backends
:backends company-cabal
:modes haskell-cabal-mode)))
(defun haskell/init-company-ghci ()
(use-package company-ghci

View file

@ -1,20 +0,0 @@
;;; packages.el --- HTML Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 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
;; Variables
(spacemacs|defvar-company-backends css-mode)
(spacemacs|defvar-company-backends jade-mode)
(spacemacs|defvar-company-backends slim-mode)
(spacemacs|defvar-company-backends web-mode)
;;TODO: when this becomes available -- uncomment. -@robbyoconnor
;; (spacemacs|defvar-company-backends haml-mode)

View file

@ -14,8 +14,3 @@
(if (bound-and-true-p yas-minor-mode)
(call-interactively 'emmet-expand-yas)
(call-interactively 'emmet-expand-line)))
;; see https://github.com/osv/company-web/issues/4
(defun spacemacs//company-web-minimum-prefix-length ()
"Set company minimum prefix length to 0 for the current buffer only."
(set (make-local-variable 'company-minimum-prefix-length) 0))

View file

@ -31,25 +31,33 @@
))
(defun html/post-init-company ()
(spacemacs|add-company-hook css-mode))
(spacemacs|add-company-backends
:backends company-css
:modes css-mode))
;;TODO: whenever company-web makes a backend for haml-mode it should be added here. -- @robbyoconnor
(defun html/init-company-web ()
(use-package company-web
:defer t
:init
(progn
(spacemacs|add-company-hook jade-mode)
(spacemacs|add-company-hook slim-mode)
(spacemacs|add-company-hook web-mode))))
(spacemacs|add-company-backends
:backends (company-web-html company-css)
:modes web-mode
:variables
;; see https://github.com/osv/company-web/issues/4
company-minimum-prefix-length 0)
(spacemacs|add-company-backends
:backends company-web-jade
:modes pug-mode)
(spacemacs|add-company-backends
:backends company-web-slim
:modes slim-mode))))
(defun html/init-css-mode ()
(use-package css-mode
:defer t
:init
(progn
(push 'company-css company-backends-css-mode)
;; Mark `css-indent-offset' as safe-local variable
(put 'css-indent-offset 'safe-local-variable #'integerp)
@ -135,8 +143,7 @@
(defun html/init-pug-mode ()
(use-package pug-mode
:defer t
:mode ("\\.pug$" . pug-mode)
:init (push 'company-web-jade company-backends-jade-mode)))
:mode ("\\.pug$" . pug-mode)))
(defun html/init-sass-mode ()
(use-package sass-mode
@ -150,8 +157,7 @@
(defun html/init-slim-mode ()
(use-package slim-mode
:defer t
:init (push 'company-web-slim company-backends-slim-mode)))
:defer t))
(defun html/post-init-smartparens ()
(spacemacs/add-to-hooks
@ -174,10 +180,6 @@
(defun html/init-web-mode ()
(use-package web-mode
:defer t
:init
(progn
(push '(company-web-html company-css) company-backends-web-mode)
(add-hook 'web-mode-hook 'spacemacs//company-web-minimum-prefix-length))
:config
(progn
(spacemacs/declare-prefix-for-mode 'web-mode "me" "errors")

View file

@ -1,13 +0,0 @@
;;; config.el --- Idris Layer config File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Timothy Jones <git@zmthy.io>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(spacemacs|defvar-company-backends idris-mode)
(spacemacs|defvar-company-backends idris-repl-mode)

View file

@ -9,16 +9,18 @@
;;
;;; License: GPLv3
(setq idris-packages '(company
(setq idris-packages
'(
company
idris-mode
golden-ratio
popwin))
popwin
))
(defun idris/post-init-company ()
(spacemacs|add-company-hook idris-mode)
(spacemacs|add-company-hook idris-repl-mode)
(push 'company-capf company-backends-idris-mode)
(push 'company-capf company-backends-idris-repl-mode))
(spacemacs|add-company-backends
:backends company-capf
:modes idris-mode idris-repl-mode))
(defun idris/init-idris-mode ()
(use-package idris-mode

View file

@ -8,6 +8,6 @@
;;
;;; License: GPLv3
(spacemacs|defvar-company-backends java-mode)
;; variables
(spacemacs|define-jump-handlers java-mode)

View file

@ -11,21 +11,21 @@
(setq java-packages
'(
company
(company-emacs-eclim :toggle (configuration-layer/package-usedp 'company))
(company-emacs-eclim :toggle
(configuration-layer/package-usedp 'company))
eclim
ggtags
helm-gtags
(java-mode :location built-in)
))
(defun java/post-init-company ()
(spacemacs|add-company-hook java-mode))
(defun java/init-company-emacs-eclim ()
(use-package company-emacs-eclim
:defer t
:init (push 'company-emacs-eclim company-backends-java-mode)))
:init
(spacemacs|add-company-backends
:backends company-emacs-eclim
:modes java-mode)))
(defun java/init-eclim ()
(use-package eclim
@ -34,7 +34,8 @@
:init
(progn
(add-hook 'java-mode-hook 'eclim-mode)
(add-to-list 'spacemacs-jump-handlers-java-mode 'eclim-java-find-declaration))
(add-to-list 'spacemacs-jump-handlers-java-mode
'eclim-java-find-declaration))
:config
(progn
(require 'eclimd)

View file

@ -11,8 +11,6 @@
;; Variables
(spacemacs|defvar-company-backends js2-mode)
(spacemacs|define-jump-handlers js2-mode)
(defvar javascript-disable-tern-port-files t

View file

@ -12,7 +12,6 @@
(setq javascript-packages
'(
coffee-mode
company
(company-tern :toggle (configuration-layer/package-usedp 'company))
evil-matchit
flycheck
@ -35,20 +34,19 @@
:init
(progn
;; indent to right position after `evil-open-below' and `evil-open-above'
(add-hook 'coffee-mode-hook '(lambda ()
(add-hook 'coffee-mode-hook
'(lambda ()
(setq indent-line-function 'javascript/coffee-indent
evil-shift-width coffee-tab-width))))))
(defun javascript/post-init-company ()
(spacemacs|add-company-hook js2-mode))
(defun javascript/init-company-tern ()
(use-package company-tern
:if (and (configuration-layer/package-usedp 'company)
(configuration-layer/package-usedp 'tern))
:defer t
:init
(push 'company-tern company-backends-js2-mode)))
:init (spacemacs|add-company-backends
:backends company-tern
:modes js2-mode)))
(defun javascript/post-init-flycheck ()
(dolist (mode '(coffee-mode js2-mode json-mode))

View file

@ -11,8 +11,6 @@
;; variables
(spacemacs|defvar-company-backends LaTeX-mode)
(spacemacs|define-jump-handlers latex-mode)
(defvar latex-build-command (if (executable-find "latexmk") "LatexMk" "LaTeX")

View file

@ -13,7 +13,6 @@
'(
auctex
(auctex-latexmk :toggle (string= "LatexMk" latex-build-command))
company
(company-auctex :toggle (configuration-layer/package-usedp 'company))
evil-matchit
(reftex :location built-in)
@ -130,19 +129,17 @@
:post-config
(auctex-latexmk-setup)))))
(defun latex/post-init-company ()
(spacemacs|add-company-hook LaTeX-mode))
(defun latex/init-company-auctex ()
(use-package company-auctex
:defer t
:init
(progn
(push 'company-auctex-labels company-backends-LaTeX-mode)
(push 'company-auctex-bibs company-backends-LaTeX-mode)
(push '(company-auctex-macros
:init (spacemacs|add-company-backends
:backends
company-auctex-labels
company-auctex-bibs
(company-auctex-macros
company-auctex-symbols
company-auctex-environments) company-backends-LaTeX-mode))))
company-auctex-environments)
:modes LaTeX-mode)))
(defun latex/post-init-evil-matchit ()
(add-hook 'LaTeX-mode-hook 'evil-matchit-mode))

View file

@ -11,7 +11,5 @@
;; variables
(spacemacs|defvar-company-backends markdown-mode)
(defvar markdown-live-preview-engine 'eww
"Possibe values are `eww' (built-in browser) or `vmd' (installed with `npm').")

View file

@ -23,11 +23,12 @@
))
(defun markdown/post-init-company ()
(spacemacs|add-company-hook markdown-mode)
(push 'company-capf company-backends-markdown-mode))
(spacemacs|add-company-backends :backends company-capf :modes markdown-mode))
(defun markdown/post-init-company-emoji ()
(push 'company-emoji company-backends-markdown-mode))
(spacemacs|add-company-backends
:backends company-emoji
:modes markdown-mode))
(defun markdown/post-init-emoji-cheat-sheet-plus ()
(add-hook 'markdown-mode-hook 'emoji-cheat-sheet-plus-display-mode))

View file

@ -11,7 +11,4 @@
;; Variables
(spacemacs|defvar-company-backends nim-mode)
(spacemacs|defvar-company-backends nimscript-mode)
(spacemacs|define-jump-handlers nim-mode)

View file

@ -5,8 +5,9 @@
nim-mode))
(defun nim/post-init-company ()
(spacemacs|add-company-hook nim-mode)
(spacemacs|add-company-hook nimscript-mode))
(spacemacs|add-company-backends
:backends company-capf
:modes nim-mode nimscript-mode))
(defun nim/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'nim-mode))
@ -20,8 +21,6 @@
:defer t
:init
(progn
(when (configuration-layer/package-usedp 'company)
(push 'company-capf company-backends-nim-mode))
(add-hook 'nim-mode-hook 'nimsuggest-mode)
(push 'nimsuggest-find-definition spacemacs-jump-handlers-nim-mode))
:config

View file

@ -9,6 +9,6 @@
;;
;;; License: GPLv3
(spacemacs|defvar-company-backends merlin-mode)
;; variables
(spacemacs|define-jump-handlers tuareg-mode)

View file

@ -25,7 +25,11 @@
))
(defun ocaml/post-init-company ()
(spacemacs|add-company-hook merlin-mode))
(when (configuration-layer/layer-usedp 'merlin)
(spacemacs|add-company-backends
:backends merlin-company-backend
:modes merlin-mode
:variables merlin-completion-with-doc t)))
(when (configuration-layer/layer-usedp 'syntax-checking)
(defun ocaml/post-init-flycheck ()
@ -54,8 +58,6 @@
(add-to-list 'spacemacs-jump-handlers-tuareg-mode
'spacemacs/merlin-locate)
(add-hook 'tuareg-mode-hook 'merlin-mode)
(setq merlin-completion-with-doc t)
(push 'merlin-company-backend company-backends-merlin-mode)
(spacemacs/set-leader-keys-for-major-mode 'tuareg-mode
"cp" 'merlin-project-check
"cv" 'merlin-goto-project-file

View file

@ -11,6 +11,4 @@
;; variables
(spacemacs|defvar-company-backends php-mode)
(spacemacs|define-jump-handlers php-mode)

View file

@ -25,7 +25,7 @@
))
(defun php/post-init-company ()
(spacemacs|add-company-hook php-mode))
(spacemacs|add-company-backends :modes php-mode))
(defun php/init-drupal-mode ()
(use-package drupal-mode

View file

@ -9,7 +9,7 @@
;;
;;; License: GPLv3
(spacemacs|defvar-company-backends purescript-mode)
;; variables
(spacemacs|define-jump-handlers purescript-mode)

View file

@ -19,7 +19,10 @@
popwin))
(defun purescript/post-init-company ()
(spacemacs|add-company-hook purescript-mode))
(when (configuration-layer/package-usedp 'psc-ide)
(spacemacs|add-company-backends
:backends company-psc-ide-backend
:modes purescript-mode)))
(defun purescript/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'purescript-mode))
@ -57,7 +60,6 @@
(progn
(add-hook 'purescript-mode-hook 'psc-ide-mode)
(spacemacs/declare-prefix-for-mode 'purescript-mode "mm" "purescript/psc-ide")
(push 'company-psc-ide-backend company-backends-purescript-mode)
(customize-set-variable 'psc-ide-add-import-on-completion purescript-add-import-on-completion)
(customize-set-variable 'psc-ide-rebuild-on-save purescript-enable-rebuild-on-save)

View file

@ -11,10 +11,6 @@
;; variables
(spacemacs|defvar-company-backends python-mode)
(spacemacs|defvar-company-backends inferior-python-mode)
(spacemacs|defvar-company-backends pip-requirements-mode)
(spacemacs|define-jump-handlers python-mode)
(spacemacs|define-jump-handlers cython-mode anaconda-mode-goto)

View file

@ -65,18 +65,23 @@
(evil--jumps-push)))))
(defun python/post-init-company ()
(spacemacs|add-company-hook python-mode)
(spacemacs|add-company-hook inferior-python-mode)
(push '(company-files company-capf) company-backends-inferior-python-mode)
(add-hook 'inferior-python-mode-hook (lambda ()
(setq-local company-minimum-prefix-length 0)
(setq-local company-idle-delay 0.5))))
(spacemacs|add-company-backends
:backends (company-files company-capf)
:modes inferior-python-mode
:variables
company-minimum-prefix-length 0
company-idle-delay 0.5)
(when (configuration-layer/package-usedp 'pip-requirements)
(spacemacs|add-company-backends
:backends company-capf
:modes pip-requirements-mode)))
(defun python/init-company-anaconda ()
(use-package company-anaconda
:defer t
:init
(push 'company-anaconda company-backends-python-mode)))
:init (spacemacs|add-company-backends
:backends 'company-anaconda
:modes python-mode)))
(defun python/init-cython-mode ()
(use-package cython-mode
@ -165,12 +170,7 @@
(defun python/init-pip-requirements ()
(use-package pip-requirements
:defer t
:init
(progn
;; company support
(push 'company-capf company-backends-pip-requirements-mode)
(spacemacs|add-company-hook pip-requirements-mode))))
:defer t))
(defun python/init-py-isort ()
(use-package py-isort

View file

@ -11,9 +11,6 @@
;; Variables
(spacemacs|defvar-company-backends enh-ruby-mode)
(spacemacs|defvar-company-backends ruby-mode)
(spacemacs|define-jump-handlers enh-ruby-mode)
(spacemacs|define-jump-handlers ruby-mode)

View file

@ -47,8 +47,10 @@
"bo" 'bundle-open))))
(defun ruby/post-init-company ()
(spacemacs|add-company-hook ruby-mode)
(spacemacs|add-company-hook enh-ruby-mode)
(when (configuration-layer/package-usedp 'robe)
(spacemacs|add-company-backends
:backends company-robe
:modes ruby-mode enh-ruby-mode))
(with-eval-after-load 'company-dabbrev-code
(dolist (mode '(ruby-mode enh-ruby-mode))
(push mode company-dabbrev-code-modes))))
@ -128,9 +130,6 @@
(spacemacs/register-repl 'robe 'robe-start "robe")
(dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
(add-hook hook 'robe-mode))
(when (configuration-layer/package-usedp 'company)
(push 'company-robe company-backends-enh-ruby-mode)
(push 'company-robe company-backends-ruby-mode))
(spacemacs/add-to-hooks 'robe-jump
'(spacemacs-jump-handlers-ruby-mode
spacemacs-jump-handlers-enh-ruby-mode)))

View file

@ -11,6 +11,4 @@
;; Variables
(spacemacs|defvar-company-backends rust-mode)
(spacemacs|define-jump-handlers rust-mode)

View file

@ -73,11 +73,10 @@
:mode "/\\(Cargo.lock\\|\\.cargo/config\\)\\'"))
(defun rust/post-init-company ()
(push 'company-capf company-backends-rust-mode)
(spacemacs|add-company-hook rust-mode)
(add-hook 'rust-mode-hook
(lambda ()
(setq-local company-tooltip-align-annotations t))))
(spacemacs|add-company-backends
:backends company-capf
:modes rust-mode
:variables company-tooltip-align-annotations t))
(defun rust/post-init-smartparens ()
(with-eval-after-load 'smartparens

View file

@ -9,6 +9,6 @@
;;
;;; License: GPLv3
(spacemacs|define-jump-handlers scheme-mode geiser-edit-symbol-at-point)
;; variables
(spacemacs|defvar-company-backends scheme-mode)
(spacemacs|define-jump-handlers scheme-mode geiser-edit-symbol-at-point)

View file

@ -19,23 +19,22 @@
(defun scheme/post-init-company ()
;; Geiser provides completion as long as company mode is loaded.
(spacemacs|add-company-hook scheme-mode))
(spacemacs|add-company-backends :modes scheme-mode))
(defun scheme/init-geiser ()
(use-package geiser
:commands run-geiser
:init
(progn
(spacemacs/register-repl 'geiser 'geiser-mode-switch-to-repl "geiser"))
:init (spacemacs/register-repl 'geiser 'geiser-mode-switch-to-repl "geiser")
:config
(progn
;; prefixes
(spacemacs/declare-prefix-for-mode 'scheme-mode "mc" "compiling")
(spacemacs/declare-prefix-for-mode 'scheme-mode "mg" "navigation")
(spacemacs/declare-prefix-for-mode 'scheme-mode "mh" "documentation")
(spacemacs/declare-prefix-for-mode 'scheme-mode "mi" "insertion")
(spacemacs/declare-prefix-for-mode 'scheme-mode "mm" "macroexpansion")
(spacemacs/declare-prefix-for-mode 'scheme-mode "ms" "repl")
;; key bindings
(spacemacs/set-leader-keys-for-major-mode 'scheme-mode
"'" 'geiser-mode-switch-to-repl
"," 'lisp-state-toggle-lisp-state

View file

@ -1,14 +0,0 @@
;;; config.el --- Shaders Layer configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Boris Buliga <boris@d12frosted.io>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;; Variables
(spacemacs|defvar-company-backends glsl-mode)

View file

@ -10,23 +10,18 @@
;;; License: GLPv3
(setq shaders-packages
'(glsl-mode
company
(company-glsl
:location (recipe
(company-glsl :location (recipe
:fetcher github
:repo "Kaali/company-glsl")
:toggle (and (configuration-layer/package-usedp 'company)
(executable-find "glslangValidator")))))
(defun shaders/post-init-company ()
(spacemacs|add-company-hook glsl-mode))
(defun shaders/init-company-glsl ()
(use-package company-glsl
:defer t
:init
(push 'company-glsl
company-backends-glsl-mode)))
:init (spacemacs|add-company-backends
:backends company-glsl
:modes glsl-mode)))
(defun shaders/init-glsl-mode ()
"Initialize GLSL mode"

View file

@ -10,7 +10,5 @@
;;; License: GPLv3
;; variables
(spacemacs|defvar-company-backends sh-mode)
(spacemacs|defvar-company-backends fish-mode)
(spacemacs|define-jump-handlers sh-mode)

View file

@ -11,7 +11,6 @@
(setq shell-scripts-packages
'(
company
(company-shell :toggle (configuration-layer/package-usedp 'company))
fish-mode
flycheck
@ -21,17 +20,17 @@
(sh-script :location built-in)
))
(defun shell-scripts/post-init-company ()
(spacemacs|add-company-hook sh-mode)
(spacemacs|add-company-hook fish-mode))
(defun shell-scripts/init-company-shell ()
(use-package company-shell
:defer t
:init
(progn
(push 'company-shell company-backends-sh-mode)
(push '(company-shell company-fish-shell) company-backends-fish-mode))))
(spacemacs|add-company-backends
:backends company-shell
:modes sh-mode)
(spacemacs|add-company-backends
:backends (company-shell company-fish-shell)
:modes fish-mode))))
(defun shell-scripts/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'sh-mode))

View file

@ -9,7 +9,7 @@
;;
;;; License: GPLv3
(spacemacs|defvar-company-backends typescript-mode)
;; variables
(defvar typescript-fmt-on-save nil
"Run formatter on buffer save.")

View file

@ -20,7 +20,10 @@
))
(defun typescript/post-init-company ()
(spacemacs|add-company-hook typescript-mode))
(when (configuration-layer/package-usedp 'tide)
(spacemacs|add-company-backends
:backends company-tide
:modes typescript-mode)))
(defun php/post-init-eldoc ()
(add-hook 'typescript-mode-hook 'eldoc-mode))
@ -39,7 +42,7 @@
(kbd "C-j") 'tide-find-next-reference
(kbd "C-l") 'tide-goto-reference)
(add-hook 'typescript-mode-hook 'tide-setup)
(push 'company-tide company-backends-typescript-mode))
(add-to-list 'spacemacs-jump-handlers-typescript-mode 'tide-jump-to-definition))
:config
(progn
(spacemacs/declare-prefix-for-mode 'typescript-mode "mg" "goto")

View file

@ -1,14 +0,0 @@
;;; config.el --- YAML Layer configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 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
;; variables
(spacemacs|defvar-company-backends yaml-mode)

View file

@ -13,7 +13,7 @@
yaml-mode))
(defun yaml/post-init-company ()
(spacemacs|add-company-hook yaml-mode))
(spacemacs|add-company-backends :modes yaml-mode))
(defun yaml/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'yaml-mode))

View file

@ -1 +0,0 @@
(spacemacs|defvar-company-backends nix-mode)

View file

@ -1,21 +1,24 @@
(setq nixos-packages
'(
company
(company-nixos-options :toggle (configuration-layer/package-usedp 'company))
(company-nixos-options :toggle
(configuration-layer/package-usedp 'company))
(helm-nixos-options :toggle (configuration-layer/package-usedp 'helm))
nix-mode
nixos-options
))
(defun nixos/post-init-company ()
(spacemacs|add-company-hook nix-mode)
(push 'company-capf company-backends-nix-mode))
(let ((backends '(company-capf)))
(when (configuration-layer/package-usedp 'company-nixos-options)
(add-to-list 'backends 'company-nixos-options t))
(eval `(spacemacs|add-company-backends
:backends ,backends
:modes nix-mode))))
(defun nixos/init-company-nixos-options ()
(use-package company-nixos-options
:defer t
:init
(push 'company-nixos-options company-backends-nix-mode)))
:defer t))
(defun nixos/init-helm-nixos-options ()
(use-package helm-nixos-options

View file

@ -1,12 +0,0 @@
;;; config.el --- CFEgine Layer configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Nick Anderson <nick@cmdln.org>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(spacemacs|defvar-company-backends cfengine3-mode)

View file

@ -25,7 +25,7 @@
"j" 'cfengine3-reformat-json-string)))
(defun cfengine/post-init-company ()
(spacemacs|add-company-hook cfengine3-mode))
(spacemacs|add-company-backends :modes cfengine3-mode))
(defun cfengine/post-init-eldoc ()
(add-hook 'cfengine3-mode-hook 'eldoc-mode))

View file

@ -1,14 +0,0 @@
;;; config.el --- Finance Layer configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 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
;; Variables
(spacemacs|defvar-company-backends ledger-mode)

View file

@ -16,6 +16,10 @@
ledger-mode
))
(defun finance/post-init-company ()
(spacemacs|add-company-backends
:backends company-capf
:modes ledger-mode))
(defun finance/init-flycheck-ledger ()
(with-eval-after-load 'flycheck
@ -28,7 +32,6 @@
:init
(progn
(setq ledger-post-amount-alignment-column 62)
(push 'company-capf company-backends-ledger-mode)
(spacemacs/set-leader-keys-for-major-mode 'ledger-mode
"hd" 'ledger-delete-current-transaction
"a" 'ledger-add-transaction
@ -48,6 +51,3 @@
;; TODO remove this hack if the limitation is removed upstream
(add-hook 'ledger-mode-hook 'evil-normalize-keymaps)
(evilified-state-evilify ledger-report-mode ledger-report-mode-map))))
(defun finance/post-init-company ()
(spacemacs|add-company-hook ledger-mode))

View file

@ -1,14 +0,0 @@
;;; config.el --- Puppet layer configuration File for Spacemacs
;;
;; Copyright (c) 2012-2016 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
;; Variables
(spacemacs|defvar-company-backends puppet-mode)

View file

@ -35,7 +35,7 @@
))))
(defun puppet/post-init-company ()
(spacemacs|add-company-hook puppet-mode))
(spacemacs|add-company-backends :modes puppet-mode))
(defun puppet/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'puppet-mode))

View file

@ -9,7 +9,7 @@
;;
;;; License: GPLv3
;; variables
(defvar restclient-use-org nil
"If non-nil use `ob-http' instead of `restclient'.")
(spacemacs|defvar-company-backends restclient-mode)

View file

@ -10,7 +10,6 @@
;;; License: GPLv3
(setq restclient-packages
'(
company
(company-restclient :toggle (configuration-layer/package-usedp 'company))
golden-ratio
ob-http
@ -53,13 +52,12 @@
"R" 'restclient-http-send-current-raw
"y" 'restclient-copy-curl-command))))
(defun restclient/post-init-company ()
(spacemacs|add-company-hook restclient-mode))
(defun restclient/init-company-restclient ()
(use-package company-restclient
:defer t
:init (push 'company-restclient company-backends-restclient-mode)))
:init (spacemacs|add-company-backends
:backends company-restclient
:modes restclient-mode)))
(defun restclient/init-restclient-helm ()
(use-package restclient-helm

View file

@ -20,8 +20,6 @@
;; Variables
(spacemacs|defvar-company-backends eshell-mode)
(defvar shell-default-shell (if (eq window-system 'w32)
'eshell
'ansi-term)

View file

@ -38,8 +38,7 @@
(spacemacs|use-package-add-hook eshell
:post-init
(progn
(push 'company-capf company-backends-eshell-mode)
(spacemacs|add-company-hook eshell-mode)
(spacemacs|add-company-backends :backends company-capf :modes eshell-mode)
(add-hook 'eshell-directory-change-hook
'spacemacs//toggle-shell-auto-completion-based-on-path)
;; The default frontend screws everything up in short windows like