aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/init-misc.el
blob: 2dc3dd54de49b86e1c1b40172522383f3fb654a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(setq tab-always-indent 'complete
      completion-cycle-threshold t)

(setq scroll-conservatively most-positive-fixnum)

(when (version<= "26.0.50" emacs-version)
  (global-display-line-numbers-mode))
(setq vc-follow-symlinks t)
(setq find-file-visit-truename t)
(setq enable-recursive-minibuffers t)

;; Disable evil operation writes clipboard
(setq x-select-enable-clipboard nil)

(setq
 backup-by-copying t
 delete-old-versions t
 kept-new-versions 10
 kept-old-versions 2
 version-control t
 backup-directory-alist `(("." . ,(concat user-emacs-directory "backups"))))

(setq auto-save-file-name-transforms
      `((".*" "~/.emacs.d/backups/" t)))

(setq-default fill-column 72)
(setq-default indent-tabs-mode nil)
(setq-default
 recentf-max-saved-items 1024
 recentf-exclude `("/tmp/"))
(setq show-paren-when-point-inside-paren t
      show-paren-when-point-in-periphery t)

(add-hook 'prog-mode-hook #'hs-minor-mode) ;; allow folding
(add-hook 'after-init-hook
	  (lambda ()
	    (global-hl-line-mode)
	    (menu-bar-mode -1)
	    (xterm-mouse-mode 1) ;; Enable mouse
	    (tool-bar-mode -1)
            (scroll-bar-mode -1)
            ;; Auto reload buffers whenever they are updated externally
	    (global-auto-revert-mode t)
	    (global-so-long-mode 1) ;; Disable some modes when the files are so long
	    (recentf-mode)
	    (show-paren-mode)
	    (fset 'yes-or-no-p 'y-or-n-p)
            ;; Show column number in modeline
            (column-number-mode)
            ;; Show the size of file in modeline
            (size-indication-mode))
          'append)

(with-eval-after-load 'hideshow
  (gx/diminish 'hs-minor-mode))

(setq avy-background t
      avy-all-windows t
      avy-timeout-seconds 0.3)
(when (gx/maybe-require-package 'avy)
  (with-eval-after-load 'evil
    (evil-define-key 'normal 'global
      (kbd "<SPC>j") 'evil-avy-goto-line-below
      (kbd "<SPC>k") 'evil-avy-goto-line-above
      (kbd "<SPC>w") 'evil-avy-goto-word-0
      (kbd "<SPC>f") 'evil-avy-goto-char)
    (evil-define-key 'visual 'global
      (kbd "<SPC>j") 'evil-avy-goto-line-below
      (kbd "<SPC>k") 'evil-avy-goto-line-above)
    (evil-define-key 'operator 'global
      (kbd "<SPC>j") 'evil-avy-goto-line-below
      (kbd "<SPC>k") 'evil-avy-goto-line-below)))
 
(gx/maybe-require-package 'rg)
(gx/maybe-require-package 'esup)

(when (gx/maybe-require-package 'which-key)
  (autoload 'which-key-mode "which-key")
  (add-hook 'after-init-hook 'which-key-mode 'append))
(with-eval-after-load 'which-key
  (gx/diminish 'which-key-mode))

(when (gx/maybe-require-package 'undo-tree)
  (autoload 'global-undo-tree-mode "undo-tree")
  (add-hook 'after-init-hook 'global-undo-tree-mode 'append))
(with-eval-after-load 'undo-tree
  (gx/diminish 'undo-tree-mode))
(setq undo-tree-auto-save-history t
      undo-tree-history-directory-alist `(("." . ,(concat user-emacs-directory "undo"))))

(setq eldoc-echo-area-use-multiline-p nil)
(setq eldoc-idle-delay 0.1)
(with-eval-after-load 'eldoc
    (gx/diminish 'eldoc-mode))

(with-eval-after-load 'evil
  (evil-define-key 'normal 'flymake-mode
    (kbd "[g") 'flymake-goto-prev-error
    (kbd "]g") 'flymake-goto-next-error))

(add-hook 'after-init-hook #'winner-mode 'append)
(with-eval-after-load 'evil
  (evil-define-key 'normal 'global
    (kbd "C-w u") 'winner-undo
    (kbd "C-w C-u") 'winner-undo
    (kbd "C-w U") 'winner-redo
    (kbd "C-w C-U") 'winner-redo))

(add-hook 'after-init-hook #'save-place-mode 'append)

(when (gx/maybe-require-package 'edwina)
  (setq display-buffer-base-action '(display-buffer-below-selected))
  (autoload #'edwina-mode "edwina" nil t)
  (add-hook 'after-init-hook #'edwina-mode 'append))

(provide 'init-misc)