2015-12-02 14:23:39 +00:00
|
|
|
#+TITLE: Nim layer
|
2015-07-24 11:16:06 +00:00
|
|
|
|
2019-05-07 08:53:56 +00:00
|
|
|
#+TAGS: general|layer|multi-paradigm|programming
|
2019-05-05 17:26:40 +00:00
|
|
|
|
2015-07-24 11:16:06 +00:00
|
|
|
[[file:img/logo.png]]
|
|
|
|
|
2019-05-07 20:05:06 +00:00
|
|
|
* Table of Contents :TOC_5_gh:noexport:
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#description][Description]]
|
2018-01-07 22:26:54 +00:00
|
|
|
- [[#features][Features:]]
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#install][Install]]
|
2020-07-21 20:58:52 +00:00
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#choosing-a-backend][Choosing a backend]]
|
2020-08-07 11:44:44 +00:00
|
|
|
- [[#company-vim][Company-vim]]
|
2020-07-21 20:58:52 +00:00
|
|
|
- [[#lsp][LSP]]
|
|
|
|
- [[#key-bindings][Key bindings]]
|
2015-07-24 11:16:06 +00:00
|
|
|
|
|
|
|
* Description
|
2018-01-07 22:26:54 +00:00
|
|
|
This layer adds support for the multi-paradigm language =Nim=.
|
2015-07-24 11:16:06 +00:00
|
|
|
|
2018-01-07 22:26:54 +00:00
|
|
|
** Features:
|
2020-07-21 20:58:52 +00:00
|
|
|
- Auto-completion
|
|
|
|
- Syntax-checking
|
2016-09-15 11:04:48 +00:00
|
|
|
- Jump to definition.
|
2015-07-24 11:16:06 +00:00
|
|
|
|
|
|
|
* Install
|
2016-01-06 05:21:55 +00:00
|
|
|
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.
|
2015-07-24 11:16:06 +00:00
|
|
|
|
2016-09-15 11:04:48 +00:00
|
|
|
For syntax checking, the =syntax-checking= layer must also be added.
|
|
|
|
|
2020-07-21 20:58:52 +00:00
|
|
|
* Configuration
|
|
|
|
All layer configurations can be done by setting layer variables in your dotfile.
|
|
|
|
No custom user config lines are necessary
|
2016-09-15 11:04:48 +00:00
|
|
|
|
2020-07-21 20:58:52 +00:00
|
|
|
** Choosing a backend
|
|
|
|
This layer provides two alternative backends to choose from.
|
2016-04-13 03:31:38 +00:00
|
|
|
|
2020-07-21 20:58:52 +00:00
|
|
|
*** Company-vim
|
|
|
|
This is the default choice if nothing is set and no lsp layer
|
|
|
|
is loaded in your dotfile. This mode only provides very
|
|
|
|
limited IDE capabilities. Used best if only small scripts
|
|
|
|
are edited. To set explicitly set the following in your
|
|
|
|
dotfile:
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(nim :variables nim-backend 'company-nim)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** LSP
|
|
|
|
For proper IDE support this backend should be used. It is
|
|
|
|
based on an external server which will be started automatically
|
|
|
|
by emacs, once a nim file is opened. The key bindings are
|
|
|
|
the same for all lsp modes so if you are already familiar with
|
|
|
|
one you should be able to work the same in all modes.
|
|
|
|
|
|
|
|
To set explicitly do the following in your dotfile:
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(nim :variables
|
|
|
|
nim-backend 'lsp)
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
For this to work you will also need to install the
|
|
|
|
latest version of the lsp server by running:
|
|
|
|
|
|
|
|
#+BEGIN_SRC sh
|
2020-08-07 11:44:44 +00:00
|
|
|
nimble install nimlsp
|
2020-07-21 20:58:52 +00:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Should this not work than further instructions can
|
|
|
|
be obtained from [[https://github.com/PMunch/nimlsp][here]].
|
|
|
|
|
|
|
|
NOTE: Key bindings for LSP are defined in the
|
|
|
|
LSP layer. Also it is advisable to have a look
|
|
|
|
at the autocomplete layer for an optimal
|
|
|
|
intellisense config for LSP.
|
|
|
|
|
|
|
|
* Key bindings
|
|
|
|
|
|
|
|
| Key binding | Description |
|
|
|
|
|-------------+------------------------------|
|
|
|
|
| ~SPC m c r~ | =nim compile --run main.nim= |
|
|
|
|
| ~SPC m g b~ | Jump back |
|
|
|
|
| ~SPC m h h~ | Show symbol's documentation |
|
|
|
|
|-------------+------------------------------|
|