summary refs log tree commit diff
path: root/configs/rcs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--configs/rcs/emacs.d/init.el254
1 files changed, 186 insertions, 68 deletions
diff --git a/configs/rcs/emacs.d/init.el b/configs/rcs/emacs.d/init.el
index 7f4ae6c..61dbd80 100644
--- a/configs/rcs/emacs.d/init.el
+++ b/configs/rcs/emacs.d/init.el
@@ -1,6 +1,11 @@
 ;; Initialise the package system first of all.
 (require 'package)
-(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
+
+(setq package-archives
+      '(("gnu" . "https://elpa.gnu.org/packages/")
+        ("melpa" . "https://melpa.org/packages/")
+        ("elpy" . "https://jorgenschaefer.github.io/packages/")
+        ("org" . "http://orgmode.org/elpa/")))
 
 (defvar fcuny-path-emacs-var (expand-file-name "var" user-emacs-directory)
   "Path to some files for Emacs.")
@@ -8,6 +13,9 @@
 (defvar fcuny-path-emacs-elpa (expand-file-name "elpa" fcuny-path-emacs-var)
   "Path to elpa's local files.")
 
+(defvar fcuny-projects-ignored-dirs '(".git" ".svn" "target" "elpa")
+   "Ignore the following directories when browsing with projectile.")
+
 ;; where to store the packages
 (setq package-user-dir fcuny-path-emacs-elpa)
 
@@ -24,9 +32,6 @@
 (defvar fcuny-path-home (getenv "HOME")
   "Path to the user's home directory.")
 
-(defvar fcuny-projects-ignored-dirs '(".git" ".svn" "target" "elpa")
-  "Ignore the following directories when browsing with projectile.")
-
 (defvar fcuny-bookmarks-dir (expand-file-name "bookmarks" fcuny-path-emacs-var)
   "Path to save the bookmarks")
 
@@ -63,28 +68,25 @@
 ;; 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 use-package-always-ensure t)             ;; always ensure packages are present
