From 5cc823cc0f2d750ecfabd01a3656ad53390b9b2e Mon Sep 17 00:00:00 2001 From: JAremko Date: Mon, 14 Jan 2019 10:19:14 +0200 Subject: [PATCH] add flycheck-clojure --- CHANGELOG.develop | 1 + layers/+lang/clojure/README.org | 14 ++++++++++++++ layers/+lang/clojure/config.el | 3 +++ layers/+lang/clojure/packages.el | 13 +++++++++++++ 4 files changed, 31 insertions(+) diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 383fc3595..4beacd71a 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -1083,6 +1083,7 @@ Other: **** Clojure - New packages: - Added =sayid= debugger (thanks to Daniel Manila and Arne Brasseur) + - Added =flycheck-clojure= linters (thanks to Eugene Yaremenko) - Improvements: - Store cider REPL history in spacemacs cache (thanks to Ryan Fowler) - Remove backtick from smartparens pairs for Clojure diff --git a/layers/+lang/clojure/README.org b/layers/+lang/clojure/README.org index 33bdf0158..8cca6b405 100644 --- a/layers/+lang/clojure/README.org +++ b/layers/+lang/clojure/README.org @@ -17,6 +17,7 @@ - [[#more-details][More details]] - [[#usage][Usage]] - [[#cheatsheet][Cheatsheet]] + - [[#linting][Linting]] - [[#structuraly-safe-editing][Structuraly safe editing]] - [[#key-bindings][Key bindings]] - [[#working-with-clojure-files-barfage-slurpage--more][Working with clojure files (barfage, slurpage & more)]] @@ -50,6 +51,7 @@ This layer adds support for [[https://clojure.org/][Clojure]] language using [[h - REPL via [[https://github.com/clojure-emacs/cider][CIDER]] - Code formatting via [[https://github.com/clojure-emacs/cider][CIDER]] using [[https://github.com/weavejester/cljfmt][Cljfmt]] - Refactoring via [[https://github.com/clojure-emacs/clj-refactor.el][clj-refactor]] +- Linting via [[https://github.com/clojure-emacs/squiggly-clojure][squiggly-clojure]] - Aligning of code forms via [[https://github.com/clojure-emacs/clojure-mode][clojure-mode]] - Debugging with [[https://github.com/clojure-emacs/sayid][sayid]] - Clojure cheatsheet @@ -186,6 +188,18 @@ Type ~SPC m h c~ to display the cheatsheet then type in some terms (space separated) to narrow down the list. For example, try typing in sort map to see some functions that deal with sorting maps. +** Linting +Linting works via flycheck and disabled by default. +You can enable it like this: + +#+BEGIN_SRC emacs-lisp + (setq clojure-enable-linters t) +#+END_SRC + +Make sure to read the [[https://github.com/clojure-emacs/squiggly-clojure#warnings][warnings section]]. +If you have a problem peek into [[https://github.com/clojure-emacs/squiggly-clojure#debugging-and-bug-reporting][debugging and bug reporting]] then try to reproduce in the [[https://github.com/clojure-emacs/squiggly-clojure/tree/master/sample-project][sample project]]. +NOTE: With the default linter configs you should add =org.clojure/core.typed= to the development dependencies. + ** Structuraly safe editing This layer adds support for =evil-cleverparens= which allows to safely edit lisp code by keeping the s-expressions balanced. diff --git a/layers/+lang/clojure/config.el b/layers/+lang/clojure/config.el index ddfd2b7d9..d0a0924b7 100644 --- a/layers/+lang/clojure/config.el +++ b/layers/+lang/clojure/config.el @@ -25,3 +25,6 @@ (defvar clojure-enable-clj-refactor nil "If non-nil, the clj-refactor is enabled.") + +(defvar clojure-enable-linters nil + "If non-nil, enable clojure linters.") diff --git a/layers/+lang/clojure/packages.el b/layers/+lang/clojure/packages.el index 3ca6dee93..da3c7958b 100644 --- a/layers/+lang/clojure/packages.el +++ b/layers/+lang/clojure/packages.el @@ -19,6 +19,8 @@ company eldoc evil-cleverparens + flycheck + (flycheck-clojure :toggle clojure-enable-linters) ggtags counsel-gtags helm-gtags @@ -162,6 +164,9 @@ ;; add support for golden-ratio (with-eval-after-load 'golden-ratio (add-to-list 'golden-ratio-extra-commands 'cider-popup-buffer-quit-function)) + ;; setup linters. NOTE: It must be done after both CIDER and Flycheck are loaded. + (when clojure-enable-linters + (with-eval-after-load 'flycheck (flycheck-clojure-setup))) ;; add support for evil (evil-set-initial-state 'cider-stacktrace-mode 'motion) (evil-set-initial-state 'cider-popup-buffer-mode 'motion) @@ -412,3 +417,11 @@ (defun clojure/post-init-parinfer () (add-hook 'clojure-mode-hook 'parinfer-mode)) + +(defun clojure/post-init-flycheck () + (spacemacs|forall-clojure-modes m + (spacemacs/enable-flycheck m))) + +(defun clojure/init-flycheck-clojure () + (use-package flycheck-clojure + :if (configuration-layer/package-usedp 'flycheck)))