summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-05-01 18:40:00 +0300
committerLars Wirzenius <liw@liw.fi>2020-05-01 18:40:00 +0300
commit14f8be35d9b5fd234a29f84f1840798fd0b40a97 (patch)
tree3120245efea294ff296d1c1e1f2a6e7c395748bc
parent4b4a311d4bf779608fd7f45810e5e25ac90bb1c9 (diff)
downloadliw-dot-files-14f8be35d9b5fd234a29f84f1840798fd0b40a97.tar.gz
Add: flycheck modes
-rw-r--r--emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-autoloads.el39
-rw-r--r--emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-pkg.el2
-rw-r--r--emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line.el162
-rw-r--r--emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-autoloads.el30
-rw-r--r--emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-pkg.el2
-rw-r--r--emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust.el210
6 files changed, 445 insertions, 0 deletions
diff --git a/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-autoloads.el b/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-autoloads.el
new file mode 100644
index 0000000..00824ad
--- /dev/null
+++ b/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-autoloads.el
@@ -0,0 +1,39 @@
+;;; flycheck-color-mode-line-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+ (or (file-name-directory #$) (car load-path))))
+
+
+;;;### (autoloads nil "flycheck-color-mode-line" "flycheck-color-mode-line.el"
+;;;;;; (0 0 0 0))
+;;; Generated autoloads from flycheck-color-mode-line.el
+
+(autoload 'flycheck-color-mode-line-mode "flycheck-color-mode-line" "\
+Minor mode to color the mode line with the Flycheck status.
+
+When called interactively, toggle
+`flycheck-color-mode-line-mode'. With prefix ARG, enable
+`flycheck-color-mode-line-mode' if ARG is positive, otherwise
+disable it.
+
+When called from Lisp, enable `flycheck-color-mode-line-mode' if ARG is omitted,
+nil or positive. If ARG is `toggle', toggle `flycheck-color-mode-line-mode'.
+Otherwise behave as if called interactively.
+
+\(fn &optional ARG)" t nil)
+
+(custom-add-frequent-value 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flycheck-color-mode-line" '("flycheck-color-mode-line-")))
+
+;;;***
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; flycheck-color-mode-line-autoloads.el ends here
diff --git a/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-pkg.el b/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-pkg.el
new file mode 100644
index 0000000..0d5d5a4
--- /dev/null
+++ b/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line-pkg.el
@@ -0,0 +1,2 @@
+;;; -*- no-byte-compile: t -*-
+(define-package "flycheck-color-mode-line" "20171122.707" "Change mode line color with Flycheck status" '((flycheck "0.15") (dash "1.2") (emacs "24.1")) :commit "cc474804d4e8088a627485faaf4217a5781aec7d" :keywords '("convenience" "language" "tools") :authors '(("Sylvain Benner" . "sylvain.benner@gmail.com")) :maintainer '("Sylvain Benner" . "sylvain.benner@gmail.com"))
diff --git a/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line.el b/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line.el
new file mode 100644
index 0000000..930fea8
--- /dev/null
+++ b/emacs.d/elpa/flycheck-color-mode-line-20171122.707/flycheck-color-mode-line.el
@@ -0,0 +1,162 @@
+;;; flycheck-color-mode-line.el --- Change mode line color with Flycheck status -*- lexical-binding: t -*-
+
+;; Copyright (c) 2013 Sylvain Benner <sylvain.benner@gmail.com>
+;;
+;; Author: Sylvain Benner <sylvain.benner@gmail.com>
+;; Keywords: convenience language tools
+;; Package-Version: 20171122.707
+;; Version: 0.3
+;; Package-Requires: ((flycheck "0.15") (dash "1.2") (emacs "24.1"))
+
+;; This file is not part of GNU Emacs.
+
+;; This program 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 of the License, or
+;; (at your option) any later version.
+
+;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Colorize the mode line according to the Flycheck status.
+;;
+;; This package provides the `flycheck-color-mode-line-mode' minor mode which
+;; changes the color of the mode line according to the status of Flycheck syntax
+;; checking.
+;;
+;; To enable this mode in Flycheck, add it to `flycheck-mode-hook':
+;;
+;; (add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
+;;
+;; Thanks go to:
+;; - Thomas Järvstrand (tjarvstrand) for the initial code from the excellent
+;; EDTS package
+;; - Sebastian Wiesner (lunaryorn) for flycheck and his awesome support.
+
+;;; Code:
+
+(require 'dash)
+(require 'flycheck)
+(require 'face-remap)
+
+;;;; Customization
+(defface flycheck-color-mode-line-error-face
+ '((t :inherit flycheck-fringe-error))
+ "Face remapping for the modeline in buffers with Flycheck errors.
+This is applied to the face named in `flycheck-color-mode-line-face-to-color'."
+ :group 'flycheck-faces)
+
+(defface flycheck-color-mode-line-warning-face
+ '((t :inherit flycheck-fringe-warning))
+ "Face remapping for the modeline in buffers with only Flycheck warnings.
+This is applied to the face named in `flycheck-color-mode-line-face-to-color'."
+ :group 'flycheck-faces)
+
+(defface flycheck-color-mode-line-info-face
+ '((t :inherit flycheck-fringe-info))
+ "Face remapping for the modeline in buffers with only Flycheck info.
+This is applied to the face named in `flycheck-color-mode-line-face-to-color'."
+ :group 'flycheck-faces)
+
+(defface flycheck-color-mode-line-success-face
+ '((t))
+ "Face remapping for the modeline in buffers with no Flycheck feedback items.
+This is applied to the face named in `flycheck-color-mode-line-face-to-color'.
+Customize this to actively mark buffers in which Flycheck has run
+but not reported any issues."
+ :group 'flycheck-faces)
+
+(defcustom flycheck-color-mode-line-show-running t
+ "When non-nil, apply `flycheck-color-mode-line-running-face' when Flycheck is running."
+ :type 'boolean)
+
+(put 'flycheck-color-mode-line-show-running 'safe-local-variable 'booleanp)
+
+(defface flycheck-color-mode-line-running-face
+ '((t :inherit font-lock-comment-face))
+ "Face remapping for the modeline in buffers where Flycheck is running.
+This is applied to the face named in `flycheck-color-mode-line-face-to-color'."
+ :group 'flycheck-faces)
+
+(defcustom flycheck-color-mode-line-face-to-color
+ 'mode-line
+ "Symbol identifying which face to remap.
+While 'mode-line is the default, you might prefer to modify a
+different face, e.g. 'mode-line-buffer-id, 'fringe, 'line-number or 'linum."
+ :type 'symbol
+ :group 'flycheck-faces)
+
+;;;; Modeline face remapping
+(defvar-local flycheck-color-mode-line-cookie nil
+ "Cookie for the remapped modeline face.
+
+Used to restore the original mode line face.")
+
+(defun flycheck-color-mode-line-reset ()
+ "Reset the mode line face."
+ (when flycheck-color-mode-line-cookie
+ (face-remap-remove-relative flycheck-color-mode-line-cookie)
+ (setq flycheck-color-mode-line-cookie nil)))
+
+(defun flycheck-color-mode-line-update (status)
+ "Update the mode line face according to the Flycheck STATUS."
+ (let ((face (pcase status
+ (`finished
+ (cond
+ ((flycheck-has-current-errors-p 'error)
+ 'flycheck-color-mode-line-error-face)
+ ((flycheck-has-current-errors-p 'warning)
+ 'flycheck-color-mode-line-warning-face)
+ ((flycheck-has-current-errors-p 'info)
+ 'flycheck-color-mode-line-info-face)
+ (t
+ 'flycheck-color-mode-line-success-face)))
+ (`running
+ (when flycheck-color-mode-line-show-running
+ 'flycheck-color-mode-line-running-face)))))
+ (when face
+ (flycheck-color-mode-line-reset)
+ (setq flycheck-color-mode-line-cookie
+ (face-remap-add-relative flycheck-color-mode-line-face-to-color face)))))
+
+;;;###autoload
+(define-minor-mode flycheck-color-mode-line-mode
+ "Minor mode to color the mode line with the Flycheck status.
+
+When called interactively, toggle
+`flycheck-color-mode-line-mode'. With prefix ARG, enable
+`flycheck-color-mode-line-mode' if ARG is positive, otherwise
+disable it.
+
+When called from Lisp, enable `flycheck-color-mode-line-mode' if ARG is omitted,
+nil or positive. If ARG is `toggle', toggle `flycheck-color-mode-line-mode'.
+Otherwise behave as if called interactively."
+ :init-value nil
+ :keymap nil
+ :lighter nil
+ :group 'flycheck
+ :require 'flycheck-color-mode-line
+ (cond
+ (flycheck-color-mode-line-mode
+ (add-hook 'flycheck-status-changed-functions
+ #'flycheck-color-mode-line-update nil t)
+ (flycheck-color-mode-line-update 'unknown))
+ (:else
+ (remove-hook 'flycheck-status-changed-functions
+ #'flycheck-color-mode-line-update t)
+
+ (flycheck-color-mode-line-reset))))
+
+;;;###autoload
+(custom-add-frequent-value 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
+
+(provide 'flycheck-color-mode-line)
+
+;;; flycheck-color-mode-line.el ends here
diff --git a/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-autoloads.el b/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-autoloads.el
new file mode 100644
index 0000000..8ec491f
--- /dev/null
+++ b/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-autoloads.el
@@ -0,0 +1,30 @@
+;;; flycheck-rust-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+ (or (file-name-directory #$) (car load-path))))
+
+
+;;;### (autoloads nil "flycheck-rust" "flycheck-rust.el" (0 0 0 0))
+;;; Generated autoloads from flycheck-rust.el
+
+(autoload 'flycheck-rust-setup "flycheck-rust" "\
+Setup Rust in Flycheck.
+
+If the current file is part of a Cargo project, configure
+Flycheck according to the Cargo project layout.
+
+\(fn)" t nil)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flycheck-rust" '("flycheck-rust-")))
+
+;;;***
+
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; flycheck-rust-autoloads.el ends here
diff --git a/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-pkg.el b/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-pkg.el
new file mode 100644
index 0000000..152631d
--- /dev/null
+++ b/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust-pkg.el
@@ -0,0 +1,2 @@
+;;; -*- no-byte-compile: t -*-
+(define-package "flycheck-rust" "20190319.1546" "Flycheck: Rust additions and Cargo support" '((emacs "24.1") (flycheck "28") (dash "2.13.0") (seq "2.3") (let-alist "1.0.4")) :commit "a139cd53c5062697e9ed94ad80b803c37d999600" :keywords '("tools" "convenience") :authors '(("Sebastian Wiesner" . "swiesner@lunaryorn.com")) :maintainer '("Sebastian Wiesner" . "swiesner@lunaryorn.com") :url "https://github.com/flycheck/flycheck-rust")
diff --git a/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust.el b/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust.el
new file mode 100644
index 0000000..c057beb
--- /dev/null
+++ b/emacs.d/elpa/flycheck-rust-20190319.1546/flycheck-rust.el
@@ -0,0 +1,210 @@
+;;; flycheck-rust.el --- Flycheck: Rust additions and Cargo support -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2016, 2017 fmdkdd
+;; Copyright (C) 2014, 2015 Sebastian Wiesner <swiesner@lunaryorn.com>
+
+;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
+;; URL: https://github.com/flycheck/flycheck-rust
+;; Package-Version: 20190319.1546
+;; Keywords: tools, convenience
+;; Version: 1.1
+;; Package-Requires: ((emacs "24.1") (flycheck "28") (dash "2.13.0") (seq "2.3") (let-alist "1.0.4"))
+
+;; This file is not part of GNU Emacs.
+
+;; This program 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 of the License, or
+;; (at your option) any later version.
+
+;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This Flycheck extension configures Flycheck automatically for the current
+;; Cargo project.
+;;
+;; # Setup
+;;
+;; (with-eval-after-load 'rust-mode
+;; (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
+;;
+;; # Usage
+;;
+;; Just use Flycheck as usual in your Rust/Cargo projects.
+
+;;; Code:
+
+(eval-when-compile
+ (require 'pcase)
+ (require 'let-alist))
+
+(require 'dash)
+(require 'flycheck)
+(require 'seq)
+(require 'json)
+
+(defun flycheck-rust-find-manifest (file-name)
+ "Get the Cargo.toml manifest for FILE-NAME.
+
+FILE-NAME is the path of a file in a cargo project given as a
+string.
+
+See http://doc.crates.io/guide.html for an introduction to the
+Cargo.toml manifest.
+
+Return the path to the Cargo.toml manifest file, or nil if the
+manifest could not be located."
+ (-when-let (root-dir (locate-dominating-file file-name "Cargo.toml"))
+ (expand-file-name "Cargo.toml" root-dir)))
+
+(defun flycheck-rust-dirs-list (start end)
+ "Return a list of directories from START (inclusive) to END (exclusive).
+
+E.g., if START is '/a/b/c/d' and END is '/a', return the list
+'(/a/b/c/d /a/b/c /a/b) in this order.
+
+START and END are strings representing file paths. END should be
+above START in the file hierarchy; if not, the list stops at the
+root of the file hierarchy."
+ (let ((dirlist)
+ (dir (expand-file-name start))
+ (end (expand-file-name end)))
+ (while (not (or (equal dir (car dirlist)) ; avoid infinite loop
+ (file-equal-p dir end)))
+ (push dir dirlist)
+ (setq dir (directory-file-name (file-name-directory dir))))
+ (nreverse dirlist)))
+
+(defun flycheck-rust-get-cargo-targets (manifest)
+ "Return the list of available Cargo targets for the given project.
+
+MANIFEST is the path to the Cargo.toml file of the project.
+
+Calls `cargo metadata --no-deps --manifest-path MANIFEST
+--format-version 1', parses and collects the targets for the
+current workspace, and returns them in a list, or nil if no
+targets could be found."
+ (let ((cargo (funcall flycheck-executable-find "cargo")))
+ (unless cargo
+ (user-error "flycheck-rust cannot find `cargo'. Please \
+make sure that cargo is installed and on your PATH. See \
+http://www.flycheck.org/en/latest/user/troubleshooting.html for \
+more information on setting your PATH with Emacs."))
+ ;; metadata contains a list of packages, and each package has a list of
+ ;; targets. We concatenate all targets, regardless of the package.
+ (-when-let (packages (let-alist
+ (with-temp-buffer
+ (call-process cargo nil '(t nil) nil
+ "metadata" "--no-deps"
+ "--manifest-path" manifest
+ "--format-version" "1")
+ (goto-char (point-min))
+ (let ((json-array-type 'list))
+ (json-read)))
+ .packages))
+ (seq-map (lambda (pkg)
+ (let-alist pkg .targets))
+ packages))))
+
+(defun flycheck-rust-find-cargo-target (file-name)
+ "Return the Cargo build target associated with FILE-NAME.
+
+FILE-NAME is the path of the file that is matched against the
+`src_path' value in the list of `targets' returned by `cargo
+read-manifest'.
+
+Return an alist ((KIND . k) (NAME . n) (REQUIRED-FEATURES . rf))
+where KIND is the target kind (lib, bin, test, example or bench),
+NAME the target name (usually, the crate name), and REQUIRED-FEATURES is the
+optional list of features required to build the selected target. If FILE-NAME
+exactly matches a target `src-path', this target is returned. Otherwise, return
+the closest matching target, or nil if no targets could be found.
+
+See http://doc.crates.io/manifest.html#the-project-layout for a
+description of the conventional Cargo project layout."
+ (-when-let* ((manifest (flycheck-rust-find-manifest file-name))
+ (packages (flycheck-rust-get-cargo-targets manifest))
+ (targets (-flatten-n 1 packages)))
+ (let ((target
+ (or
+ ;; If there is a target that matches the file-name exactly, pick
+ ;; that one
+ (seq-find (lambda (target)
+ (let-alist target (string= file-name .src_path)))
+ targets)
+ ;; Otherwise find the closest matching target by walking up the tree
+ ;; from FILE-NAME and looking for targets in each directory. E.g.,
+ ;; the file 'tests/common/a.rs' will look for a target in
+ ;; 'tests/common', then in 'tests/', etc.
+ (car (seq-find
+ (lambda (pair)
+ (-let [((&alist 'src_path target-path) . dir) pair]
+ (file-equal-p dir (file-name-directory target-path))))
+ ;; build a list of (target . dir) candidates
+ (-table-flat
+ 'cons targets
+ (flycheck-rust-dirs-list file-name
+ (file-name-directory manifest)))))
+ ;; If all else fails, just pick the first target
+ (car targets))))
+ ;; If target is 'custom-build', we pick another target from the same package (see GH-62)
+ (when (string= "custom-build" (let-alist target (car .kind)))
+ (setq target (->> packages
+ ;; find the same package as current build-script buffer
+ (--find (--any? (equal target it) it))
+ (--find (not (equal target it))))))
+ (when target
+ (let-alist target
+ (seq-filter (lambda (kv) (cdr kv))
+ (list (cons 'kind (flycheck-rust-normalize-target-kind .kind))
+ (cons 'name .name)
+ (cons 'required-features .required-features))))))))
+
+
+(defun flycheck-rust-normalize-target-kind (kinds)
+ "Return the normalized target name from KIND.
+
+KIND is a list of target name as returned by `cargo metadata',
+which do not necessarily correspond to to target names that can
+be passed as argument to `cargo rustc'.
+
+The normalization returns a valid cargo target based on KINDS."
+ ;; Assumption: we only care about the first kind name. Multiple kinds only
+ ;; seem to happen for library crate types, and those all maps to the same
+ ;; `lib' target.
+ (pcase (car kinds)
+ (`"dylib" "lib")
+ (`"rlib" "lib")
+ (`"staticlib" "lib")
+ (`"cdylib" "lib")
+ (`"proc-macro" "lib")
+ (_ (car kinds))))
+
+;;;###autoload
+(defun flycheck-rust-setup ()
+ "Setup Rust in Flycheck.
+
+If the current file is part of a Cargo project, configure
+Flycheck according to the Cargo project layout."
+ (interactive)
+ ;; We should avoid raising any error in this function, as in combination
+ ;; with `global-flycheck-mode' it will render Emacs unusable (see
+ ;; https://github.com/flycheck/flycheck-rust/issues/40#issuecomment-253760883).
+ (with-demoted-errors "Error in flycheck-rust-setup: %S"
+ (-when-let* ((file-name (buffer-file-name))
+ (target (flycheck-rust-find-cargo-target file-name)))
+ (let-alist target
+ (setq-local flycheck-rust-features .required-features)
+ (setq-local flycheck-rust-crate-type .kind)
+ (setq-local flycheck-rust-binary-name .name)))))
+
+(provide 'flycheck-rust)
+
+;;; flycheck-rust.el ends here