Just my emacs configuration, for convenience purposes. It's all copypasted from somewhere and probably breaks itself multiple times.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

252 rader
6.6 KiB

;;; init.el --- just my init file
;;; Commentary:
;;; This is just my init file, and these comments at the start are
;;; here to appease the lint.
;;; Feel free to copy any bits you might need, just don't tell anyone
;;; you got them from me.
;;; Code:
(require 'package)
(add-to-list 'package-archives
'("MELPA" . "http://melpa.org/packages/"))
;; use-package
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;; Allow all themes to run
(setq custom-safe-themes t)
;; Very visual stuff first
;; Mode line
(use-package smart-mode-line
(setq sml/theme 'dark)
;; Font
(set-face-attribute 'default nil :height 105)
(set-face-attribute 'default nil :font "monospace")
;; Theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(use-package base16-theme
(load-theme 'snazzy))
;; Whitespace
(setq-default show-trailing-whitespace t)
;; Misc nice visual stuff
(show-paren-mode 1)
(set-face-attribute 'show-paren-match nil :weight 'normal)
(global-hl-line-mode 0)
(setq column-number-mode t)
(setq ring-bell-function 'ignore)
(menu-bar-mode -1)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
;; End of very visual stuff
;; Customfile
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
;; Increase GC Threshold - Speeds up startup according to zirrostig on GitHub
(setq-default gc-cons-threshold 10000000)
;; Dear emacs,
;; please don't leave garbage all around my filesystem.
(setq backup-directory-alist
`((".*" . ,(concat user-emacs-directory
(setq auto-save-default nil)
(setq create-lockfiles nil)
;; Window switching
(defun prev-window()
"Other-window but with arg -1."
(other-window -1))
(define-key global-map (kbd "C-x o") 'other-window)
(define-key global-map (kbd "C-x p") 'prev-window)
(when (boundp 'term-raw-map)
(define-key term-raw-map (kbd "C-x o") 'other-window)
(define-key term-raw-map (kbd "C-x p") 'prev-window))
;; ANSI escape codes in compilation from
;; http://endlessparentheses.com/ansi-colors-in-the-compilation-buffer-output.html
(use-package ansi-color
(defun endless/colorize-compilation ()
"Colorize from `compilation-filter-start' to `point'."
(let ((inhibit-read-only t))
compilation-filter-start (point))))
(add-hook 'compilation-filter-hook
;; Ido
(use-package ido)
(use-package ido-completing-read+)
(ido-mode t)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point nil)
(setq ido-auto-merge-work-directories-length -1)
(setq ido-use-virtual-buffers t)
(ido-ubiquitous-mode 1)
;; Smex
(use-package smex)
(setq smex-save-file (concat user-emacs-directory ".smex-items"))
(global-set-key (kbd "M-x") 'smex)
;; Langs that don't need much config
(use-package yaml-mode
:mode "\\.yaml\\'")
(use-package toml-mode
:mode "\\.toml\\'")
(use-package gdscript-mode
:mode "\\.gd\\'")
(use-package papyrus-mode
:load-path "papyrus-mode"
:mode "\\.psc\\'")
(use-package scopes-mode
:load-path "scopes-mode"
:mode "\\.sc\\'")
;; Langs that do need config below
;; Rust
(use-package rust-mode
:config (setq rust-format-on-save t))
(use-package flycheck-rust
(with-eval-after-load 'rust-mode
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))
(use-package glsl-mode
:mode ("\\.glsl\\'"
;; Markdown
(use-package markdown-mode)
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
;; Purescript
(use-package psc-ide)
(use-package purescript-mode
(lambda ()
(customize-set-variable 'psc-ide-rebuild-on-save t))
;; JS
(use-package rjsx-mode
:mode ("\\.js\\'"
(setq js-indent-level 2)
(setq js2-strict-missing-semi-warning nil))
;; Elm
;; Keys:
;; - Compile: C-c M-c
;; - Add type annotations: C-c C-a
;; - Clean imports: C-c C-r
;; - Sort imports: C-c C-s
;; - Format: C-c C-f
;; - Test: C-c C-v
(use-package elm-mode
:mode "\\.elm\\'"
(setq elm-sort-imports-on-save t)
(setq elm-format-on-save t))
;; C
(setq c-default-style "k&r"
c-basic-offset 4)
;; Flycheck
(use-package flycheck
(setq flycheck-check-syntax-automatically '(mode-enabled save))
(add-hook 'after-init-hook #'global-flycheck-mode))
(use-package flycheck-inline
:after (flycheck)
(with-eval-after-load 'flycheck
(add-hook 'flycheck-mode-hook #'flycheck-inline-mode)))
;; Org
(use-package org)
(setq org-agenda-files '("~/org"))
(define-key global-map (kbd "C-c l") 'org-store-link)
(define-key global-map (kbd "C-c a") 'org-agenda)
(setq org-checkbox-hierarchical-statistics t)
(setq org-agenda-files '("~/org"))
;; Yanking
(dolist (command '(yank yank-pop))
(eval `(defadvice ,command (after indent-region activate)
(and (not current-prefix-arg)
(member major-mode '(emacs-lisp-mode python-mode
(let ((mark-even-if-inactive transient-mark-mode))
(indent-region (region-beginning) (region-end) nil))))))
;; Tabs
(defun infer-indentation-style ()
(let ((space-count (how-many "^ " (point-min) (point-max)))
(tab-count (how-many "^\t" (point-min) (point-max))))
(if (> space-count tab-count) (setq indent-tabs-mode nil))
(if (> tab-count space-count) (setq indent-tabs-mode t))))
(setq-default indent-tabs-mode nil)
(define-key global-map (kbd "RET") 'newline-and-indent)
;; Rainbow parens
(use-package rainbow-delimiters
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
;; Company
(use-package company
(add-hook 'after-init-hook 'global-company-mode)
(define-key global-map (kbd "<backtab>") 'company-complete))
;; Compiling
(global-set-key [f6] 'recompile)
;; Misc packages
(use-package eldoc)
;; Fix hang on exit in Sway
(setq x-select-enable-clipboard-manager nil)
(provide 'init)
;;; init.el ends here