;;; setup-emacs.el -- Configure overall emacs setup. ;;; ;;; Commentary: ;;; Calls other setup and configuration scripts to provide the ;;; overall emacs setup. ;;; ;;; Code: ;; Get rid of bars of any kind, we don't need 'em (if (fboundp 'menu-bar-mode) (menu-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ;; Start the emacsclient server (require 'server) (unless (server-running-p) (server-start)) ;; Get rid of the welcome screen (setq inhibit-startup-message t) ;; One letter yes-or-no prompts (defalias 'yes-or-no-p 'y-or-n-p) ;; Show line numbers next to lines ;; (global-linum-mode -1) ;; Highlight the current line (global-hl-line-mode 1) ;; Interactive do mode (ido-mode t) ;; Hide the fringes (fringe-mode -1) ;; Show us the time (display-time) ;; Don't blink that cursor (blink-cursor-mode -1) ;; Overwrite selection when cutting and pasting (delete-selection-mode 1) ;; Set the default fill column at 79 characters (not 72) (setq-default fill-column 79) ;; Add some space to the right of the line numbers displayed (defadvice linum-update-window (around linum-dynamic activate) "Customize line-number formatting." (let* ((w (length (number-to-string (count-lines (point-min) (point-max))))) (linum-format (concat "%" (number-to-string w) "d "))) ad-do-it)) ;; Show line and column numbers in gutter (setq line-number-mode t) (setq column-number-mode t) ;; Show how big the file is in the gutter (size-indication-mode t) ;; Show trailing whitespace at the end of a line (highlights in red by ;; default) (setq show-trailing-whitespace t) ;; Never insert tabs (set-default 'indent-tabs-mode nil) ;; Show matching parens (show-paren-mode 1) ;; Uniquify buffer names if we have two files with same name open (require 'uniquify) (setq uniquify-buffer-name-style 'forward) ;; Automatically reload buffers that have changed on disk (global-auto-revert-mode t) ;; Electric pair mode (electric-pair-mode 1) ;; UTF-8 everywhere (setq locale-encoding-system 'utf-8) (set-terminal-coding-system 'utf-8) ;;(set-keyboard-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) ;; Set up a decent, basic color scheme (use customize-themes to find ;; new one) ;; (custom-set-variables ;; '(custom-enabled-themes (quote (wombat)))) ;; (require 'twilight-bright-theme) ;; (load-theme 'twilight-bright t) (require 'doom-modeline) (doom-modeline-mode 1) (require 'doom-themes) ;; (load-theme 'doom-one t) ;; (load-theme 'doom-vibrant t) ;; (load-theme 'doom-nova t) ;; (load-theme 'doom-moonlight t) ;; (load-theme 'doom-snazzy t) ;; (load-theme 'doom-molokai t) ;; (load-theme 'doom-city-lights t) ;; (load-theme 'doom-sourcerer t) (load-theme 'doom-nord t) ;; (load-theme 'doom-solarized-dark t) ;; Bump up the font size a bit and use a prettier fac (when (display-graphic-p) (cond ((member "Hack" (font-family-list)) (set-face-attribute 'default nil :height 120 :font "Hack")) (t (set-face-attribute 'default nil :height 120)))) (set-face-attribute 'default nil :height 120 :font "Liberation Mono") ;; (when (display-graphic-p) ;; (cond ((member "Monoid" (font-family-list)) ;; (set-face-attribute 'default nil :height 120 :font "Monoid")) ;; ((member "Inconsolata" (font-family-list)) ;; (set-face-attribute 'default nil :height 120 :font "Inconsolata")) ;; ((member "ProggyCleanTTSZ" (font-family-list)) ;; (set-face-attribute 'default nil :height 180 :font "ProggyCleanTTSZ")) ;; ((member "Hack" (font-family-list)) ;; (set-face-attribute 'default nil :height 110 :font "Hack")) ;; (t (set-face-attribute 'default nil :height 180)))) ;; Handle backspace triggering help in terminal (when (not (display-graphic-p)) (normal-erase-is-backspace-mode 1)) ;; Score: gLives ;; Customize hl-line-mode coloring. This needs to come after ;; configuring theming as some themes override these settings. ;; (set-face-foreground 'highlight nil) ;; (set-face-background 'highlight "#333") ;; (set-face-underline 'highlight nil) (set-face-background 'hl-line "#555") ;; (Un)comment region (global-set-key (kbd "C-c u c") 'comment-region) (global-set-key (kbd "C-c u u") 'uncomment-region) ;; Bind key for replacing a rectangle (global-set-key (kbd "C-c u r") 'replace-rectangle) ;; Custom highlight keywords (require 'hl-todo) (add-to-list 'hl-todo-keyword-faces '("Improvement" . "#cc9393")) ;; Duplicate whole line (global-set-key (kbd "C-c C-d") (kbd "C-a C-SPC C-n M-w C-y C-p C-e")) ;; Semantic mode (require 'semantic/db) ;; Flycheck ;; (require 'flycheck) ;; (add-hook 'after-init-hook #'global-flycheck-mode) ;; perspective-el (require 'perspective) (persp-mode) ;; Ivy (require 'ivy) (require 'counsel) (ivy-mode 1) (counsel-mode 1) (setq ivy-use-virtual-buffers t) (setq enable-recursive-minibuffers t) (global-set-key (kbd "C-c h o") 'swiper) (global-set-key (kbd "C-c h i") 'counsel-semantic-or-imenu) (global-set-key (kbd "C-c h b") 'ivy-switch-buffer) ;; Projectile mode (projectile-global-mode) (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) (setq projectile-completion-system 'ivy) ;; Add Go to PATH (setq exec-path (append exec-path '("/usr/local/go/bin" "/usr/local/bin"))) (require 'hl-todo) (global-hl-todo-mode 1) ;; Faster recompilation of files (global-set-key (kbd "C-c b c") 'compile) (global-set-key (kbd "C-c b b") 'recompile) (global-set-key (kbd "C-M-") (lambda () (interactive) (kill-line 0) (indent-according-to-mode))) ;; C stuff (defun custom-c-mode-setup () (progn (setq c-default-style "linux" c-basic-offset 2 open-parens-in-column-0-is-defun-start nil open-paren-in-column-0-is-defun-start nil) (c-set-offset 'defun-open 0) (c-set-offset 'defun-block-intro 2) (c-set-offset 'block-open 0) (c-set-offset 'substatement-open 0) (c-set-offset 'brace-list-intro 2) (c-set-offset 'arglist-intro 2) (c-set-offset 'arglist-close 0))) ;; NOTE: These variables tell Emacs to scan backwards through the whole buffer for parens rather than using heuristics which seem broken. (add-hook 'c-mode-hook 'custom-c-mode-setup) (add-hook 'c++-mode-hook 'custom-c-mode-setup) ;; Fix projectile (setq projectile-indexing-method 'native) ;; Number windows (require 'winum) (winum-mode) ;; Allow for toggling the transparency of the window (defun toggle-transparency () (interactive) (let ((alpha (frame-parameter nil 'alpha))) (set-frame-parameter nil 'alpha (if (eql (cond ((numberp alpha) alpha) ((numberp (cdr alpha)) (cdr alpha)) ;; Also handle undocumented ( ) form. ((numberp (cadr alpha)) (cadr alpha))) 100) '(95 . 95) '(100 . 100))))) (global-set-key (kbd "C-c t") 'toggle-transparency) ;; Ace window (global-set-key (kbd "C-c w") 'ace-window) ;;(require 'crosshairs) ;; doom-nova color scheme ;; (set-face-attribute 'col-highlight nil :background "#556873") ;; LSP ;; (require 'yasnippet) ;; (yas-global-mode t) ;;(require 'lsp) ;;(add-hook 'c-mode-hook #'lsp-deferred) ;; (add-hook 'c++-mode-hook #'lsp-deferred) ;; (setq lsp-ui-sideline-ignore-duplicate t) ;; (add-hook 'lsp-mode-hook 'lsp-ui-mode) ;; Fix issues with perspective and lsp-ui ;; (add-hook 'lsp-mode-hook ;; (lambda () ;; (when (featurep 'perspective) ;; (ad-deactivate 'set-window-buffer)))) ;; (global-set-key (kbd "C-M-i") 'lsp-ui-peek-find-references) ;; (require 'company-lsp) ;; (push 'company-lsp company-backends) ;; (setq company-dabbrev-downcase 0) ;; (setq company-idle-delay 0) ;; Fix splitting windows on compile? (defun my-compilation-hook () (when (not (get-buffer-window "*compilation*")) ;;(save-selected-window (save-excursion (let* ((w (split-window-horizontally)) (h (window-height w))) (select-window w) (switch-to-buffer "*compilation*"))))) ;; (add-to-list 'same-window-buffer-names "*compilation*") ;; ;; Magit ;; (global-set-key (kbd "C-c m s") 'magit-status) (global-set-key (kbd "C-c m l") 'magit-log) ;; ;; Expansion ;; (global-set-key (kbd "M-/") (make-hippie-expand-function '(try-expand-dabbrev-visible try-expand-dabbrev try-expand-dabbrev-all-buffers) t)) (provide 'setup-emacs) ;;; setup-emacs.el ends here