An emacs major mode for the Nim programming language
Emacs Lisp Nimrod Makefile
Latest commit 2ddac4f Oct 2, 2016 @yuutayamada yuutayamada committed on GitHub Merge pull request #144 from nim-lang/minor-update
Minor update
Permalink
Failed to load latest commit information.
tests Remove ob-nim. Jul 29, 2016
.gitignore first test running - for #30 Jun 25, 2015
.travis.yml Revert travis changes too Jul 29, 2016
Cask Use nim-capf instead of company-nim Sep 7, 2016
Makefile Fix Makefile (use quotes instead of backquotes) Aug 17, 2015
README.md Update README.md Oct 2, 2016
company-nim.el Delete needless obsolete variables definition Sep 7, 2016
contributing.md rewording of the contributing.md file Apr 17, 2016
flycheck-nimsuggest.el Use `autoload` for lazy loading Sep 7, 2016
nim-capf.el Add a hook to use suggestion-box later Sep 27, 2016
nim-compile.el Modify default compile command Jul 23, 2016
nim-eldoc.el Update pragma keywords and eldoc support for it Sep 13, 2016
nim-fill.el nim-indent-line -> nim--indent-line-core Jan 24, 2016
nim-helper.el Use when-let Sep 14, 2016
nim-mode.el Use define-key instead of advising function Sep 10, 2016
nim-rx.el Apply highlight non-case-sensitive and ignore underscores Feb 19, 2016
nim-smie.el Apply indentation of `concept` Jun 18, 2016
nim-suggest.el Attach frame number to nimsuggest's dirty directory Oct 1, 2016
nim-syntax.el Update pragma keywords and eldoc support for it Sep 13, 2016
nim-thing-at-point.el Remove cl.el dependency Nov 25, 2015
nim-util.el Delete needless variable declaration Jan 24, 2016
nim-vars.el Add a hook to use suggestion-box later Sep 27, 2016
nimscript-mode.el Add syntax-table for nimscript-mode Aug 27, 2016
starterKit.nims Refactor sterterkit.nims Apr 7, 2016

README.md

nim-mode Travis CI

A major mode for editing Nim source code

Note (9/5/2016)

company-mode's configuration (adding company-backends) is no longer required for auto-completion. capf (completion-at-point-function), which is Emacs's default feature was added and company-mode also support this feature as backend for auto-completion.

So, you can remove below configuration if you have:

(add-to-list 'company-backends
               '(company-nim :with company-nim-builtin))

Also nimsuggest-mode was newly added. So if you were already using nim-mode, please take a look nimsuggest's installing section to activate nimsuggest-mode.

Installation

  • Install nim-mode.el via MELPA.
    • Check the MELPA's link and add the package archive if you don't set yet
    • M-x list-packages opens the list of all packages (M is the emacs name for Alt)
    • C-s nim-mode moves cursor to nim mode
    • ESC ends search
    • i tags for install
    • x executes install
    • y to confirm question

Please take a look next Nimsuggest section if you interested in editor integration like completion, jump-to-definition, or linting.

Nimsuggest

(if you are impatient, skip until install nimsuggest to install it)

Nimsuggest is an editor agnostic tool for Nim and nim-mode provides:

  1. Completion feature -- C-M-i and M-TAB keys and auto-complete feature if you install company-mode
  2. Asynchronous linting -- nimsuggest take care .nims files as configuration file, so it's smarter than nim check command (1)
  3. Showing info under the cursor in minibuffer -- (1)
  4. Jump to definition feature -- M-. for go to def and M-, for back to before the go to def position

(1): those are automatically turned on if you turned on nimsuggest-mode

install nimsuggest

  1. Use stable version: See official download instruction at "Installation based on generated C code" section.

  2. Use latest version: This way may or may not work (depending on Nim or nimsuggest's state and we can't support all the way), so use above way if you prefer stable.

    git clone https://github.com/nim-lang/nimsuggest.git
    cd /path/to/nimsuggest_repository
    nim e compile_without_nimble.nims

After you installed nimsuggest, you may need following configuration in your emacs configuration file (e.g, ~/.emacs.d/init.el):

(setq nim-nimsuggest-path "path/to/nimsuggest")
;; Currently nimsuggest doesn't support nimscript files, so only nim-mode...
(add-hook 'nim-mode-hook 'nimsuggest-mode)
;; if you installed company-mode (optional)
(add-hook 'nim-mode-hook 'company-mode)
(add-hook 'nimscript-mode-hook 'company-mode)
;; or use below instead if you want to activate `company-mode` all programming
;; related modes.
;; (add-hook 'prog-mode-hook 'company-mode)

Note that above nim-nimsuggest-path variable is automatically set the result of (executable-find "nimsuggest"), so if you can get value from the executable-find, you may not need that configuration unless you want to set specific version of nimsuggest.

Other convenience packages for editing Nim source code

Those packages are convenience packages and can be installed same way as nim-mode (M-x list-packages ...)

auto-indent mode

If you use auto-indent-mode, you need to add nim-mode to the list of auto-indent-multiple-indent-modes:

(add-to-list 'auto-indent-multiple-indent-modes 'nim-mode)