Improve Nim layer

- Add support for better completion using Nim's IDE tool, `nimsuggest`.
- Add key binding for goto definition and jump back.
- Eldoc integration (with the nimsuggest-mode)
- Update documentation.
This commit is contained in:
Tu Do 2016-09-15 18:04:48 +07:00 committed by Eivind Fonn
parent 781aa079ab
commit 763d6f5555
2 changed files with 25 additions and 10 deletions

View File

@ -5,24 +5,33 @@
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#working-with-nim][Working with Nim]]
- [[#nim-commands-start-with-m][Nim commands (start with =m=):]]
* Description
This layer provides the following features for Nim:
This layer adds support for nim (nimrod).
- Code completion.
- Jump to definition.
- Syntax checking.
* Install
** Layer
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =nim= to the existing =dotspacemacs-configuration-layers= list in this
file.
For syntax checking, the =syntax-checking= layer must also be added.
For all the features to work properly, =nimsuggest= must be installed properly
and =nimsuggest= binary must be in $PATH.
* Working with Nim
** Nim commands (start with =m=):
| Key Binding | Description |
|-------------+----------------------------|
| ~SPC m c r~ | nim compile --run main.nim |
| Key Binding | Description |
|--------------------+----------------------------|
| ~SPC m c r~ | nim compile --run main.nim |
| ~SPC g g~ or ~M-.~ | Jump to definition |
| ~SPC g b~ or ~M-,~ | Jump back |
|--------------------+----------------------------|

View File

@ -5,7 +5,8 @@
nim-mode))
(defun nim/post-init-company ()
(spacemacs|add-company-hook nim-mode))
(spacemacs|add-company-hook nim-mode)
(spacemacs|add-company-hook nimscript-mode))
(defun nim/post-init-flycheck ()
(spacemacs/add-flycheck-hook 'nim-mode))
@ -17,12 +18,17 @@
(defun nim/init-nim-mode ()
(use-package nim-mode
:defer t
:init (when (configuration-layer/package-usedp 'company)
(push 'company-nim company-backends-nim-mode))
:init
(when (configuration-layer/package-usedp 'company)
(push 'company-capf company-backends-nim-mode))
(add-hook 'nim-mode-hook 'nimsuggest-mode)
:config
(progn
(defun spacemacs/nim-compile-run ()
(interactive)
(shell-command "nim compile --run main.nim"))
(spacemacs/set-leader-keys-for-major-mode 'nim-mode
"cr" 'spacemacs/nim-compile-run))))
"cr" 'spacemacs/nim-compile-run
"gg" 'nimsuggest-find-definition
"gb" 'pop-tag-mark))))