summaryrefslogtreecommitdiff
path: root/dotemacs
blob: ec9c30c3779173e36d2c8057398225e82b282b77 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
(package-initialize)

;; -------------------------------------------------------------
;; basic editor look and feel
(setq-default indent-tabs-mode nil)
(setq-default make-backup-files nil)
(setq-default column-number-mode t)
(setq-default tramp-default-user "brad")
(setq-default tramp-default-host "localhost")
(setq-default pgg-default-user-id "Brad Clawsie <brad@b7j0c.org>")
(setq-default pgg-query-keyserver nil)
(setq confirm-nonexistent-file-or-buffer nil)
(setq inhibit-splash-screen t)
(setq display-time-24hr-format t)
(setq debug-on-error t)
(setq next-line-add-newlines nil)
(setq scroll-step 1)
(set-input-mode nil nil t)
(display-time)
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'blink-cursor-mode) (blink-cursor-mode 0))
(setq-default transient-mark-mode t)

;; -------------------------------------------------------------
;; shortcuts
(global-set-key "\C-l" 'goto-line)
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key (kbd "\C-x w") 'kill-region)
(global-set-key (kbd "<f3>") 'magit-status)
(global-set-key (kbd "<f4>") 'eshell)
(global-set-key (kbd "<f5>") 'rename-buffer)
(fset 'switchbuffers
   [?\C-x ?b])
(global-set-key (kbd "C-c b") 'switchbuffers)

;; -------------------------------------------------------------
;; common input
(global-set-key [mouse-2] 'yank)
(global-font-lock-mode 1)
(fset 'yes-or-no-p 'y-or-n-p)

;; -------------------------------------------------------------
;; show whitespace
(setq-default show-trailing-whitespace t)
(setq-default indicate-empty-lines t)
(setq-default indicate-buffer-boundaries 'left)

;; -------------------------------------------------------------
;; highlight matching pairs of parentheses
(setq show-paren-delay 0)
(show-paren-mode)

;; -------------------------------------------------------------
;; ido
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
(setq ido-use-filename-at-point 'guess)
(setq ido-create-new-buffer 'always)

;; -------------------------------------------------------------
;; don't get clever and try to ping things that look like domains
(setq ffap-machine-p-known 'reject)

;; -------------------------------------------------------------
;; eshell
(setq eshell-prompt-function
  (lambda nil (concat "" " $ ")))

;; -------------------------------------------------------------
;; melpa
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))

;; -------------------------------------------------------------
;; language modes

;; go save hook
(setq gofmt-command "goimports")
(add-hook 'go-mode-hook (lambda ()
                          (add-hook 'before-save-hook 'gofmt-before-save nil 'local)))

;; .t files perl-mode
(add-to-list 'auto-mode-alist '("\\.t\\'" . perl-mode))

;; run auto-fill whenever editing markdown
(add-hook 'markdown-mode-hook 'auto-fill-mode)

;; zig
(require 'lsp-mode)
(setq lsp-zig-zls-executable "~/.zig/zls-release/zls")

;; -------------------------------------------------------------
;; time-related funcs
(defun insert-time ()
  (interactive)
  (insert (format-time-string "%Y-%m-%d-%R")))

(defun insert-unixtime ()
  (interactive)
  (insert (format-time-string "%s")))

(defun insert-date ()
  (interactive)
  (insert (format-time-string "%Y-%m-%d")))

;; -------------------------------------------------------------
;; revert all buffers with no confirm, and alias to f6
(defun revert-all-buffers ()
  "Refreshes all open buffers from their respective files."
  (interactive)
  (dolist (buf (buffer-list))
    (with-current-buffer buf
      (when (and (buffer-file-name) (file-exists-p (buffer-file-name)) (not (buffer-modified-p)))
        (revert-buffer t t t) )))
      (message "Refreshed open files."))
(global-set-key (kbd "<f6>") 'revert-all-buffers)

;; -------------------------------------------------------------
;; custom
(setq custom-file "~/.custom.el")
(load custom-file :noerror)

;; -------------------------------------------------------------
;; fix weird tls issue with packages
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

;; -------------------------------------------------------------
;; server
(server-start)