PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/init.el

https://github.com/adlaius/nix-configs
Emacs Lisp | 238 lines | 186 code | 34 blank | 18 comment | 3 complexity | 0c94e47dc23c1333c3ae2de5a0d48be7 MD5 | raw file
  1. ;; tips are now filed in emacs-tips.el
  2. (prefer-coding-system 'utf-8)
  3. ;; "foreground" and "background" are the opposite of what you think here
  4. (set-face-foreground 'mode-line "black")
  5. (set-face-background 'mode-line "white")
  6. (let ((default-directory "~/Source/Repos/lisp/"))
  7. (normal-top-level-add-subdirs-to-load-path))
  8. ;; cf https://debbugs.gnu.org/34341
  9. ;; verify if fixed in 26.3+
  10. (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
  11. (require 'package)
  12. (package-initialize)
  13. (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
  14. (not (gnutls-available-p))))
  15. (proto (if no-ssl "http" "https")))
  16. (when no-ssl
  17. (warn "\
  18. Your version of Emacs does not support SSL connections,
  19. which is unsafe because it allows man-in-the-middle attacks.
  20. There are two things you can do about this warning:
  21. 1. Install an Emacs version that does support SSL and be safe.
  22. 2. Remove this warning from your init file so you won't see it again."))
  23. (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  24. (when (< emacs-major-version 24) ;; For important compatibility libraries like cl-lib
  25. (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
  26. (defvar my-packages
  27. '(better-defaults company company-lsp csv-mode dash-functional deft
  28. elixir-mode flycheck helm helm-slime helm-systemd helm-wordnet
  29. helm-xref helpful lsp-mode lsp-ui magit move-text parinfer
  30. rdf-prefix sparql-mode ttl-mode which-key yasnippet))
  31. (dolist (p my-packages)
  32. (unless (package-installed-p p)
  33. (package-install p)))
  34. (autoload 'sparql-mode "sparql-mode.el"
  35. "Major mode for editing SPARQL files" t)
  36. (add-to-list 'auto-mode-alist '("\\.sparql$" . sparql-mode))
  37. (add-to-list 'auto-mode-alist '("\\.rq$" . sparql-mode))
  38. (autoload 'ttl-mode "ttl-mode" "Major mode for OWL or Turtle files" t)
  39. (add-hook 'ttl-mode-hook
  40. 'turn-on-font-lock)
  41. (setq auto-mode-alist
  42. (append
  43. (list
  44. '("\\.n3" . ttl-mode)
  45. '("\\.ttl" . ttl-mode))
  46. auto-mode-alist))
  47. (require 'better-defaults)
  48. (require 'move-text)
  49. (load-library "dash")
  50. (load-library "dash-functional")
  51. (eval-after-load 'dash '(dash-enable-font-lock))
  52. (require 'helm-config)
  53. (helm-mode)
  54. (require 'eldoc)
  55. (require 'which-key)
  56. (which-key-mode)
  57. (require 'yasnippet)
  58. (require 'lsp-mode)
  59. (require 'lsp-ui)
  60. (require 'company-lsp)
  61. (push 'company-lsp company-backends)
  62. (add-hook 'lsp-mode-hook 'lsp-ui-mode)
  63. (add-hook 'elixir-mode-hook #'lsp)
  64. (add-hook 'elixir-mode-hook 'flycheck-mode)
  65. (require 'deft)
  66. (setq deft-extensions '("txt" "tex" "org" "md"))
  67. (cond ((eq system-type 'windows-nt) (setq deft-directory "~/../../Dropbox/notes"))
  68. ((setq deft-directory "~/Dropbox/notes")))
  69. (setq deft-recursive t)
  70. ;; this is the default but it duplicates the first line when
  71. ;; deft-use-filename-as-title is nil
  72. (setq deft-strip-summary-regexp
  73. (concat "\\("
  74. "[\n\t]" ;; blank
  75. "\\|^#\\+[[:upper:]_]+:.*$" ;; org-mode metadata
  76. "\\)"))
  77. (global-set-key [f8] 'deft)
  78. ;; helm-ify All The Things(TM)
  79. (global-set-key (kbd "C-x C-f") 'helm-find-files) ;; was 'ido-find-file
  80. (global-set-key (kbd "C-x b") 'helm-buffers-list) ;; was 'ido-switch-buffer
  81. (global-set-key (kbd "M-x") 'helm-M-x) ;; was 'execute-extended-command
  82. (global-set-key (kbd "C-h a") 'helm-apropos) ;; was 'apropos-command
  83. (global-set-key (kbd "M-o" ) 'helm-occur)
  84. (setf helm-M-x-fuzzy-match t
  85. helm-apropos-fuzzy-match t
  86. helm-autoresize-mode t
  87. helm-buffers-fuzzy-matching t
  88. helm-completion-in-region-fuzzy-match t
  89. helm-etags-fuzzy-match t
  90. helm-ff-fuzzy-matching t
  91. helm-lisp-fuzzy-completion t
  92. helm-locate-fuzzy-match t
  93. helm-locate-library-fuzzy-match t
  94. helm-mode-fuzzy-match t ;; this is supposed to be the global enable, but it doesn't work for whatever reason
  95. helm-move-to-line-cycle-in-source t
  96. helm-recentf-fuzzy-match t
  97. helm-semantic-fuzzy-match t
  98. helm-session-fuzzy-match t
  99. helm-split-window-in-side-p t)
  100. (setf save-interprogram-paste-before-kill t
  101. apropos-do-all t
  102. mouse-yank-at-point t
  103. require-final-newline t
  104. load-prefer-newer t
  105. ediff-window-setup-function 'ediff-setup-windows-plain
  106. save-place-file (concat user-emacs-directory "places")
  107. backup-directory-alist `(("." . ,(concat user-emacs-directory
  108. "backups"))))
  109. (setq frame-title-format
  110. '(buffer-file-name "%f" ; File buffer
  111. (dired-directory dired-directory ; Dired buffer
  112. (revert-buffer-function "%b" ; Buffer Menu
  113. ("%b - Dir: " default-directory))))) ; Plain buffer
  114. (setq org-fontify-done-headline t
  115. org-fontify-whole-heading-line t
  116. org-hide-leading-stars t
  117. org-highlight-sparse-tree-matches nil
  118. org-n-level-faces 8)
  119. (setq inhibit-startup-message t
  120. tool-bar-mode nil
  121. show-paren-mode t
  122. blink-matching-paren 'jump-offscreen
  123. scroll-bar-mode nil
  124. size-indication-mode t
  125. column-number-mode t
  126. ring-bell-function 'ignore)
  127. (add-hook 'eval-expression-minibuffer-setup-hook #'eldoc-mode)
  128. ;; enhanced thanks to https://emacs.stackexchange.com/a/7550
  129. (defun sort-words (reverse beg end)
  130. "Sort words in region alphabetically, in REVERSE if negative.
  131. Prefixed with negative \\[universal-argument], sorts in reverse.
  132. The variable `sort-fold-case' determines whether alphabetic case
  133. affects the sort order. See `sort-regexp-fields'.
  134. Temporarily consider - and _ characters as part of the word when sorting."
  135. (interactive "*P\nr")
  136. (let ((temp-table (copy-syntax-table text-mode-syntax-table)))
  137. (with-syntax-table temp-table
  138. (modify-syntax-entry ?- "w" temp-table)
  139. (modify-syntax-entry ?_ "w" temp-table)
  140. (sort-regexp-fields reverse "\\w+" "\\&" beg end))))
  141. (if (eq window-system 'ns)
  142. (setq ns-mwheel-line-height 1
  143. ns-use-mwheel-acceleration nil
  144. ns-use-mwheel-momentum 1
  145. ns-command-modifier 'control
  146. ns-option-modifier 'meta)
  147. (setq mouse-wheel-scroll-amount '(5 ((shift) . 1))
  148. mouse-wheel-progressive-speed nil
  149. mouse-wheel-follow-mouse 't
  150. scroll-step 1))
  151. (defun unicode-insert (char)
  152. "Read a unicode code point and insert said character. Input uses
  153. `read-quoted-char-radix'. If you want to copy the values from
  154. the Unicode charts, you should set it to 16."
  155. (interactive (list (read-quoted-char "Char: ")))
  156. (insert-char char))
  157. (defun set-selective-display-dlw (&optional level)
  158. "Fold text indented same of more than the cursor.
  159. If level is set, set the indent level to LEVEL. If
  160. 'selective-display' is already set to LEVEL, clicking F5 again
  161. will unset 'selective-display' by setting it to 0."
  162. (interactive "P")
  163. (if (eq selective-display (1+ (current-column)))
  164. (set-selective-display 0)
  165. (set-selective-display (or level (1+ (current-column))))))
  166. (global-set-key (kbd "<f5>") 'set-selective-display-dlw)
  167. (cond
  168. ((eq system-type 'darwin) (setq inferior-lisp-program "/opt/bin/ccl"))
  169. ((eq system-type 'windows-nt) (setq inferior-lisp-program "C:/apps/clisp"))
  170. (t (setq inferior-lisp-program "/usr/bin/sbcl")))
  171. (setq slime-contribs '(slime-fancy))
  172. (add-to-list 'slime-contribs 'slime-repl)
  173. (org-babel-do-load-languages
  174. 'org-babel-load-languages
  175. '((elixir . t)
  176. (ocaml . t)
  177. (clojure . t)
  178. (scheme . t)
  179. (sparql . t)))
  180. (defun cargo-test ()
  181. "Compile using `cargo test`"
  182. (interactive)
  183. (re-search-backward "^fn ")
  184. (forward-word 2)
  185. (compile (concat "cargo test " (current-word) " -- --nocapture")))
  186. (setq prettify-symbols-alist
  187. ;; other chars are super buggy - fix someday...
  188. ;; use M-x describe-char, M-x insert-char to explore
  189. '(("lambda" . 955)))
  190. (prettify-symbols-mode 1)
  191. (custom-set-variables
  192. ;; custom-set-variables was added by Custom.
  193. ;; If you edit it by hand, you could mess it up, so be careful.
  194. ;; Your init file should contain only one such instance.
  195. ;; If there is more than one, they won't work right.
  196. '(package-selected-packages
  197. (quote
  198. (company-lsp company flycheck lsp-ui helm-lsp ob-elixir yasnippet which-key ttl-mode sparql-mode rdf-prefix parinfer move-text magit lsp-mode helpful helm-xref helm-wordnet helm-systemd helm-slime elixir-mode deft csv-mode better-defaults))))
  199. (custom-set-faces
  200. ;; custom-set-faces was added by Custom.
  201. ;; If you edit it by hand, you could mess it up, so be careful.
  202. ;; Your init file should contain only one such instance.
  203. ;; If there is more than one, they won't work right.
  204. )