Please let me know when I screwed up. I promise I will learn.
;;; wal-fix.el --- Fixing things. -*- lexical-binding: t -*-
;;; Commentary:
;;
;; Provide fixing packages.
;;; Code:
(eval-when-compile
(require 'wal-useful nil t)
(require 'wal-key-bindings nil t))
(declare-function flycheck-error-line "ext:flycheck.el")
(declare-function flycheck-error-message "ext:flycheck.el")
(declare-function wdb-nearby "wal-useful.el")
(defvar flycheck-error-list-buffer)
flymake
uses backends to check your code, one for each mode. It ships with a few (and so do some other packages like lsp-mode
).
(defvar wal-flymake-map (make-sparse-keymap))
(use-package flymake
:config
(that-key "flymake" :key "C-c f")
(defvar-keymap wal-flymake-repeat-map
:doc "Repeat map for `flymake'."
:repeat t
"n" 'flymake-goto-next-error
"p" 'flymake-goto-prev-error)
:custom
(flymake-mode-line-lighter "flm")
(flymake-indicator-type 'fringes)
:bind
(:map wal-flymake-map
("n" . flymake-goto-next-error)
("p" . flymake-goto-prev-error)
("l" . flymake-show-buffer-diagnostics))
:bind-keymap
("C-c f" . wal-flymake-map))
flycheck
is for all of our linting/code quality needs. It’s a bit easier to setup than the built-in flymake
although that one has come a long way itself.
This provides functionality to run a check on a file from a batch process.
(use-package flycheck
:init
(that-key "flycheck" :leader (ambassador :key "f"))
:config
(wdb-nearby flycheck-error-list-buffer :side 'bottom)
(defvar-keymap wal-flycheck-repeat-map
:doc "Repeat map for `flycheck'."
:repeat t
"n" 'flycheck-next-error
"p" 'flycheck-previous-error
"h" 'flycheck-display-error-at-point)
:custom
(flycheck-mode-line-prefix "flc")
(flycheck-disabled-checkers '(proselint))
(flycheck-keymap-prefix (wal-key-combo-for-leader 'ambassador :key "f" :translate t)))
Just-in-time spell-checking using enchant-2
.
(defun wal-jinx--js-import-p (start)
"Check if word at START belongs to a JavaScript import statement."
(save-excursion
(goto-char start)
(beginning-of-line)
(when (looking-at-p "^\\(import.+\\|} \\)from.+;$")
(save-match-data
(looking-at "^\\(import.+\\|} \\)from.+;$")
(match-end 0)))))
(use-package jinx
:if (executable-find "enchant-2")
:hook ((emacs-startup . global-jinx-mode)
((js-mode
js-ts-mode
typescript-mode
typescript-ts-mode
tsx-ts-mode)
.
(lambda () (setq-local jinx--predicates (append jinx--predicates (list 'wal-jinx--js-import-p))))))
:bind
(:map jinx-repeat-map
("j" . jinx-next)
("c" . jinx-correct))
:general
(editors "j" 'jinx-next 'jinx-correct)
:delight '(:eval (concat " jnx[" jinx-languages "]")))
(provide 'wal-fix)
;;; wal-fix.el ends here