Skip to content

Commit

Permalink
Use autoload for lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
yuutayamada committed Sep 7, 2016
1 parent 4b17ee4 commit 12729e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions flycheck-nimsuggest.el
Expand Up @@ -29,7 +29,9 @@

(require 'flycheck)
(require 'cl-lib)
(require 'nim-suggest)

(autoload 'nim-call-epc "nim-suggest")
(autoload 'nim-suggest-available-p "nim-suggest")

(defvar flycheck-nimsuggest-patterns
(mapcar (lambda (p)
Expand Down Expand Up @@ -65,6 +67,13 @@ CALLBACK is the status callback passed by Flycheck."
;; TODO: add proper error handler
(error (funcall callback 'errored err)))))))

;;;###autoload
(defun flycheck-nimsuggest-setup ()
"Setup flycheck configuration for nimsuggest."
(when (and (bound-and-true-p nim-use-flycheck-nimsuggest)
(not flycheck-checker))
(flycheck-select-checker 'nim-nimsuggest)))

;;;###autoload
(eval-after-load "flycheck"
'(progn
Expand All @@ -74,8 +83,9 @@ CALLBACK is the status callback passed by Flycheck."
See URL `https://github.com/nim-lang/nimsuggest'."
:start 'flycheck-nim-nimsuggest-start
:modes '(nim-mode nimscript-mode)
:predicate (lambda () (and (nim-suggest-available-p)
nim-use-flycheck-nimsuggest)))
:predicate (lambda () (and
(bound-and-true-p nim-use-flycheck-nimsuggest)
(nim-suggest-available-p))))

(add-to-list 'flycheck-checkers 'nim-nimsuggest)))

Expand Down
1 change: 1 addition & 0 deletions nim-eldoc.el
Expand Up @@ -39,6 +39,7 @@
symbol-end (0+ " "))
(group line-start (0+ " ")))))

;;;###autoload
(defun nim-eldoc-function ()
"Return a doc string appropriate for the current context, or nil."
(interactive)
Expand Down

0 comments on commit 12729e9

Please sign in to comment.