Open mohkale opened 3 years ago
I just use compile
instead of nim-compile
because of problems like this. Here is how it works:
(defun arne--get-nim-compile-command ()
"Calculate a good default compile command for Nim."
(let ((koch-dir (locate-dominating-file buffer-file-name "koch.nim"))
(nimble-dir (arne--locate-dominating-nimble-file)))
(cond
(koch-dir ;; in the compiler
(concat
"cd "
(shell-quote-argument
(file-relative-name koch-dir))
(cond ;; is test file in the test folder?
((string-match "^tests/.*/t[^/]*.nims?$" (file-relative-name buffer-file-name koch-dir))
"; testament/testament run ")
((string-match "nimsuggest/tests/t[^/]*.nim$" (file-relative-name buffer-file-name koch-dir))
"; nimsuggest/tester ")
(t
"; nim c -r "))
(shell-quote-argument
(file-relative-name buffer-file-name koch-dir))))
((string-match "\\.nims$" buffer-file-name)
(concat "nim e "
(shell-quote-argument
(file-relative-name buffer-file-name))))
(t
(concat "nim c -r "
(shell-quote-argument
(file-relative-name buffer-file-name)))))))-name buffer-file-name)))))))
[...]
;; in arne--init-nim-mode
(setq-local compile-command (arne--get-nim-compile-command))
I did not minify arne--get-nim-compile-command
though at all. You can make it much smaller and you probably should.
Basic Info
Linux mk-desktop 5.9.14-arch1-1 #1 SMP PREEMPT Sat, 12 Dec 2020 14:37:12 +0000 x86_64 GNU/Linux
GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3) of 2020-08-28
Nim Compiler Version 1.4.2 [Linux: amd64]
Nim Compiler Version 1.4.2 [Linux: amd64]
, but I'm using nimlsp with eglot instead of this.*Messages*
README read?
Yes
Problem
When I run
nim-compile
nim just echos something goes wrong and nothing happend. I think this is because ofnim-compile--assert
.https://github.com/nim-lang/nim-mode/blob/d832d6b1fb5e69fedcdddf442d62251dd0f1f489/nim-compile.el#L136-L140
I'm pretty sure that first
and
is supposed to be anor
(use the current commandor
read a new one when the current one isn't given) and the latter case just seems to check whethercompilation-read-command
is bound and return but it doesn't actually read the command.This alternative implementation works for me: