Commit ddb348cd authored by David Sveningsson's avatar David Sveningsson
Browse files

emacs: move more config to init.org

parent 2bbf8b29
......@@ -39,26 +39,6 @@
;; load configuration from init.org
(org-babel-load-file "~/.dotfiles/global/emacs.d/init.org")
(use-package ace-window
:ensure t
:init
(progn
(global-set-key [remap other-window] 'ace-window)))
(use-package solarized-theme
:ensure t
:config
(load-theme 'solarized-dark t)
(let ((line (face-attribute 'mode-line :underline)))
(set-face-attribute 'mode-line nil :overline line)
(set-face-attribute 'mode-line-inactive nil :overline line)
(set-face-attribute 'mode-line-inactive nil :underline line)
(set-face-attribute 'mode-line nil :box nil)
(set-face-attribute 'mode-line-inactive nil :box nil))
(setq solarized-distinct-fringe-background t
solarized-high-contrast-mode-line t
solarized-scale-org-headlines nil))
(use-package smerge-mode
:commands smerge-mode
:init
......@@ -84,14 +64,6 @@
;; Load additional files
(load "~/.dotfiles/global/skeletons.el")
; disable menubar/toolbar by default (as early as possible or they pop
; up for a short while while loading cruft)
(menu-bar-mode -1)
(when (fboundp 'tool-bar-mode ) (tool-bar-mode -1))
; truncate lines by default
(setq-default truncate-lines t);
; keybindings
(global-set-key (kbd "<f1>") (lambda () (interactive) (manual-entry (current-word)))) ;show manpage
(global-set-key (kbd "<f2>") 'hippie-expand); complete
......@@ -143,33 +115,6 @@
;; (global-set-key [(C left)] 'subword-backward)
;; (global-set-key [(C right)] 'subword-forward)
; show matching parents
(show-paren-mode 1)
; always show colum
(column-number-mode 1)
; have yes/no questions accept y/n
(fset 'yes-or-no-p 'y-or-n-p)
; show linenumber in sidebar
; requires emacs-23
; snipped from http://nathan-collins--conf.googlecode.com/svn/dot.emacs
(when (require 'linum nil t)
(global-linum-mode t)
;; linum in terminal has no margin after numbers. don't add the
;; margin in x11 since then you get two margins.
(when (null (window-system))
(setq linum-format "%3d ")))
; textwrapping by word instead of char
;(global-visual-line-mode 1)
; consider camelCase as different words
(when (fboundp 'global-subword-mode ) (global-subword-mode 1))
; Tabcompletion of filenames is case-insensitive
(setq read-file-name-completion-ignore-case t);
; Use C-Tab to autocomplete words, instead of default M-/
(global-set-key (kbd "C-<tab>") 'dabbrev-expand)
......@@ -237,22 +182,6 @@
;; personal style. (use c-set-style or C-c .)
(c-add-style "ext" ext-c-style)
;; customized delete-trailing-whitespace which can be toggled
(fset 'ext/original-delete-trailing-whitespace (symbol-function 'delete-trailing-whitespace))
(defun delete-trailing-whitespace () "Augmented delete trailing whitespace function."
(interactive)
(unless (boundp 'my-inhibit-dtw) (ext/original-delete-trailing-whitespace)))
(defun inhibit-dtw () "Toggle whenever to delete trailing whitespace or not."
(interactive)
(if (boundp 'my-inhibit-dtw)
(progn
(kill-local-variable 'my-inhibit-dtw)
(message "dtw enabled"))
(progn
(setq-local my-inhibit-dtw t)
(message "dtw disabled"))))
;; yasnippet
(use-package yasnippet
:ensure t
......
......@@ -4,6 +4,36 @@
#+BEGIN_SRC emacs-lisp
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
#+END_SRC
* Configuration
#+BEGIN_SRC emacs-lisp
; disable menubar/toolbar by default (as early as possible or they pop
; up for a short while while loading cruft)
(menu-bar-mode -1)
(tool-bar-mode -1)
; truncate lines by default
(setq-default truncate-lines t);
; show matching parents
(show-paren-mode 1)
; always show colum
(column-number-mode 1)
; have yes/no questions accept y/n
(fset 'yes-or-no-p 'y-or-n-p)
; show linenumber in sidebar
(global-linum-mode t)
; consider camelCase as different words
(global-subword-mode 1)
; Tabcompletion of filenames is case-insensitive
(setq read-file-name-completion-ignore-case t);
(setq-default fill-column 80)
#+END_SRC
* Swiper / Ivy / Counsel
Swiper gives us a really efficient incremental search with regular expressions
and Ivy / Counsel replace a lot of ido or helms completion functionality
......@@ -60,7 +90,8 @@
(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
))
#+END_SRC
* Avy
* Navigation
** Avy
Navigate by searching for a letter on the screen and jumping to it.
See https://github.com/abo-abo/avy for more info
#+BEGIN_SRC emacs-lisp
......@@ -69,6 +100,16 @@
:bind
("M-s" . avy-goto-word-1))
#+END_SRC
** Ace-window
Quickly switch windows in Emacs
See https://github.com/abo-abo/ace-window for more info
#+BEGIN_SRC emacs-lisp
(use-package ace-window
:ensure t
:init
(progn
(global-set-key [remap other-window] 'ace-window)))
#+END_SRC
* Javascript
** add-node-modules-path
Adds the ~node_modules/.bin~ directory to exec_path.
......@@ -113,11 +154,68 @@
(setq-default js2-basic-offset 2)
(setq-default js2-mode-show-strict-warnings nil))
#+END_SRC
* Web
** web-mode
#+BEGIN_SRC emacs-lisp
(add-to-list 'auto-mode-alist '("\\.php" . web-mode))
(add-to-list 'auto-mode-alist '("\\.php\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\.php\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[gj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.ejs\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.s?css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.njk\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.vue\\'" . web-mode))
(defun my-web-mode-hook ()
(message "Loading my-web-mode-hook...")
;; also take note of editorconfig-custom-hooks which messes with
;; these variables too.
(setq tab-width 2)
(setq web-mode-markup-indent-offset tab-width)
(setq web-mode-css-indent-offset tab-width)
(setq web-mode-code-indent-offset tab-width)
(setq web-mode-sql-indent-offset tab-width)
(setq web-mode-script-padding 0)
(setq web-mode-block-padding 0)
(setq web-mode-enable-auto-pairing t)
(flyspell-prog-mode)
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(delete-trailing-whitespace)))))
(add-hook 'web-mode-hook 'my-web-mode-hook)
#+END_SRC
* Markdown
#+BEGIN_SRC emacs-lisp
(use-package markdown-mode
:ensure t
:init
(add-to-list 'auto-mode-alist '("\\.ngdoc\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("CHANGELOG.md\\'" . markdown-mode)))
#+END_SRC
(defun markdown-hook ()
"markdown hook"
(flyspell-mode 1))
(add-hook 'markdown-mode-hook 'markdown-hook)
* Hydra
#+BEGIN_SRC emacs-lisp
(use-package hydra
:ensure hydra)
#+END_SRC
* Projectile
#+BEGIN_SRC emacs-lisp
(use-package projectile
:init
(projectile-mode +1)
:config
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
#+END_SRC
* Org mode
** Pin repo
#+BEGIN_SRC emacs-lisp
......@@ -217,3 +315,38 @@ Default configuration.
:after treemacs magit
:ensure t)
#+END_SRC
* Theme
#+BEGIN_SRC emacs-lisp
(use-package solarized-theme
:ensure t
:config
(load-theme 'solarized-dark t)
(let ((line (face-attribute 'mode-line :underline)))
(set-face-attribute 'mode-line nil :overline line)
(set-face-attribute 'mode-line-inactive nil :overline line)
(set-face-attribute 'mode-line-inactive nil :underline line)
(set-face-attribute 'mode-line nil :box nil)
(set-face-attribute 'mode-line-inactive nil :box nil))
(setq solarized-distinct-fringe-background t
solarized-high-contrast-mode-line t
solarized-scale-org-headlines nil))
#+END_SRC
* Custom functions
** inhibit-dtw
Customized ~delete-trailing-whitespace~ which can be toggled on/off.
#+BEGIN_SRC emacs-lisp
(fset 'ext/original-delete-trailing-whitespace (symbol-function 'delete-trailing-whitespace))
(defun delete-trailing-whitespace () "Augmented delete trailing whitespace function."
(interactive)
(unless (boundp 'my-inhibit-dtw) (ext/original-delete-trailing-whitespace)))
(defun inhibit-dtw () "Toggle whenever to delete trailing whitespace or not."
(interactive)
(if (boundp 'my-inhibit-dtw)
(progn
(kill-local-variable 'my-inhibit-dtw)
(message "dtw enabled"))
(progn
(setq-local my-inhibit-dtw t)
(message "dtw disabled"))))
#+END_SRC
\ No newline at end of file
(setq-default fill-column 80)
(defun my-html-mode-hook ()
(setq tab-width 2)
......@@ -84,12 +83,6 @@
(add-hook 'local-write-file-hooks '(lambda() (save-excursion (delete-trailing-whitespace)))))
(add-hook 'ruby-mode-hook 'my-ruby-mode-hook)
(use-package projectile
:init
(projectile-mode +1)
:config
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))
(add-hook 'lua-mode-hook
'(lambda()
(message "Loading lua-mode hook...")
......@@ -100,39 +93,6 @@
(delete-trailing-whitespace))))
))
; web-mode
(add-to-list 'auto-mode-alist '("\\.php" . web-mode))
(add-to-list 'auto-mode-alist '("\\.php\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\.php\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[gj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.s?css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.njk\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.vue\\'" . web-mode))
(defun my-web-mode-hook ()
(message "Loading my-web-mode-hook...")
;; also take note of editorconfig-custom-hooks which messes with
;; these variables too.
(setq tab-width 2)
(setq web-mode-markup-indent-offset tab-width)
(setq web-mode-css-indent-offset tab-width)
(setq web-mode-code-indent-offset tab-width)
(setq web-mode-sql-indent-offset tab-width)
(setq web-mode-script-padding 0)
(setq web-mode-block-padding 0)
(setq web-mode-enable-auto-pairing t)
(add-hook 'local-write-file-hooks
'(lambda()
(save-excursion
(delete-trailing-whitespace)))))
(add-hook 'web-mode-hook 'my-web-mode-hook)
;; json, node-gyp
(add-to-list 'auto-mode-alist '("\\.gyp\\'" . json-mode))
......@@ -157,12 +117,6 @@
(delete-trailing-whitespace)))))
(add-hook 'yaml-mode-hook 'my-yaml-mode-hook)
;; markdown
(use-package markdown-mode
:ensure t
:init
(add-to-list 'auto-mode-alist '("\\.ngdoc\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("CHANGELOG.md\\'" . markdown-mode)))
;; Smart tabs (tabs for indentation, spaces for alignment) ;
(use-package smart-tabs-mode
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment