branch: elpa/flymake-collection commit ea27edfb85830ea6660b4f0aa992c8f84d32101d Author: Mohsin Kaleem <mohk...@kisara.moe> Commit: Mohsin Kaleem <mohk...@kisara.moe>
(flymake-rest-hook-langs): Add file --- README.org | 55 ++++++++++++++++++++------------- flymake-rest-hook-langs.el | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 21 deletions(-) diff --git a/README.org b/README.org index fb2c84abfd..c671b6f675 100644 --- a/README.org +++ b/README.org @@ -20,6 +20,7 @@ as possible. - [[#straight][straight]] - [[#configurations][Configurations]] - [[#contributing][Contributing]] +- [[#appendix][Appendix]] * Installation ** Manually @@ -58,7 +59,7 @@ as possible. flymake-diagnostic-functions without any extra configuration or loading being needed. -*** Automatically Hooking a Checker to a Major Mode +*** Associating Checkers with Major Modes ~flymake-rest~ provides a special configuration variable to let you associate diagnostic functions with major-modes. This can be useful both for automatically enabling diagnostic functions and for interactively toggling them based on your @@ -89,32 +90,44 @@ as possible. *Note*: The ~executable-find~ predicate example here is redundant, each checker will already make sure any dependent executables are installed before being run. - To automatically enable diagnostic functions based on ~flymake-rest-config~ you - have to call the ~flymake-rest-hook-setup~ function. - This can be done through ~use-package~, for example: + Lastly there's also a ~use-package~ keyword you can use to define config + entries. This is just syntax sugar over pushing these values into + ~flymake-rest-config~ as shown above. + #+begin_src emacs-lisp - (use-package flymake-rest - :hook (after-init . flymake-rest-hook-setup)) + (use-package python-mode + :flymake-hook + (python-mode + flymake-rest-mypy ; Always added to diagnostic functions. + (flymake-rest-pycodestyle :disabled t) ; Never added. + (flymake-rest-pylint ; Added when predicate is true. + :predicate (lambda () + (executable-find "pylint")))))) #+end_src - You can also interactively enable or disable a diagnostic-function from - ~flymake-rest-config~ using the ~flymake-rest-change-checker~ command. +**** Automatically Enabling Syntax Checkers + To automatically enable diagnostic functions based on ~flymake-rest-config~ you + have to call the ~flymake-rest-hook-setup~ function. + This can be done through ~use-package~, for example: + #+begin_src emacs-lisp + (use-package flymake-rest + :hook (after-init . flymake-rest-hook-setup)) + #+end_src - Lastly there's also a ~use-package~ keyword you can use to define config - entries. - - #+begin_src emacs-lisp - (use-package python-mode - :flymake-hook - (python-mode - flymake-rest-mypy ; Always added to diagnostic functions. - (flymake-rest-pycodestyle :disabled t) ; Never added. - (flymake-rest-pylint ; Added when predicate is true. - :predicate (lambda () - (executable-find "pylint")))))) - #+end_src + You can also interactively enable or disable a diagnostic-function from + ~flymake-rest-config~ using the ~flymake-rest-change-checker~ command. + + *Note*: The default value for ~flymake-rest-config~ is empty, however a list of + recommended associations can be set by requiring ~flymake-rest-hook-langs~. * Contributing Please do!. There are more linters out there than I have the time to explore, if you'd like to add support for a new linter or contribute improvements to an existing one, we'd be more than happy to accept. + +* Appendix :ARCHIVE: +# LocalWords: flymake + +# Local Variables: +# eval: (toc-org-mode 1) +# End: diff --git a/flymake-rest-hook-langs.el b/flymake-rest-hook-langs.el new file mode 100644 index 0000000000..308cd6b7e0 --- /dev/null +++ b/flymake-rest-hook-langs.el @@ -0,0 +1,77 @@ +;;; flymake-rest-hook-langs.el --- Default mode associations for `flymake-rest-hook' -*- lexical-binding: t -*- + +;; Copyright (c) 2021 Mohsin Kaleem + +;; Permission is hereby granted, free of charge, to any person obtaining a copy +;; of this software and associated documentation files (the "Software"), to deal +;; in the Software without restriction, including without limitation the rights +;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +;; copies of the Software, and to permit persons to whom the Software is +;; furnished to do so, subject to the following conditions: + +;; The above copyright notice and this permission notice shall be included in all +;; copies or substantial portions of the Software. + +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. + + +;;; Commentary: + +;; This file sets the default associations for `flymake-rest-config' for all +;; supported major-modes. This is an opinionated section with certain checkers +;; enabled or disabled based on personal preference, which is why it's not +;; loaded by default. Use this when you don't want to setup mode->checker +;; associations yourself. + +;;; Code: + +(require 'flymake-rest-hook) + +(setq flymake-rest-config + (append + '((python-mode + flymake-rest-pycodestyle + (flymake-mypy :disabled t) + (flymake-rest-pylint :disabled t)) + (awk-mode flymake-rest-awk-gawk) + (c-mode + flymake-rest-clang + (flymake-rest-gcc :disabled t)) + (c++-mode + flymake-rest-clang + (flymake-rest-gcc :disabled t)) + (js-mode flymake-rest-eslint) + (js2-mode flymake-rest-eslint) + (typescript-mode flymake-rest-eslint) + (json-mode + flymake-rest-jq + (flymake-rest-jsonlint :disabled t)) + (less-mode flymake-rest-less) + (markdown-mode + flymake-rest-markdownlint + flymake-rest-proselint) + (lua-mode + flymake-rest-luacheck + (flymake-rest-lua :disabled t)) + (sql-mode + flymake-rest-sql-lint + (flymake-rest-sqlint :disabled t)) + (ruby-mode flymake-rest-rubocop) + ;; (hledger-mode flymake-rest-hledger) + (sh-mode flymake-rest-shellcheck) + (yaml-mode flymake-rest-yamllint) + (web-mode flymake-rest-html-tidy) + (org-mode flymake-rest-proselint) + (notmuch-message-mode flymake-rest-proselint) + (nxml-mode flymake-rest-xmllint)) + flymake-rest-config)) + +(provide 'flymake-rest-hook-langs) + +;;; flymake-rest-hook-langs.el ends here