-(setq-default indent-tabs-mode nil)            ;; turn off tab indentation
-(setq-default cursor-type 'hbar)               ;; cursor is a horizontal bar
-
-(set-face-attribute 'default nil :height 130 :weight 'normal :width 'normal)
-
-(fringe-mode '(8 . 8))                         ;; size of the fringe
-
-(global-set-key (kbd "M-j") 'join-line)                           ;; Remap join-line to M-j where it's easier to get to.
-(global-set-key (kbd "<s-return>") 'toggle-frame-fullscreen)      ;; Shift-Return switch to full-screen
+(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 use-package-always-ensure t)               ;; always ensure packages are present
+(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
+
+(fringe-mode '(8 . 8))                           ;; size of the fringe
 
 (custom-set-variables
  '(tool-bar-mode nil)
@@ -96,9 +98,19 @@
  '(inhibit-startup-message t)
  '(inhibit-startup-echo-area-message t))
 
-;; when using darwin, I don't want to use the native fullscreen mode (it opens a new workspace)
-(when (eq system-type 'darwin)
-  (setq ns-use-native-fullscreen nil))
+(use-package personal
+  :ensure nil
+  :bind (("M-j" . join-line)
+         ("C-c m m" . emacs-toggle-size)))
+
+(use-package recentf
+  :commands (recentf-mode
+             recentf-add-file
+             recentf-apply-filename-handlers)
+  :config
+  (recentf-mode 1)
+  (setq recentf-max-saved-items 500
+        recentf-save-file (expand-file-name "var/recentf" user-emacs-directory)))
 
 (use-package auto-package-update
   :custom
@@ -108,10 +120,12 @@
   :hook
   (after-init . auto-package-update-maybe))
 
-(use-package bookmark
-  :custom
-  (bookmark-default-file fcuny-bookmarks-dir)
-  (bookmark-save-flag 1))
+(use-package beacon
+  :ensure t
+  :diminish
+  :commands beacon-mode
+  :config
+  (beacon-mode t))
 
 (use-package midnight
   :config
@@ -123,25 +137,14 @@
   (setq auto-revert-verbose nil)
   (global-auto-revert-mode t))
 
-(use-package recentf
-  :config
-  (setq recentf-save-file (expand-file-name "var/recentf" user-emacs-directory)))
-
 (use-package server
-  :if window-system
-  :init
-  (add-hook 'after-init-hook 'server-start))
+  :no-require
+  :hook (after-init . server-start))
 
 (use-package hl-line
   :config
   (global-hl-line-mode t))
 
-(use-package whitespace
-  :custom
-  (whitespace-style '(face trailing))
-  (show-trailing-whitespace t)
-  :hook (whitespace-mode))
-
 (use-package ag
   :bind (:map ag-mode-map
               ("p" . compilation-previous-error)
@@ -156,7 +159,8 @@
 (use-package dired
   :ensure nil
   :defer t
-  :bind ("C-x C-d"  . dired)
+  :bind (("C-x C-d"  . dired))
+  :diminish dired-omit-mode
   :init
   (setq-default dired-dwim-target t)
   (setq dired-recursive-deletes 'always)
@@ -165,9 +169,23 @@
   (let ((gls (executable-find "/opt/twitter/bin/gls")))
     (when gls (setq insert-directory-program gls))))
 
+(use-package dired-toggle
+  :bind ("C-c ~" . dired-toggle)
+  :preface
+  (defun my-dired-toggle-mode-hook ()
+    (interactive)
+    (visual-line-mode 1)
+    (setq-local visual-line-fringe-indicators '(nil right-curly-arrow))
+    (setq-local word-wrap nil))
+  :hook (dired-toggle-mode . my-dired-toggle-mode-hook))
+
 (use-package ibuffer
   :bind ("C-x C-b" . ibuffer))
 
+(use-package magit
+  :bind (("C-x g" . magit-status))
+  :hook (magit-mode . hl-line-mode))
+
 (use-package ispell
   :config
   (when (executable-find "aspell")
@@ -189,13 +207,41 @@
         (unless (getenv var)
           (exec-path-from-shell-copy-env var)))))
 
-(electric-pair-mode 1)
-
-(use-package paren
+(use-package counsel
+  :ensure t
+  :after (projectile ivy)
+  :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))
   :custom
-  (show-paren-delay 0)
+  (counsel-find-file-at-point t)
   :config
-  (show-paren-mode 1))
+  (use-package swiper :ensure t)
+  (use-package counsel-projectile
+    :ensure t
+    :config
+    (counsel-projectile-mode)))
+
+(use-package projectile
+  :ensure t
+  :diminish projectile-mode
+  :bind-keymap ("C-c p" . projectile-command-map)
+  :init
+  (add-hook 'after-init-hook #'projectile-mode)
+  :config
+  (setq projectile-switch-project-action 'projectile-dired
+        projectile-enable-caching t
+        projectile-completion-system 'ivy
+        projectile-known-projects-file (expand-file-name "var/projectile-bookmarks.eld" user-emacs-directory)
+        projectile-cache-file (expand-file-name "var/projectile.cache" user-emacs-directory)
+        projectile-globally-ignored-directories (append fcuny-projects-ignored-dirs
+                                                        projectile-globally-ignored-directories)
+        projectile-globally-ignored-files (append projectile-globally-ignored-files)))
 
 (use-package lisp-mode
   :ensure f
@@ -234,19 +280,27 @@
   (add-hook 'sh-mode-hook 'set-sh-mode-indent)
   (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p))
 
+(use-package docker
+  :bind ("C-c d" . docker)
+  :diminish)
+
+(use-package docker-compose-mode
+  :mode "docker-compose.*\.yml\\'")
+
+(use-package docker-tramp
+  :after tramp
+  :defer 5)
+
 (use-package dockerfile-mode
-  :ensure t)
+  :mode "Dockerfile[a-zA-Z.-]*\\'")
 
-(use-package puppet-mode
-  :ensure t
-  :mode ("\\.pp\\'" . puppet-mode))
+(use-package gitconfig-mode
+  :defer 5)
+
+(use-package puppet-mode :ensure t)
 
 (use-package yaml-mode
-  :ensure t
-  :after (flyspell)
-  :mode (("\\.yml?\\'" . yaml-mode)
-         ("\\.yaml?\\'" . yaml-mode))
-  :hook ((yaml-mode . flyspell-prog-mode)))
+  :ensure t)
 
 (use-package json-mode
   :ensure t
@@ -259,14 +313,78 @@
   (if (fc/check-work-machine-p)
     (add-to-list 'auto-mode-alist '("\\.workflow$" . json-mode))))
 
-(use-package thrift
-  :ensure t
-  :after (flyspell)
-  :custom
-  (thrift-indent-level 2)
-  :hook ((thrift . flyspell-prog-mode)))
-
 (use-package protobuf-mode
   :ensure t
   :after (flyspell)
   :hook ((protobuf-mode . flyspell-prog-mode)))
+
+(use-package whitespace
+  :custom
+  (whitespace-style '(face trailing))
+  (show-trailing-whitespace t)
+  :hook (whitespace-mode))
+
+(use-package electric-pair-mode
+  :ensure nil
+  :commands electric-pair-mode
+  :init (add-hook 'prog-mode-hook 'electric-pair-mode))
+
+(use-package paren
+  :custom
+  (show-paren-delay 0)
+  :config
+  (show-paren-mode 1))
+
+;; layout
+;; when using darwin, I don't want to use the native fullscreen mode (it opens a new workspace)
+(when (eq system-type 'darwin)
+  (setq ns-use-native-fullscreen nil))
+
+(defconst display-name
+  (pcase (display-pixel-width)
+    (`1440 'macbook-pro)))
+
+(defconst emacs-min-top 23)
+
+(defconst emacs-min-left
+  (pcase display-name
+    (`macbook-pro 200)))
+
+(defconst emacs-min-height
+  (pcase display-name
+    (`macbook-pro 47)))
+
+(defconst emacs-min-width
+  (pcase display-name
+    (`macbook-pro 100)))
+
+(defconst emacs-min-font
+  (pcase display-name
+    (_ "-*-DejaVu Sans Mono-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1")))
+
+(defun emacs-min ()
+  (interactive)
+  (cl-flet ((set-param (p v) (set-frame-parameter (selected-frame) p v)))
+    (set-param 'fullscreen nil)
+    (set-param 'vertical-scroll-bars nil)
+    (set-param 'horizontal-scroll-bars nil))
+  (set-frame-position (selected-frame) emacs-min-left emacs-min-top)
+  (set-frame-height (selected-frame) emacs-min-height)
+  (set-frame-width (selected-frame) emacs-min-width)
+  (set-frame-font emacs-min-font))
+
+(defun emacs-max ()
+  (interactive)
+  (cl-flet ((set-param (p v) (set-frame-parameter (selected-frame) p v)))
+    (set-param 'fullscreen 'fullboth)
+    (set-param 'vertical-scroll-bars nil)
+    (set-param 'horizontal-scroll-bars nil))
+  (set-frame-font emacs-min-font))
+
+(defun emacs-toggle-size ()
+  (interactive)
+  (if (alist-get 'fullscreen (frame-parameters))
+      (emacs-min)
+    (emacs-max)))
+
+(add-hook 'emacs-startup-hook #'emacs-min t)