diff --git a/layers/+lang/nim/README.org b/layers/+lang/nim/README.org index 53864257f..2088039a4 100644 --- a/layers/+lang/nim/README.org +++ b/layers/+lang/nim/README.org @@ -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 | +|--------------------+----------------------------| diff --git a/layers/+lang/nim/packages.el b/layers/+lang/nim/packages.el index 1ef0a4471..0f833078c 100644 --- a/layers/+lang/nim/packages.el +++ b/layers/+lang/nim/packages.el @@ -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))))