2018-05-08 11:50:12 -03:00
|
|
|
|
;;; lang/nim/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
2018-05-25 00:46:11 +02:00
|
|
|
|
(after! nim-mode
|
2018-05-09 10:20:09 +02:00
|
|
|
|
(defun +nim|init-nimsuggest-mode ()
|
|
|
|
|
"Conditionally load `nimsuggest-mode', instead of clumsily erroring out if
|
|
|
|
|
nimsuggest isn't installed."
|
2018-08-30 19:42:57 +02:00
|
|
|
|
(unless (stringp nimsuggest-path)
|
|
|
|
|
(setq nimsuggest-path (executable-find "nimsuggest")))
|
|
|
|
|
(when (and nimsuggest-path (file-executable-p nimsuggest-path))
|
2018-05-09 10:20:09 +02:00
|
|
|
|
(nimsuggest-mode)))
|
|
|
|
|
(add-hook 'nim-mode-hook #'+nim|init-nimsuggest-mode)
|
2018-05-08 11:50:12 -03:00
|
|
|
|
|
2018-08-30 23:36:32 +02:00
|
|
|
|
(when IS-WINDOWS
|
|
|
|
|
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
|
|
|
|
|
(defun doom*nimsuggest--get-dirty-dir ()
|
|
|
|
|
"The original `nimsuggest--get-dirty-dir' incorrectly extracts the frame
|
2018-08-30 22:35:25 +02:00
|
|
|
|
number from the string representation of `selected-frame', which can contain
|
|
|
|
|
characters that are illegal on Windows, causing invalid argument errors when
|
|
|
|
|
`nimsuggest--make-tempdir' tries to use it."
|
2018-08-30 23:36:32 +02:00
|
|
|
|
(let* ((frame-str (format "%s" (selected-frame)))
|
|
|
|
|
(frame-num-str (if (string-match " \\(0x[0-9a-z]+\\)>$" frame-str)
|
|
|
|
|
(match-string 1 frame-str))))
|
|
|
|
|
(file-name-as-directory (concat nimsuggest-dirty-directory frame-num-str))))
|
|
|
|
|
(advice-add #'nimsuggest--get-dirty-dir :override #'doom*nimsuggest--get-dirty-dir)
|
|
|
|
|
|
|
|
|
|
;; TODO File PR/report upstream (https://github.com/nim-lang/nim-mode)
|
|
|
|
|
(defun doom*nimsuggest--get-temp-file-name (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."
|
|
|
|
|
(replace-regexp-in-string "[꞉* |<>\"?*]" "" path))
|
2018-08-31 16:07:33 +02:00
|
|
|
|
(advice-add #'nimsuggest--get-temp-file-name :filter-return #'doom*nimsuggest--get-temp-file-name))
|
2018-08-30 22:35:25 +02:00
|
|
|
|
|
2018-12-23 23:54:27 -05:00
|
|
|
|
(map! :localleader
|
|
|
|
|
:map nim-mode-map
|
|
|
|
|
"b" #'nim-compile))
|
2018-05-08 11:50:12 -03:00
|
|
|
|
|
2018-05-09 10:20:09 +02:00
|
|
|
|
|
|
|
|
|
(def-package! flycheck-nim
|
2019-02-22 00:20:29 -05:00
|
|
|
|
:when (featurep! :tools flycheck)
|
2018-06-21 15:54:36 +02:00
|
|
|
|
:after nim-mode)
|
2018-05-09 10:20:09 +02:00
|
|
|
|
|