Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proselint layer #5403

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions layers/proselint/README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#+TITLE: proselint layer
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../css/readtheorg.css" />

#+CAPTION: logo

# The maximum height of the logo should be 200 pixels.
[[img/proselint.png]]

* Table of Contents :TOC_4_org:noexport:
- [[Description][Description]]
- [[Install][Install]]
- [[Key bindings][Key bindings]]

* Description

This layer hooks [[https://github.com/amperser/proselint][proselint]] into flycheck to making typing go good, obviously.

While flycheck-proselint is enabled (via the toggle or the config var), it
will take precedence and be the ONLY functioning flycheck checker. Toggling
it off will return the normal flycheck functioning to the buffer.

It is possible to manually change this behavior using the
`flycheck-add-next-checker` function.

* Install

Install the proselint executable. Make sure it is in your $PATH.

#+begin_src sh
pip install proselint
#+end_src

Add the following to your =~/.spacemacs=

#+begin_src emacs-lisp
(setq-default dotspacemacs-configuration-layers '(proselint))
#+end_src

You may have proselint available but not started immediately by setting the
`enable-proselint-feedback` variable to `nil`.

#+begin_src emacs-lisp
(setq-default dotspacemacs-configuration-layers '(proselint :variables
enable-proselint-feedback nil))
#+end_src

* Key bindings

| Key Binding | Description |
|--------------+--------------------------------------------------- |
| ~<SPC> t P~ | Toggles the proselint flycheck feedback on and off |

15 changes: 15 additions & 0 deletions layers/proselint/config.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
;;; packages.el --- proselint layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Chris Ewald <chrisewald@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defvar enable-proselint-feedback t
"Non-nil if proselint feedback should be started automatically.")

;; (length flycheck-checkers)
45 changes: 45 additions & 0 deletions layers/proselint/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
;;; packages.el --- proselint layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Chris Ewald <chrisewald@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(defconst proselint-packages
'(flycheck))

(defun proselint/post-init-flycheck ()

(defun flycheck-proselint-enabled-p ()
enable-proselint-feedback)

(flycheck-define-checker proselint
"A linter for prose."
:command ("proselint" source-inplace)
:error-patterns
((warning line-start (file-name) ":" line ":" column ": "
(id (one-or-more (not (any " "))))
(message (one-or-more not-newline)
(zero-or-more "\n" (any " ") (one-or-more not-newline)))
line-end))
:predicate flycheck-proselint-enabled-p)
;; :modes (text-mode markdown-mode gfm-mode))

(add-to-list 'flycheck-checkers 'proselint)

(spacemacs|add-toggle flycheck-proselint
:status enable-proselint-feedback
:on (progn
(setq enable-proselint-feedback t)
(flycheck-buffer))
:off (progn
(setq enable-proselint-feedback nil)
(flycheck-buffer))
:documentation "Better writing with proselint feedback."
:evil-leader "tP"))

;;; packages.el ends here