diff options
Diffstat (limited to '')
-rw-r--r-- | emacs.d/init.el | 354 |
1 files changed, 25 insertions, 329 deletions
diff --git a/emacs.d/init.el b/emacs.d/init.el index c0c2d60..4afc820 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -3,11 +3,10 @@ (setq package-archives '(("melpa" . "https://melpa.org/packages/"))) -(defvar fcuny-path-emacs-var (expand-file-name "var" user-emacs-directory) - "Path to some files for Emacs.") +;; and now we load custom configurations +(add-to-list 'load-path (expand-file-name "custom" user-emacs-directory)) -(defvar fcuny-path-emacs-elpa (expand-file-name "elpa" fcuny-path-emacs-var) - "Path to elpa's local files.") +(require 'fcuny-vars) ;; where to store the packages (setq package-user-dir fcuny-path-emacs-elpa) @@ -22,329 +21,26 @@ (require 'use-package) -(defvar fcuny/bookmarks-dir (expand-file-name "bookmarks" fcuny-path-emacs-var) - "Path to save the bookmarks") +(require 'fcuny-settings) +(require 'fcuny-ui) +(require 'fcuny-hygiene) +(require 'fcuny-common) +(require 'fcuny-navigation) +(require 'fcuny-edit) +(require 'fcuny-text) +(require 'fcuny-git) + +(require 'fcuny-flycheck) + +(require 'fcuny-docker) +(require 'fcuny-json) +(require 'fcuny-protobuf) +(require 'fcuny-puppet) +(require 'fcuny-yaml) + +(require 'fcuny-go) +(require 'fcuny-lisp) +(require 'fcuny-make) +(require 'fcuny-python) +(require 'fcuny-shell) -(defvar fcuny/custom-settings (expand-file-name "emacs-custom.el" fcuny-path-emacs-var) - "Path to emacs custom variables.") - -(defun fcuny/rename-this-buffer-and-file () - "Renames current buffer and file it is visiting." - (interactive) - (let ((name (buffer-name)) - (filename (buffer-file-name)) - (read-file-name-function 'read-file-name-default)) - (if (not (and filename (file-exists-p filename))) - (error "Buffer '%s' is not visiting a file!" name) - (let ((new-name (read-file-name "New name: " filename))) - (cond ((get-buffer new-name) - (error "A buffer named '%s' already exists!" new-name)) - (t - (rename-file filename new-name 1) - (rename-buffer new-name) - (set-visited-file-name new-name) - (set-buffer-modified-p nil) - (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name)))))))) - -(defun fcuny/check-work-machine-p () - "Returns t if this is a work machine" - (string-match "tw-mbp.*" (system-name))) - -(defun fcuny/remove-mysql-columns () - "Removes | from text. This is useful when I want to drop the column separator from some text coming from a mysql query." - (interactive) - (if (region-active-p) - (replace-regexp "\s?|\s?" "" nil (region-beginning) (region-end)) - (replace-regexp "\s?|\s?" ""))) - -(defun fcuny/copy-whole-buffer () - "Selects the buffer and copy it." - (interactive) - (save-excursion - (mark-whole-buffer) - (copy-region-as-kill 1 (buffer-size)))) - -;; set utf-8 as the default encoding -(prefer-coding-system 'utf-8-unix) -(set-terminal-coding-system 'utf-8) -(set-keyboard-coding-system 'utf-8) - -;; alias yes-or-no to y-or-n -(fset 'yes-or-no-p 'y-or-n-p) - -(setq auto-save-default nil) ;; don't auto save files -(setq auto-save-list-file-prefix nil) ;; no backups -(setq create-lockfiles nil) ;; don't use a lock file -(setq custom-file fcuny/custom-settings) ;; where to save custom settings -(setq make-backup-files nil) ;; really no backups -(setq minibuffer-message-timeout 0.5) ;; How long to display an echo-area message -(setq next-screen-context-lines 5) ;; scroll 5 lines at a time -(setq require-final-newline t) ;; ensure newline exists at the end of the file -(setq ring-bell-function 'ignore) ;; really no bell -(setq tab-always-indent 'complete) ;; when using TAB, always indent -(setq visible-bell nil) ;; no bell -(setq column-number-mode t) ;; show column number in the mode line -(setq-default indent-tabs-mode nil) ;; turn off tab indentation -(setq-default cursor-type 'hbar) ;; cursor is a horizontal bar -(setq bookmark-default-file fcuny/bookmarks-dir) ;; where to save bookmarks -(setq bookmark-save-flag 1) ;; save bookmarks when emacs qui -(setq vc-handled-backends nil) ;; don't use the VC backend, it's too slow with source -(setq-default delete-by-moving-to-trash t) ;; delete files by moving them to the trash -(setq initial-scratch-message "") ;; empty scratch buffer - -(custom-set-variables - '(tool-bar-mode nil) - '(scroll-bar-mode nil) - '(use-file-dialog nil) - '(use-dialog-box nil) - '(blink-cursor-mode nil) - '(inhibit-startup-screen t) - '(inhibit-startup-message t) - '(inhibit-startup-echo-area-message t)) - -(use-package frame - :bind (("C-c C-m" . toggle-frame-fullscreen)) - :config - (progn - (defun fcuny/setup-frame(&optional frame) - (fringe-mode '(10 . 10)) - (setq-default frame-title-format "%b") - (set-face-attribute 'default nil :height 160 :weight 'normal :width 'normal :font "Source Code Pro") - (when (eq system-type 'darwin) - (setq ns-use-native-fullscreen nil) - (setq mac-allow-anti-aliasing t))) - (fcuny/setup-frame))) - -(use-package general - :config - (general-define-key - "M-j" 'join-line)) - -;;; emacs hygiene - -(use-package midnight - :config - (midnight-mode t)) - -(use-package server - :hook (after-init . server-start)) - -(use-package exec-path-from-shell - :ensure t - :if (memq window-system '(mac ns)) - :config - (exec-path-from-shell-initialize)) - -;;; general editing - -(use-package ace-window - :ensure t - :bind (("C-x o" . ace-window))) - -(use-package recentf - :config - (recentf-mode 1) - (setq recentf-max-saved-items 500 - recentf-save-file (expand-file-name "var/recentf" user-emacs-directory))) - -(use-package autorevert - :config - (setq global-auto-revert-non-file-buffers t) - (setq auto-revert-verbose nil) - (global-auto-revert-mode t)) - -(use-package hl-line - :config - (set-face-background 'hl-line "#E0EBF5") - (global-hl-line-mode t)) - -(use-package uniquify - :defer 5 - :config - (setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers - (setq uniquify-buffer-name-style 'forward) - (setq uniquify-separator "/")) - -;;; files navigation - -(use-package ag - :ensure t - :bind (:map ag-mode-map - ("p" . compilation-previous-error) - ("n" . compilation-next-error) - ("N" . compilation-next-file) - ("P" . compilation-previous-file)) - :custom - (ag-highlight-search t) - (ag-reuse-buffers t) - (ag-reuse-window t)) - -(use-package dired - :defer t - :bind (("C-x C-d" . dired) - ("C-x C-j" . dired-jump)) - :init - (setq-default dired-dwim-target t) - (setq-default dired-listing-switches "--group-directories-first -alh") - (setq dired-recursive-deletes 'always) - (setq dired-recursive-copies 'always) - - (let ((gls (executable-find "/opt/twitter/bin/gls"))) - (when gls (setq insert-directory-program gls)))) - -(use-package ibuffer - :bind ("C-x C-b" . ibuffer)) - -;;; general text editing - -(use-package flyspell - :hook ((text-mode . flyspell-mode) - (prog-mode . flyspell-prog-mode)) - :config - (setq ispell-dictionary "en_US") - - (when (executable-find "aspell") - (setq ispell-program-name "aspell" - ispell-list-command "--list")) - - (use-package flyspell-correct - :after (flyspell) - :commands (flyspell-correct-word-generic - flyspell-correct-previous-word-generic) - :bind (:map flyspell-mode-map - ("C-;" . flyspell-correct-previous-word-generic)))) - -(use-package whitespace - :custom - (whitespace-style '(face trailing)) - (show-trailing-whitespace t) - :hook (whitespace-mode)) - -(use-package electric-pair-mode - :commands electric-pair-mode - :init (add-hook 'prog-mode-hook 'electric-pair-mode)) - -(use-package paren - :ensure t - :custom - (show-paren-delay 0) - :config - (show-paren-mode 1)) - -;;; text formats - -(use-package markdown-mode - :ensure t - :after (flyspell) - :commands (markdown-mode gfm-mode) - :mode (("README\\.md\\'" . gfm-mode) - ("\\.md\\'" . gfm-mode) - ("\\.markdown\\'" . gfm-mode))) - -;;; source control - -(use-package magit - :ensure t - :after (flyspell) - :hook ((magit-mode . hl-line-mode)) - :bind (("C-x g s" . magit-status)) - :config - (setq git-commit-summary-max-length 50) - (setq git-commit-fill-column 72) - (setq git-commit-turn-on-auto-fill t)) - -;;; prog mode - -(use-package flycheck - :ensure t - :custom - (flycheck-idle-change-delay 2)) - -(use-package lisp-mode - :bind - (("C-c C-e" . eval-buffer) - ("C-c C-r" . eval-region))) - -(use-package make-mode - :config - (add-hook 'makefile-mode-hook (lambda () (setq-local tab-width 2)))) - -(use-package go-mode - :ensure t - :after (exec-path-from-shell) - :hook (go-mode . fcuny/go-mode-setup) - :init - (defun fcuny/go-mode-setup () - (setq tab-width 4) - (add-hook 'before-save-hook 'gofmt-before-save)) - :config - (when (memq window-system '(mac ns)) - (exec-path-from-shell-copy-env "GOPATH"))) - -(use-package python - :mode (("\\.py$" . python-mode) - ("BUILD\\'" . python-mode)) - :commands python-mode - :custom (python-indent-offset 2)) - -(use-package sh-script - :mode ("bashrc" . sh-mode) - :hook (after-save . executable-make-buffer-file-executable-if-script-p) - :config - (setq-default sh-indentation 2 - sh-basic-offset 2)) - -;;; configurations - -(use-package dockerfile-mode - :ensure t - :mode "Dockerfile[a-zA-Z.-]*\\'") - -(use-package gitconfig-mode - :ensure t - :defer 5) - -(use-package puppet-mode - :ensure t - :bind (:map puppet-mode-map - ("C-c |" . puppet-align-block))) - -(use-package yaml-mode - :ensure t) - -(use-package json-mode - :after (flyspell flycheck) - :custom - (json-reformat:indent-width 2) - (js-indent-level 2) - :hook ((json-mode . flyspell-prog-mode) - (json-mode . flycheck-mode)) - :init - (if (fcuny/check-work-machine-p) - (add-to-list 'auto-mode-alist '("\\.workflow$" . json-mode)))) - -(use-package protobuf-mode - :after (flyspell flycheck) - :ensure t - :hook ((protobuf-mode . flyspell-prog-mode) - (protobuf-mode . flycheck-mode))) - -(use-package counsel - :ensure t - :init (counsel-mode 1) (ivy-mode 1) - :bind - (("M-x" . counsel-M-x) - ("C-s" . counsel-grep-or-swiper) - ("C-x C-f" . counsel-find-file) - ("C-x C-r" . counsel-recentf) - ("C-c f" . counsel-git) - ("C-c s" . counsel-git-grep) - ("C-c /" . counsel-ag) - ("C-x r l" . counsel-bookmark)) - :custom - (counsel-find-file-at-point t) - (ivy-use-virtual-buffers t) - (ivy-count-format "(%d/%d) ") - (ivy-height 10) - :config - (use-package swiper :ensure t)) |