277 lines
9.6 KiB
EmacsLisp
277 lines
9.6 KiB
EmacsLisp
;;; packages.el --- Spacemacs UI Layer packages File
|
|
;;
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
|
;;
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
;;
|
|
;; This file is not part of GNU Emacs.
|
|
;;
|
|
;;; License: GPLv3
|
|
|
|
(setq spacemacs-ui-packages
|
|
'(ace-link
|
|
ace-window
|
|
buffer-move
|
|
(centered-cursor :location local)
|
|
desktop
|
|
(doc-view :location built-in)
|
|
flx-ido
|
|
info+
|
|
open-junk-file
|
|
window-numbering))
|
|
|
|
;; Paradox from MELPA is not compatible with 24.3, so we use
|
|
;; a local paradox with 24.3
|
|
(if (version< emacs-version "24.4")
|
|
(push '(paradox :location local) spacemacs-ui-packages)
|
|
(push 'paradox spacemacs-ui-packages))
|
|
|
|
;; Initialization of packages
|
|
|
|
(defun spacemacs-ui/init-ace-link ()
|
|
(use-package ace-link
|
|
:commands spacemacs/ace-buffer-links
|
|
:init
|
|
(progn
|
|
(define-key spacemacs-buffer-mode-map "o" 'spacemacs/ace-buffer-links)
|
|
(with-eval-after-load 'info
|
|
(define-key Info-mode-map "o" 'ace-link-info))
|
|
(with-eval-after-load 'help-mode
|
|
(define-key help-mode-map "o" 'ace-link-help))
|
|
(with-eval-after-load 'eww
|
|
(define-key eww-link-keymap "o" 'ace-link-eww)
|
|
(define-key eww-mode-map "o" 'ace-link-eww)))
|
|
:config
|
|
(progn
|
|
(defvar spacemacs--link-pattern "~?/.+\\|\s\\[")
|
|
(defun spacemacs//collect-spacemacs-buffer-links ()
|
|
(let ((end (window-end))
|
|
points)
|
|
(save-excursion
|
|
(goto-char (window-start))
|
|
(while (re-search-forward spacemacs--link-pattern end t)
|
|
(push (+ (match-beginning 0) 1) points))
|
|
(nreverse points))))
|
|
(defun spacemacs/ace-buffer-links ()
|
|
"Ace jump to links in `spacemacs' buffer."
|
|
(interactive)
|
|
(let ((res (avy-with spacemacs/ace-buffer-links
|
|
(avy--process
|
|
(spacemacs//collect-spacemacs-buffer-links)
|
|
#'avy--overlay-pre))))
|
|
(when res
|
|
(goto-char (1+ res))
|
|
(widget-button-press (point))))))))
|
|
|
|
(defun spacemacs-ui/init-ace-window ()
|
|
(use-package ace-window
|
|
:defer t
|
|
:init
|
|
(progn
|
|
(spacemacs/set-leader-keys
|
|
"bM" 'ace-swap-window
|
|
"wC" 'ace-delete-window
|
|
"w <SPC>" 'ace-window)
|
|
;; set ace-window keys to home-row
|
|
(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)))))
|
|
|
|
(defun spacemacs-ui/init-buffer-move ()
|
|
(use-package buffer-move
|
|
:defer t
|
|
:init
|
|
(spacemacs/set-leader-keys
|
|
"bmh" 'buf-move-left
|
|
"bmj" 'buf-move-down
|
|
"bmk" 'buf-move-up
|
|
"bml" 'buf-move-right)))
|
|
|
|
(defun spacemacs-ui/init-centered-cursor ()
|
|
(use-package centered-cursor-mode
|
|
:commands (centered-cursor-mode
|
|
global-centered-cursor-mode)
|
|
:init
|
|
(progn
|
|
(spacemacs|add-toggle centered-point
|
|
:status centered-cursor-mode
|
|
:on (centered-cursor-mode)
|
|
:off (centered-cursor-mode -1)
|
|
:documentation
|
|
"Keep point at the center of the window."
|
|
:evil-leader "t-")
|
|
(spacemacs|add-toggle centered-point-globally
|
|
:status centered-cursor-mode
|
|
:on (global-centered-cursor-mode)
|
|
:off (global-centered-cursor-mode -1)
|
|
:documentation
|
|
"Keep point at the center of the window globally."
|
|
:evil-leader "t C--"))
|
|
:config
|
|
(progn
|
|
(setq ccm-recenter-at-end-of-file t
|
|
ccm-ignored-commands '(mouse-drag-region
|
|
mouse-set-point
|
|
widget-button-click
|
|
scroll-bar-toolkit-scroll
|
|
evil-mouse-drag-region))
|
|
(spacemacs|diminish centered-cursor-mode " ⊝" " -"))))
|
|
|
|
(defun spacemacs-ui/init-desktop ()
|
|
(use-package desktop
|
|
:defer t
|
|
:config
|
|
(progn
|
|
(setq desktop-dirname spacemacs-cache-directory)
|
|
(push spacemacs-cache-directory desktop-path))))
|
|
|
|
(defun spacemacs-ui/init-doc-view ()
|
|
(use-package doc-view
|
|
:defer t
|
|
:init
|
|
(evilified-state-evilify doc-view-mode doc-view-mode-map
|
|
"/" 'spacemacs/doc-view-search-new-query
|
|
"?" 'spacemacs/doc-view-search-new-query-backward
|
|
"gg" 'doc-view-first-page
|
|
"G" 'doc-view-last-page
|
|
"gt" 'doc-view-goto-page
|
|
"h" 'doc-view-previous-page
|
|
"j" 'doc-view-next-line-or-next-page
|
|
"k" 'doc-view-previous-line-or-previous-page
|
|
"K" 'doc-view-kill-proc-and-buffer
|
|
"l" 'doc-view-next-page
|
|
"n" 'doc-view-search
|
|
"N" 'doc-view-search-backward
|
|
(kbd "C-d") 'doc-view-scroll-up-or-next-page
|
|
(kbd "C-k") 'doc-view-kill-proc
|
|
(kbd "C-u") 'doc-view-scroll-down-or-previous-page)
|
|
:config
|
|
(progn
|
|
(defun spacemacs/doc-view-search-new-query ()
|
|
"Initiate a new query."
|
|
(interactive)
|
|
(doc-view-search 'newquery))
|
|
|
|
(defun spacemacs/doc-view-search-new-query-backward ()
|
|
"Initiate a new query."
|
|
(interactive)
|
|
(doc-view-search 'newquery t))
|
|
|
|
;; fixed a weird issue where toggling display does not
|
|
;; swtich to text mode
|
|
(defadvice doc-view-toggle-display
|
|
(around spacemacs/doc-view-toggle-display activate)
|
|
(if (eq major-mode 'doc-view-mode)
|
|
(progn
|
|
ad-do-it
|
|
(text-mode)
|
|
(doc-view-minor-mode))
|
|
ad-do-it)))))
|
|
|
|
(defun spacemacs-ui/init-flx-ido ()
|
|
(use-package flx-ido
|
|
:init (flx-ido-mode 1)))
|
|
|
|
(defun spacemacs-ui/init-info+ ()
|
|
(use-package info+
|
|
:defer t
|
|
:init
|
|
(progn
|
|
(with-eval-after-load 'info
|
|
(require 'info+))
|
|
(setq Info-fontify-angle-bracketed-flag nil))))
|
|
|
|
(defun spacemacs-ui/init-open-junk-file ()
|
|
(use-package open-junk-file
|
|
:defer t
|
|
:commands (open-junk-file)
|
|
:init
|
|
(setq open-junk-file-format (concat spacemacs-cache-directory "junk/%Y/%m/%d-%H%M%S."))
|
|
(defun spacemacs/open-junk-file (&optional arg)
|
|
"Open junk file Open junk file using helm or ivy depending
|
|
on whether the spacemacs-ivy layer is used or not, with
|
|
`prefix-arg' search in junk files"
|
|
(interactive "P")
|
|
(let* ((fname (format-time-string open-junk-file-format (current-time)))
|
|
(rel-fname (file-name-nondirectory fname))
|
|
(junk-dir (file-name-directory fname))
|
|
(default-directory junk-dir))
|
|
(cond ((and arg (configuration-layer/layer-usedp 'spacemacs-ivy))
|
|
(spacemacs/counsel-search dotspacemacs-search-tools nil junk-dir))
|
|
((configuration-layer/layer-usedp 'spacemacs-ivy)
|
|
(require 'counsel)
|
|
(counsel-find-file rel-fname))
|
|
(arg
|
|
(require 'helm)
|
|
(let (helm-ff-newfile-prompt-p)
|
|
(spacemacs/helm-files-smart-do-search)))
|
|
(t
|
|
(require 'helm)
|
|
(let (helm-ff-newfile-prompt-p)
|
|
(helm-find-files-1 fname))))))
|
|
(spacemacs/set-leader-keys "fJ" 'spacemacs/open-junk-file)))
|
|
|
|
(defun spacemacs-ui/init-paradox ()
|
|
(use-package paradox
|
|
:commands paradox-list-packages
|
|
:init
|
|
(progn
|
|
(setq paradox-execute-asynchronously nil)
|
|
(defun spacemacs/paradox-list-packages ()
|
|
"Load depdendencies for auth and open the package list."
|
|
(interactive)
|
|
(require 'epa-file)
|
|
(require 'auth-source)
|
|
(when (and (not (boundp 'paradox-github-token))
|
|
(file-exists-p "~/.authinfo.gpg"))
|
|
(let ((authinfo-result (car (auth-source-search
|
|
:max 1
|
|
:host "github.com"
|
|
:port "paradox"
|
|
:user "paradox"
|
|
:require '(:secret)))))
|
|
(let ((paradox-token (plist-get authinfo-result :secret)))
|
|
(setq paradox-github-token (if (functionp paradox-token)
|
|
(funcall paradox-token)
|
|
paradox-token)))))
|
|
(paradox-list-packages nil))
|
|
|
|
(evilified-state-evilify paradox-menu-mode paradox-menu-mode-map
|
|
"H" 'paradox-menu-quick-help
|
|
"J" 'paradox-next-describe
|
|
"K" 'paradox-previous-describe
|
|
"L" 'paradox-menu-view-commit-list
|
|
"o" 'paradox-menu-visit-homepage)
|
|
(spacemacs/set-leader-keys
|
|
"ak" 'spacemacs/paradox-list-packages))))
|
|
|
|
(defun spacemacs-ui/init-window-numbering ()
|
|
(use-package window-numbering
|
|
:config
|
|
(progn
|
|
(when (configuration-layer/package-usedp 'spaceline)
|
|
(defun window-numbering-install-mode-line (&optional position)
|
|
"Do nothing, the display is handled by the powerline."))
|
|
(setq window-numbering-auto-assign-0-to-minibuffer nil)
|
|
(spacemacs/set-leader-keys
|
|
"0" 'select-window-0
|
|
"1" 'select-window-1
|
|
"2" 'select-window-2
|
|
"3" 'select-window-3
|
|
"4" 'select-window-4
|
|
"5" 'select-window-5
|
|
"6" 'select-window-6
|
|
"7" 'select-window-7
|
|
"8" 'select-window-8
|
|
"9" 'select-window-9)
|
|
(window-numbering-mode 1))
|
|
|
|
(defun spacemacs//window-numbering-assign (windows)
|
|
"Custom number assignment for special buffers."
|
|
(mapc (lambda (w)
|
|
(when (and (boundp 'neo-global--window)
|
|
(eq w neo-global--window))
|
|
(window-numbering-assign w 0)))
|
|
windows))
|
|
(add-hook 'window-numbering-before-hook 'spacemacs//window-numbering-assign)
|
|
(add-hook 'neo-after-create-hook '(lambda (w) (window-numbering-update)))))
|