Created
November 23, 2016 22:13
-
-
Save deech/234709d7e78f2b0bee7f138ff1571c17 to your computer and use it in GitHub Desktop.
Emacs Config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; -*- mode: dotspacemacs -*- | |
| ;; This file is loaded y Spacemacs at startup. | |
| ;; It must be stored in your home directory. | |
| (defun dotspacemacs/layers () | |
| "Configuration Layers declaration." | |
| (setq-default | |
| ;; List of additional paths where to look for configuration layers. | |
| ;; Paths must have a trailing slash (ie. `~/.mycontribs/') | |
| dotspacemacs-configuration-layer-path '() | |
| ;; List of configuration layers to load. If it is the symbol `all' instead | |
| ;; of a list then all discovered layers will be installed. | |
| dotspacemacs-configuration-layers '( | |
| yaml | |
| nim | |
| python | |
| markdown | |
| markdownerc erlang ocaml scala auto-completion org git shell magit-extras epresent rust) | |
| ;; A list of packages and/or extensions that will not be install and loaded. | |
| dotspacemacs-excluded-packages '(smooth-scrolling) | |
| dotspacemacs-additional-packages '(intero | |
| shen-elisp | |
| hyperbole) | |
| ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that | |
| ;; are declared in a layer which is not a member of | |
| ;; the list `dotspacemacs-configuration-layers' | |
| dotspacemacs-delete-orphan-packages t)) | |
| (defun dotspacemacs/init () | |
| "Initialization function. | |
| This function is called at the very startup of Spacemacs initialization | |
| before layers configuration." | |
| ;; This setq-default sexp is an exhaustive list of all the supported | |
| ;; spacemacs settings. | |
| (setq-default | |
| ;; Specify the startup banner. If the value is an integer then the | |
| ;; text banner with the corresponding index is used, if the value is | |
| ;; `random' then the banner is chosen randomly among the available banners, | |
| ;; if the value is a string then it must be a path to a .PNG file, | |
| ;; if the value is nil then no banner is displayed. | |
| dotspacemacs-startup-banner 'random | |
| ;; List of themes, the first of the list is loaded when spacemacs starts. | |
| ;; Press <SPC> T n to cycle to the next theme in the list (works great | |
| ;; with 2 themes variants, one dark and one light) | |
| dotspacemacs-themes '(leuven | |
| minimal-light | |
| minimal | |
| spacemacs-light | |
| spacemacs-dark | |
| zenburn) | |
| ;; If non nil the cursor color matches the state color. | |
| dotspacemacs-colorize-cursor-according-to-state t | |
| ;; Default font. `powerline-scale' allows to quickly tweak the mode-line | |
| ;; size to make separators look not too crappy. | |
| dotspacemacs-default-font '( "Fira Mono" | |
| :size 10 | |
| :weight semi-bold | |
| :width normal | |
| :powerline-scale 1.1) | |
| ;; The leader key | |
| dotspacemacs-leader-key "SPC" | |
| ;; Major mode leader key is a shortcut key which is the equivalent of | |
| ;; pressing `<leader> m`. Set it to `nil` to disable it. | |
| dotspacemacs-major-mode-leader-key "," | |
| ;; The command key used for Evil commands (ex-commands) and | |
| ;; Emacs commands (M-x). | |
| ;; By default the command key is `:' so ex-commands are executed like in Vim | |
| ;; with `:' and Emacs commands are executed with `<leader> :'. | |
| dotspacemacs-command-key ":" | |
| ;; If non nil the paste micro-state is enabled. While enabled pressing `p` | |
| ;; several times cycle between the kill ring content. | |
| dotspacemacs-enable-paste-micro-state t | |
| ;; Guide-key delay in seconds. Thenters the | |
| ;; point when it reaches the top or bottom of the screen. | |
| dotspacemacs-smooth-scrolling nil | |
| ;; If non-nil smartparens-strict-mode will be enabled in programming modes. | |
| dotspacemacs-smartparens-strict-mode nil | |
| ;; If non nil advises quit functions to keep server open when quitting. | |
| dotspacemacs-persistent-server nil | |
| ;; The default package repository used if no explicit repository has been | |
| ;; specified with an installed package. | |
| ;; Not used for now. | |
| dotspacemacs-default-package-repository nil) | |
| ;; User initialization goes here | |
| ) | |
| (defun with-evil-mode (mode key-behavior-pairs) | |
| (mapcar #'(lambda (pair) | |
| (define-key | |
| mode | |
| (car pair) | |
| (cdr pair))) | |
| key-behavior-pairs)) | |
| (defun evil-configuration () | |
| (eval-after-load 'evil | |
| '(progn | |
| (setq evil-want-fine-undo t) | |
| ;; Make Shift-Tab equivalent to escape | |
| (with-evil-mode evil-insert-state-map | |
| '( | |
| ;; ("\C-p" . previous-line) | |
| ;; ("\C-n" . next-line) | |
| ([(control f10)] . evil-paste-from-register) | |
| ([(control f11)] . evil-copy-from-above) | |
| ([(control f12)] . evil-copy-from-below) | |
| ("\C-y" . yank) | |
| ("\M-y" . yank-pop) | |
| ; ("\C-s" . isearch-forward) | |
| ; ("\C-r" . isearch-backward) | |
| ("\C-f" . forward-char) | |
| ("\C-d" . delete-char) | |
| ("\C-k" . kill-line) | |
| ([(meta f9)] . sp-forward-slurp-sexp))) | |
| (define-key evil-motion-state-map "\C-w" nil) | |
| (define-key evil-insert-state-map "\C-w" nil) | |
| (define-key evil-emacs-state-map "\C-w" nil) | |
| (global-unset-key "\C-t") | |
| (define-key evil-motion-state-map "\C-t" 'evil-window-map) | |
| (define-key evil-insert-state-map "\C-t" 'evil-window-map) | |
| (define-key evil-normal-state-map "\C-t" 'evil-window-map) | |
| (define-key evil-emacs-state-map "\C-t" 'evil-window-map) | |
| (global-set-key "\C-j" 'newline-indent-and-whitespace) | |
| (with-evil-mode evil-normal-state-map | |
| '(("gl" . evil-last-non-blank) | |
| ("gb" . evil-first-non-blank-of-visual-line))) | |
| (with-evil-mode evil-visual-state-map | |
| '(("gl" . evil-last-non-blank) | |
| ("gb" . evil-first-non-blank-of-visual-line)))))) | |
| (defun helm-configuration () | |
| (eval-after-load 'helm | |
| '(progn | |
| (define-key helm-map (kbd "<tab>") 'helm-execute-persistent-action) ; rebind tab to do persistent action | |
| (define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB works in terminal | |
| ))) | |
| (defun define-key-in-all-evil-modes (key behavior) | |
| (mapcar #'(lambda (mode) (define-key mode key behavior)) | |
| (list evil-normal-state-map | |
| evil-insert-state-map | |
| evil-visual-state-map | |
| evil-replace-state-map | |
| evil-operator-state-map | |
| evil-motion-state-map))) | |
| (defun with-evil-mode (mode key-behavior-pairs) | |
| (mapcar #'(lambda (pair) | |
| (define-key | |
| mode | |
| (car pair) | |
| (cdr pair))) | |
| key-behavior-pairs)) | |
| (defun dotspacemacs/user-config () | |
| (progn | |
| (setq global-hl-line-mode nil) | |
| (setq global-evil-search-highlight-persist nil) | |
| (setq recentf-mode nil) | |
| (setq scroll-step 1) | |
| (setq scroll-conservatively 10000) | |
| (setq auto-window-vscroll nil) | |
| (add-hook 'before-save-hook 'delete-trailing-whitespace) | |
| (global-set-key "\C-u" 'universal-argument) | |
| (helm-configuration) | |
| (evil-configuration) | |
| ;; http://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/ | |
| ;; I prefer using the "clipboard" selection (the one the | |
| ;; typically is used by c-c/c-v) before the primary selection | |
| ;; (that uses mouse-select/middle-button-click) | |
| (setq x-select-enable-clipboard t) | |
| ;; If emacs is run in a terminal, the clipboard- functions have no | |
| ;; effect. Instead, we use of xsel, see | |
| ;; http://www.vergenet.net/~conrad/software/xsel/ -- "a command-line | |
| ;; program for getting and setting the contents of the X selection" | |
| ;; Idea from | |
| ;; http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/ | |
| ;; http://www.mail-archive.com/[email protected]/msg03577.html | |
| (setcdr evil-insert-state-map nil) | |
| (with-evil-mode evil-insert-state-map | |
| '( | |
| ([(control f10)] . evil-paste-from-register) | |
| ([(control f11)] . evil-copy-from-above) | |
| ([(control f12)] . evil-copy-from-below) | |
| ([escape] . evil-normal-state))) | |
| (unless window-system | |
| (when (getenv "DISPLAY") | |
| ;; Callback for when user cuts | |
| (defun xsel-cut-function (text &optional push) | |
| ;; Insert text to temp-buffer, and "send" content to xsel stdin | |
| (with-temp-buffer | |
| (insert text) | |
| ;; I prefer using the "clipboard" selection (the one the | |
| ;; typically is used by c-c/c-v) before the primary selection | |
| ;; (that uses mouse-select/middle-button-click) | |
| (call-process-region (point-min) (point-max) "xsel" nil 0 nil "--clipboard" "--input"))) | |
| ;; Call back for when user pastes | |
| (defun xsel-paste-function() | |
| ;; Find out what is current selection by xsel. If it is different | |
| ;; from the top of the kill-ring (car kill-ring), then return | |
| ;; it. Else, nil is returned, so whatever is in the top of the | |
| ;; kill-ring will be used. | |
| (let ((xsel-output (shell-command-to-string "xsel --clipboard --output"))) | |
| (unless (string= (car kill-ring) xsel-output) | |
| xsel-output ))) | |
| ;; Attach callbacks to hooks | |
| (setq interprogram-cut-function 'xsel-cut-function) | |
| (setq interprogram-paste-function 'xsel-paste-function))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment