Skip to content

Instantly share code, notes, and snippets.

@Sulter
Last active October 30, 2017 19:05
Show Gist options
  • Save Sulter/c419e938fddaf7b1201c to your computer and use it in GitHub Desktop.
Save Sulter/c419e938fddaf7b1201c to your computer and use it in GitHub Desktop.
emacs
;package preload/check
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
(package-initialize)
;git from emacs
(require 'magit)
;project management
(require 'projectile)
(projectile-global-mode)
(fset 'projectile-go-function 'projectile-go) ;WORKAROUND SHOULD BE REMOVED AT SOME POINT!?
;Load/setup auto-complete
;(require 'auto-complete)
;(require 'auto-complete-config)
;(ac-config-default)
;(add-to-list 'ac-sources 'ac-source-c-headers)
;load/setup yasnippet
(require 'yasnippet)
(yas-global-mode 1)
;load/setup iedit
(require 'iedit)
;the recommended ido-alternative
(require 'flx-ido)
(ido-mode 1)
(ido-everywhere 1)
(flx-ido-mode 1)
;; disable ido faces to see flx highlights.
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil)
;enable flycheck
(require 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)
'(flycheck-lintr-caching nil)
;irony stuff
(require 'irony)
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)
;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's asynchronous function
(defun my-irony-mode-hook ()
(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 'irony-mode-hook 'my-irony-mode-hook)
;flycheck irony mode
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
;company stuff
(require 'company)
(global-company-mode)
(require 'company-irony-c-headers)
(require 'company-irony)
;; Load with `irony-mode` as a grouped backend
(eval-after-load 'company
'(add-to-list
'company-backends '(company-irony-c-headers company-irony)))
;turn on semantic mode
;(semantic-mode 1)
;add semantic to auto-complete
;(defun my:add-semantic-to-autocomplete()
; (add-to-list 'ac-sources 'ac-source-semantic)
;)
;(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
;openSCAD things
(autoload 'scad-mode "scad-mode" "A major mode for editing OpenSCAD code." t)
(add-to-list 'auto-mode-alist '("\\.scad$" . scad-mode))
(require 'scad-preview)
;save the current settings
(desktop-save-mode 1)
;show collumn
(setq column-number-mode t)
;(C, C++, Java, etc.) will have 4 spaces as indentation and "linux" style
(setq c-default-style "linux" c-basic-offset 4)
; no tabs!
(setq-default indent-tabs-mode nil)
;fix the switch case indent
(setq c-offsets-alist '((case-label . 4)))
;backup files in dedicated directory!
(setq backup-directory-alist `(("." . "~/.emacs.d/saves")))
;disalbe lockfiles!
(setq create-lockfiles nil)
;show line numbers
(global-linum-mode 1)
;highlight maching parentse
(show-paren-mode 1)
;load theme
(load-theme 'wombat t)
;stop startup message
(setq inhibit-startup-message t)
;fullsize-screen
(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.
'(flycheck-lintr-caching nil)
'(initial-frame-alist (quote ((fullscreen . maximized)))))
;Open c++ major mode for arduino files (.ino)
(setq auto-mode-alist
(append
;; File name (within directory) starts with a dot.
'(("\\.ino\\'" . c++-mode))
auto-mode-alist))
;binding for quick-access to magit (git frontend)
(global-set-key (kbd "C-x g") 'magit-status)
;date insert (function )
(defun insert-date ()
"Inserts standard date time string."
(interactive)
(insert (format-time-string "%c")))
;binding for inserting date
(global-set-key (kbd "C-c d") 'insert-date)
(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.
'(company-template-field ((t (:background "dim gray" :foreground "white smoke"))))
'(company-tooltip ((t (:background "dim gray" :foreground "white smoke"))))
'(company-tooltip-common ((t (:foreground "spring green")))))
;org-mode settings
(require 'org)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
;latex spelling. Requires aspell-danish and flyspell
(setq ispell-dictionary "dansk")
(dolist (hook '(LaTeX-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
(dolist (hook '(latex-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))
;Disable top bar
(menu-bar-mode -1)
(tool-bar-mode -1)
(toggle-scroll-bar -1)
;resizing window with CTRL-ARROW
(global-set-key (kbd "C-c <left>") 'shrink-window-horizontally)
(global-set-key (kbd "C-c <right>") 'enlarge-window-horizontally)
(global-set-key (kbd "C-c <down>") 'shrink-window)
(global-set-key (kbd "C-c <up>") 'enlarge-window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment