Skip to content

Commit

Permalink
Add more features for D language
Browse files Browse the repository at this point in the history
Add `company-dcd` package that uses DCD (a completion daemon for D) to
provide better IDE features:

- Better code completion.
- Jump to definition.
- Search symbol references.
  • Loading branch information
tuhdo committed Sep 12, 2016
1 parent 6bb4416 commit 452e740
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions layers/+lang/d/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#install][Install]]
- [[#key-bindings][Key bindings]]

* Description
This simple layer adds support for the [[http://dlang.org/][D language]].
Expand All @@ -14,3 +15,18 @@ It adds =d-mode= as well as integrating it with =auto-completion= and =syntax-ch
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =d= to the existing =dotspacemacs-configuration-layers= list in this
file.

To enable smart D completion, you need to install [[https://github.com/Hackerpilot/DCD][DCD]]. Here are [[https://github.com/Hackerpilot/DCD#setup][installation
instructions]]. After successfully built DCD, you need to copy the binary
=dcd-server= and =dcd-client= in =bin/= directory to somewhere in your $PATH e.g.
=/usr/local/bin= on Linux.

* Key bindings

| Key Binding | Description |
|-------------+-------------------------------------------------------|
| ~SPC m g g~ | Go to definition |
| ~SPC m g b~ | Jump back (after go to definition with above command) |
| ~SPC m g r~ | find references to all symbol at point |
|-------------+-------------------------------------------------------|

13 changes: 13 additions & 0 deletions layers/+lang/d/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(setq d-packages
'(
company
company-dcd
d-mode
flycheck
(flycheck-dmd-dub :toggle (configuration-layer/package-usedp 'flycheck))
Expand All @@ -26,6 +27,18 @@
(with-eval-after-load 'company-dabbrev-code (push 'd-mode company-dabbrev-code-modes))
(spacemacs|add-company-hook d-mode))

(defun d/init-company-dcd ()
(use-package company-dcd
:init
(progn
(add-hook 'd-mode-hook 'company-dcd-mode)
(push 'company-dcd company-backends-d-mode)
(spacemacs/set-leader-keys-for-major-mode 'd-mode
"gg" 'company-dcd-goto-definition
"gb" 'company-dcd-goto-def-pop-marker
"hh" 'company-dcd-show-ddoc-with-buffer
"gr" 'company-dcd-ivy-search-symbol))))

(defun d/init-d-mode ()
(use-package d-mode :defer t))

Expand Down

0 comments on commit 452e740

Please sign in to comment.