This commit is contained in:
ry
2022-01-11 18:05:13 -08:00
parent 2046befee2
commit 8e7b654716
846 changed files with 71287 additions and 4 deletions

View File

@@ -0,0 +1,52 @@
#+TITLE: :lang Nim
#+begin_quote
This module is a work in progress.
#+end_quote
This module adds [[https://nim-lang.org][Nim]] support to Emacs.
+ Code completion (nimsuggest + company)
+ Syntax checking (nimsuggest + flycheck)
+ Babel support (~ob-nim~)
* Table of Contents :TOC:
- [[#module-flags][Module Flags]]
- [[#prerequisites][Prerequisites]]
- [[#nim][Nim]]
- [[#configuration][Configuration]]
* Module Flags
This module provides no flags.
* Prerequisites
+ ~nim~ (for building & evaluation)
+ ~nimsuggest~ (for code completion, syntax checking & jump-to-definition functionality)
** Nim
=choosenim= is an installer and version manager for the Nim programming
language. You can install the latest stable release of Nim by running the
following in your terminal and following the onscreen instructions:
#+BEGIN_SRC bash
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
#+END_SRC
Alternatively, nim is usually available through your OS's package manager:
*** MacOS
#+BEGIN_SRC sh :tangle (if (doom-system-os 'macos) "yes")
brew install nim
#+END_SRC
*** Arch Linux
#+BEGIN_SRC sh :dir /sudo:: :tangle (if (doom-system-os 'arch) "yes")
sudo pacman --needed --noconfirm -S nim nimble
#+END_SRC
*** openSUSE
#+BEGIN_SRC sh :dir /sudo::
sudo zypper install nim
#+END_SRC
* Configuration

View File

@@ -0,0 +1,39 @@
;;; lang/nim/config.el -*- lexical-binding: t; -*-
(use-package! nim-mode
:defer t
:init
(add-hook! 'nim-mode-hook
(defun +nim-init-nimsuggest-mode-h ()
"Conditionally load `nimsuggest-mode', instead of clumsily erroring out if
nimsuggest isn't installed."
(unless (stringp nimsuggest-path)
(setq nimsuggest-path (executable-find "nimsuggest")))
(when (and nimsuggest-path (file-executable-p nimsuggest-path))
(nimsuggest-mode))))
(when IS-WINDOWS
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
(defadvice! +nim--suggest-get-temp-file-name-a (path)
"Removes invalid characters from the temp file path, including the unicode
character that colon is replaced with, which is known to cause issues on
windows."
:filter-return #'nimsuggest--get-temp-file-name
(replace-regexp-in-string "[* |<>\"?*]" "" path)))
:config
(set-lookup-handlers! '(nim-mode nimsuggest-mode)
:definition #'+nimsuggest-find-definition
:documentation #'nimsuggest-show-doc)
(map! :localleader
:map nim-mode-map
"b" #'nim-compile
"h" #'nimsuggest-show-doc
"d" #'nimsuggest-find-definition))
(use-package! flycheck-nim
:when (featurep! :checkers syntax)
:after nim-mode)

View File

@@ -0,0 +1,9 @@
;; -*- lexical-binding: t; no-byte-compile: t; -*-
;;; lang/nim/doctor.el
(unless (executable-find "nimsuggest")
(warn! "Could not find nimsuggest executable; code-completion, syntax checking and jump-to-definition functionality will be disabled."))
(unless (executable-find "nim")
(warn! "Could not find nim executable; build commands will be disabled."))

View File

@@ -0,0 +1,9 @@
;; -*- no-byte-compile: t; -*-
;;; lang/nim/packages.el
;;; requires nim nimsuggest nimble
(package! nim-mode :pin "744e076f0bea1c5ddc49f92397d9aa98ffa7eff8")
(when (featurep! :checkers syntax)
(package! flycheck-nim :pin "ddfade51001571c2399f78bcc509e0aa8eb752a4"))