branch: elpa/flymake-kondor commit 29f80dee6bae7bb94f8223bb51bfc9165107893a Author: ad...@turbocafe.in.eu.org <ad...@turbocafe.in.eu.org> Commit: ad...@turbocafe.in.eu.org <ad...@turbocafe.in.eu.org>
v0.0.1 --- README.org | 25 +++++++++++++++++++++ flymake-kondor.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/README.org b/README.org new file mode 100644 index 0000000..d79ca2d --- /dev/null +++ b/README.org @@ -0,0 +1,25 @@ +# -*- mode:org; ispell-dictionary:"en_GB" -*- +#+TITLE: flymake backend clj-kondo +#+AUTHOR: https://turbocafe.keybase.pub + +this package integrates clj-kondo a clojure linter into emacs' +flymake; get clj-kondo following [[https://github.com/borkdude/clj-kondo/blob/master/doc/install.md][installation instructions]]; + +this package isn't on melpa, so emacs has to load it from where i +store flymake-kondor.el, i do it with use-package, like below + +#+BEGIN_SRC emasc-lisp +(use-package flymake-kondor + :ensure flymake-quickdef + :after flymake + :load-path "~/.emacs.d/site-lisp/flymake-kondor" + :init + (add-hook 'clojure-mode-hook #'flymake-kondor-setup) + :config + (define-key flymake-mode-map (kbd "<f8>") 'flymake-goto-next-error) + (define-key flymake-mode-map (kbd "<f7>") 'flymake-goto-prev-error)) +#+END_SRC + +when in clojure-mode flymake-mode is activated and you can navigate to +prev/next error in buffer; there's [[https://github.com/borkdude/flycheck-clj-kondo][sister project]] that integrates +clj-kondo into flycheck if you use that one diff --git a/flymake-kondor.el b/flymake-kondor.el new file mode 100644 index 0000000..ffe6934 --- /dev/null +++ b/flymake-kondor.el @@ -0,0 +1,67 @@ +;;; flymake-kondor.el --- emacs linter with clj-kondo -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 https://turbocafe.keybase.pub +;; +;; Author: https://turbocafe.keybase.pub +;; Created: 3 November 2019 +;; Version: 0.0.1 +;; Package-Requires: ((flymake-quickdef "0.1.1")) + +;;; Commentary: + +;; This package adds Clojure syntax checker clj-kondo. +;; Make sure clj-kondo binary is on your path. +;; Installation instructions https://github.com/borkdude/clj-kondo/blob/master/doc/install.md + +;;; License: + +;; This file is not part of GNU Emacs. +;; However, it is distributed under the same license. + +;; GNU Emacs is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(require 'flymake-quickdef) + +(flymake-quickdef-backend flymake-kondor-backend + :pre-let ((kondor-exec (executable-find "clj-kondo"))) + :pre-check (unless kondor-exec (error "Not found clj-kondo on PATH")) + :write-type 'pipe + :proc-form (list kondor-exec "--lint" "-") + :search-regexp "^.+:\\([[:digit:]]+\\):\\([[:digit:]]+\\): \\([[:alpha:]]+\\): \\(.+\\)$" + :prep-diagnostic + (let* ((lnum (string-to-number (match-string 1))) + (lcol (string-to-number (match-string 2))) + (severity (match-string 3)) + (msg (match-string 4)) + (pos (flymake-diag-region fmqd-source lnum lcol)) + (beg (car pos)) + (end (cdr pos)) + (type (cond + ((string= severity "error") :error) + ((string= severity "warning") :warning) + ((string= severity "info") :note) + (t :note)))) + (list fmqd-source beg end type msg))) +;;;###autoload +(defun flymake-kondor-setup () + (flymake-mode t) + (add-hook 'flymake-diagnostic-functions 'flymake-kondor-backend nil t)) + +(provide 'flymake-kondor) + +;;; flymake-kondor.el ends here