Skip to content

Instantly share code, notes, and snippets.

@krofna
Last active March 7, 2019 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krofna/b4b8f1f5b198b5fe815584f08523fbea to your computer and use it in GitHub Desktop.
Save krofna/b4b8f1f5b198b5fe815584f08523fbea to your computer and use it in GitHub Desktop.
;;; init.el --- my init
;;; Commentary:
;;; Code:
(require 'cc-mode)
(require 'time)
(setq user-full-name "Mislav Blažević"
user-mail-address "mislav.blazevic5@gmail.com"
c-default-style "bsd"
inhibit-splash-screen t
inhibit-startup-message t
make-backup-files nil
split-width-threshold nil
display-time-24hr-format t
column-number-mode t
echo-keystrokes 0.1
delete-by-moving-to-trash t
fill-column 80
split-height-threshold nil
split-width-threshold 0)
(setq-default tab-width 4
c-basic-offset 4
indent-tabs-mode nil)
(delete-selection-mode)
(c-set-offset 'inlambda 0)
(c-set-offset 'case-label '+)
(tooltip-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.nss\\'" . c-mode))
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(defconst pkg-list '(anzu company company-irony company-irony-c-headers flycheck
flycheck-irony irony latex-preview-pane magit moe-theme
neotree paredit pdf-tools slime smooth-scroll undo-tree
use-package all-the-icons multiple-cursors ace-window
disaster restart-emacs powerline async smex ace-jump-mode
helm-swoop haskell-mode rtags cmake-ide auctex cdlatex))
;(package-refresh-contents)
(dolist (package pkg-list)
(unless (package-installed-p package)
(package-install package)))
(eval-when-compile
(require 'use-package))
(require 'yasnippet)
(yas-global-mode 1)
(require 'haskell-interactive-mode)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(winner-mode 1)
(require 'server)
(unless (server-running-p)
(server-start))
(require 'helm-swoop)
(setq helm-swoop-speed-or-color t)
(global-set-key (kbd "M-i") 'helm-swoop)
(define-key helm-swoop-map (kbd "C-s") 'helm-next-line)
(require 'ace-jump-mode)
(define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
(require 'smex)
(global-set-key (kbd "M-x") 'smex)
(require 'smooth-scroll)
(use-package smooth-scroll
:config
(smooth-scroll-mode 1)
(setq smooth-scroll/vscroll-step-size 3))
(require 'powerline)
(require 'moe-theme)
(moe-dark)
(powerline-moe-theme)
(moe-theme-set-color 'purple)
(require 'undo-tree)
(global-undo-tree-mode)
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
(require 'slime)
(setq inferior-lisp-program "/usr/bin/sbcl")
(require 'paredit)
;; (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
;; (add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
;; (add-hook 'ielm-mode-hook #'enable-paredit-mode)
;; (add-hook 'lisp-mode-hook #'enable-paredit-mode)
;; (add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
;; (add-hook 'scheme-mode-hook #'enable-paredit-mode)
(add-hook 'prog-mode-hook 'linum-mode)
(add-hook 'prog-mode-hook 'hs-minor-mode)
(define-key prog-mode-map (kbd "<backtab>") 'hs-toggle-hiding)
(define-abbrev-table 'c++-mode-abbrev-table
'(("ALG" "#include <algorithm>")
("NUM" "#include <numeric>")
("ARR" "#include <array>")
("ASS" "#include <cassert>")
("BIT" "#include <bitset>")
("CSTD" "#include <cstdlib>")
("CSTDI" "#include <cstdint>")
("CIO" "#include <cstdio>")
("CMATH" "#include <cmath>")
("CTIME" "#include <ctime>")
("DEQUE" "#include <deque>")
("IO" "#include <iostream>")
("FIO" "#include <fstream>")
("EXCEPT" "#include <exception>")
("LIST" "#include <list>")
("MAP" "#include <map>")
("UMAP" "#include <unordered_map>")
("MANIP" "#include <iomanip>")
("QUEUE" "#include <queue>")
("SET" "#include <set>")
("USET" "#include <unordered_set>")
("SSTR" "#include <sstream>")
("STACK" "#include <stack>")
("STDEXCEPT" "#include <stdexcept>")
("STR" "#include <string>")
("UNI" "#include <unistd.h>")
("VECTOR" "#include <vector>")
("REGEX" "#include <regex>")
("LIMS" "#include <limits>")
("TUPLE" "#include <tuple>")
("UTIL" "#include <utility>")
("STD" "using namespace std;")
("VI" "typedef vector<int> vi;")
("VB" "typedef vector<bool> vb;")
("VVI" "typedef vector<vi> vvi;")))
(global-set-key (kbd "S-C-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-<down>") 'shrink-window)
(global-set-key (kbd "S-C-<up>") 'enlarge-window)
;(require 'rtags)
;(add-hook 'c-mode-hook 'rtags-start-process-unless-running)
;(add-hook 'c++-mode-hook 'rtags-start-process-unless-running)
;; (add-hook 'objc-mode-hook 'rtags-start-process-unless-running)
(require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-anzu-mode +1)
(require 'irony)
(defun my-irony-mode-hook ()
"Copy-pasted from github."
(define-key irony-mode-map [remap completion-at-point]
'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
'irony-completion-at-point-async))
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(require 'flycheck-irony)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
(require 'flycheck)
;(global-flycheck-mode)
(setq irony-additional-clang-options '("-std=c++17" "-I.")
flycheck-idle-change-delay 2)
(require 'company)
(setq company-idle-delay 0.5
company-minimum-prefix-length 2
company-global-modes '(not org-mode))
;(setq company-global-modes '(not fundamental-mode))
(add-hook 'after-init-hook 'global-company-mode)
(eval-after-load 'company
'(add-to-list 'company-backends 'company-irony))
;(require 'subr-x)
;(cmake-ide-setup)
(require 'gdb-mi)
(setq gdb-many-windows t)
(require 'company-irony-c-headers)
(eval-after-load 'company
'(add-to-list
'company-backends '(company-irony-c-headers company-irony)))
(require 'magit)
(global-set-key (kbd "C-x g") 'magit-status)
(require 'ace-window)
(global-set-key (kbd "C-x o") 'ace-window)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(aw-leading-char-face ((t (:inherit ace-jump-face-foreground :height 3.0 :foreground "GreenYellow")))))
(require 'paren)
(setq show-paren-delay 0)
(show-paren-mode 1)
(setq show-paren-style 'expression)
(require 'apropos)
(setq apropos-sort-by-scores t)
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t)
(require 'pdf-tools)
(pdf-tools-install)
(require 'latex-preview-pane)
;(latex-preview-pane-enable)
(put 'erase-buffer 'disabled nil)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(require 'org)
(defun krofna-hack ()
(when (looking-back (rx "$ ")) ; (or "$ " "$, " "$. ")
(save-excursion
(backward-char 2)
(org-toggle-latex-fragment))))
(add-hook 'org-mode-hook
(lambda ()
(org-cdlatex-mode)
(add-hook 'post-self-insert-hook #'krofna-hack 'append 'local)))
(require 'cdlatex)
(add-to-list 'cdlatex-math-modify-alist '(?B "\\mathbb" nil t nil nil))
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-hide-emphasis-markers t
org-latex-listings 'minted
org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")
org-startup-with-latex-preview t
org-src-tab-acts-natively t
org-format-latex-options (plist-put org-format-latex-options :scale 1.2)
org-log-done 'note
org-confirm-babel-evaluate nil
org-src-fontify-natively t
org-use-property-inheritance t
org-agenda-files '("~/Documents/life.org")
org-todo-keywords '((sequence "HABIT" "|" "DONE-HABIT") (sequence "TODO" "DOING" "|" "DONE"))
org-todo-keyword-faces '(("DOING" . "purple") ("HABIT" . (:foreground "blue" :background "orange"))))
(org-babel-do-load-languages 'org-babel-load-languages '((C . t)))
(defun org-summary-todo (n-done n-not-done)
"Switch entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cc" 'org-capture)
(load-file "~/.emacs.d/uva.el")
;(set-frame-parameter (selected-frame) 'alpha '(90 . 50))
(provide 'init)
;;; init.el ends here
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("30f7c9e85d7fad93cf4b5a97c319f612754374f134f8202d1c74b0c58404b8df" default))
'(package-selected-packages
'(gnuplot fill-column-indicator yasnippet use-package undo-tree smooth-scroll smex slime rtags restart-emacs powerline pdf-tools paredit neotree multiple-cursors moe-theme magit latex-preview-pane helm-swoop haskell-mode font-lock+ flycheck-irony disaster company-irony-c-headers company-irony cmake-ide cdlatex auctex anzu all-the-icons ace-window ace-jump-mode)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment