Support projectile and project. projectile is optional now.

This commit is contained in:
Vincent Zhang 2018-11-12 00:48:20 +08:00
parent 3018171bc9
commit a9847abd3e
2 changed files with 17 additions and 5 deletions

View file

@ -21,6 +21,7 @@ The DOOM modeline was designed for minimalism, and offers:
- A window number segment for `ace-window`, `winum` and `window-numbering` - A window number segment for `ace-window`, `winum` and `window-numbering`
- An indicator for `evil` state - An indicator for `evil` state
- An indicator for current input method - An indicator for current input method
- Highlight project name in buffer information if `projectile` or `project` is available.
## Install ## Install

View file

@ -5,7 +5,7 @@
;; Author: Vincent Zhang <seagle0128@gmail.com> ;; Author: Vincent Zhang <seagle0128@gmail.com>
;; Homepage: https://github.com/seagle0128/doom-modeline ;; Homepage: https://github.com/seagle0128/doom-modeline
;; Version: 0.6.1 ;; Version: 0.6.1
;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (projectile "0.10.0") (shrink-path "0.2.0") (eldoc-eval "0.1") (dash "2.11.0")) ;; Package-Requires: ((emacs "25.1") (all-the-icons "1.0.0") (shrink-path "0.2.0") (eldoc-eval "0.1") (dash "2.11.0"))
;; Keywords: faces mode-line ;; Keywords: faces mode-line
;; This file is not part of GNU Emacs. ;; This file is not part of GNU Emacs.
@ -59,9 +59,10 @@
(require 'all-the-icons) (require 'all-the-icons)
(require 'eldoc-eval) (require 'eldoc-eval)
(require 'projectile)
(require 'shrink-path) (require 'shrink-path)
(require 'subr-x) (require 'subr-x)
(when (>= emacs-major-version 26)
(require 'project))
;; ;;
;; Variables ;; Variables
@ -112,6 +113,7 @@ The icons may not be showed correctly on Windows. Disable to make it work.")
(defvar flycheck-current-errors) (defvar flycheck-current-errors)
(defvar iedit-mode) (defvar iedit-mode)
(defvar iedit-occurrences-overlays) (defvar iedit-occurrences-overlays)
(defvar projectile-dynamic-mode-line)
(defvar text-scale-mode-amount) (defvar text-scale-mode-amount)
(defvar winum-auto-setup-mode-line) (defvar winum-auto-setup-mode-line)
(defvar mc/mode-line) (defvar mc/mode-line)
@ -140,6 +142,10 @@ The icons may not be showed correctly on Windows. Disable to make it work.")
(declare-function iedit-prev-occurrence 'iedit-lib) (declare-function iedit-prev-occurrence 'iedit-lib)
(declare-function image-get-display-property 'image-mode) (declare-function image-get-display-property 'image-mode)
(declare-function magit-toplevel 'magit-git) (declare-function magit-toplevel 'magit-git)
(declare-function project-current 'project)
(declare-function project-roots 'project)
(declare-function projectile-ensure-project 'projectile)
(declare-function projectile-project-root 'projectile)
(declare-function window-numbering-clear-mode-line 'window-numbering) (declare-function window-numbering-clear-mode-line 'window-numbering)
(declare-function window-numbering-get-number-string 'window-numbering) (declare-function window-numbering-get-number-string 'window-numbering)
(declare-function window-numbering-install-mode-line 'window-numbering) (declare-function window-numbering-install-mode-line 'window-numbering)
@ -329,9 +335,14 @@ active.")
`default-directory'." `default-directory'."
(if (local-variable-p 'doom-modeline-project-root) (if (local-variable-p 'doom-modeline-project-root)
doom-modeline-project-root doom-modeline-project-root
(let ((projectile-require-project-root)) (or
(when (featurep 'projectile)
(let ((projectile-require-project-root nil))
(setq doom-modeline-project-root (setq doom-modeline-project-root
(projectile-ensure-project (projectile-project-root)))))) (projectile-ensure-project (projectile-project-root)))))
(when (featurep 'project)
(when-let ((project (project-current)))
(car (project-roots project)))))))
;; Disable projectile mode-line segment ;; Disable projectile mode-line segment
(setq projectile-dynamic-mode-line nil) (setq projectile-dynamic-mode-line nil)