Advertisement
Guest User

Untitled

a guest
Nov 26th, 2021
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.78 KB | None | 0 0
  1. ;; early-init.el
  2.  
  3. ;; Code:
  4.  
  5. ;; Installing straight.el
  6. (defvar bootstrap-version)
  7. (let ((bootstrap-file
  8. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  9. (bootstrap-version 5))
  10. (unless (file-exists-p bootstrap-file)
  11. (with-current-buffer
  12. (url-retrieve-synchronously
  13. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  14. 'silent 'inhibit-cookies)
  15. (goto-char (point-max))
  16. (eval-print-last-sexp)))
  17. (load bootstrap-file nil 'nomessage))
  18.  
  19. ;; Keep things clean, especially ~/.emacs.d
  20. (straight-use-package 'no-littering)
  21. (require 'no-littering)
  22.  
  23. ;; Some tweaking.
  24. (setq gc-cons-threshold (* 100 1000 1000) ; Setting up garbage collection.
  25. read-process-output-max (* 1024 1024)
  26. comp-deferred-compilation t
  27. package-enable-at-startup nil ; Disable package.el in favor of straight.el.
  28. package-native-compile t
  29. inhibit-startup-message t ; Disable startup message, leave to *scratch* buffer.
  30. visible-bell nil ; Disable flashing of screen.
  31. frame-inhibit-implied-resize t) ; Resizing the Emacs frame can be a terribly expensive part of changing the font.
  32.  
  33. ;; UI Tweaking.
  34. (setq frame-title-format
  35. (concat "Emacs"))
  36. (scroll-bar-mode -1) ; Disable visible scrollbar.
  37. (tool-bar-mode -1) ; Disable the toolbar.
  38. (tooltip-mode -1) ; Disable tooltips.
  39. (menu-bar-mode -1) ; Disable the menu bar.
  40.  
  41. (global-visual-line-mode t)
  42. (global-auto-revert-mode t)
  43. (electric-pair-mode t)
  44. (auto-compression-mode t)
  45. (savehist-mode t)
  46. (show-paren-mode t)
  47. (recentf-mode t)
  48.  
  49. (set-face-background 'show-paren-match "#262b36")
  50. (set-face-bold 'show-paren-match t)
  51. (set-face-foreground 'show-paren-match "#ffffff")
  52.  
  53. ;; The alias to save life.
  54. (defalias 'yes-or-no-p 'y-or-n-p)
  55.  
  56. ;; Keybindings for what we all used to.
  57. (define-key key-translation-map (kbd "ESC") (kbd "C-g"))
  58. (global-set-key (kbd "C-=") 'text-scale-increase)
  59. (global-set-key (kbd "C--") 'text-scale-decrease)
  60. ;; init.el
  61.  
  62. ;; Code:
  63.  
  64. (setq use-dialog-box nil
  65. compilation-scroll-output 'first-error
  66. default-frame-parameters '((inhibit-double-buffering . t))
  67. ad-redefinition-action 'accept
  68. create-locked nil
  69. native-comp-deferred-compilation t
  70. auto-revert-use-notify nil
  71. split-width-threshold nil
  72. electric-pair-preserve-balance nil)
  73.  
  74. (setq-default auto-save-default nil
  75. create-lockfiles nil
  76. make-backup-files nil
  77. cursor-type 'bar
  78. truncate-lines t
  79. word-wrap t)
  80.  
  81. (setq custom-file (concat user-emacs-directory "custom.el"))
  82.  
  83. ;; Some basic things.
  84. (add-to-list 'default-frame-alist '(width . 72))
  85. (add-to-list 'default-frame-alist '(height . 35))
  86.  
  87. ;; Set default font
  88. (set-face-attribute 'default nil
  89. :family "CascadiaCode"
  90. :height 115
  91. :weight 'normal
  92. :width 'normal)
  93.  
  94. ;; Relative Line Numbers on side.
  95. (setq-default display-line-numbers-grow-only t
  96. display-line-numbers-type 'relative
  97. display-line-numbers-width 2)
  98. (global-display-line-numbers-mode)
  99.  
  100. ;; Save life by automatically adding spaces between operators.
  101. (straight-use-package 'electric-operator)
  102. (add-hook 'prog-mode-hook 'electric-operator-mode)
  103. (add-hook 'emacs-lisp-mode-hook #'(lambda () (electric-operator-mode -1)))
  104. (add-hook 'sh-mode-hook #'(lambda () (electric-operator-mode -1)))
  105.  
  106. ;; Major mode for Markdown text format.
  107. (straight-use-package 'markdown-mode)
  108. (setq markdown-command "multimarkdown")
  109.  
  110. ;; Very powerful undo/redo system.
  111. (straight-use-package 'undo-tree)
  112. (global-undo-tree-mode)
  113.  
  114. ;; Highlight your indentation to make things more simple.
  115. (straight-use-package 'highlight-indent-guides)
  116. (setq highlight-indent-guides-method 'character)
  117. (add-hook 'prog-mode 'highlight-indent-guides-mode)
  118.  
  119. ;; Keep your code always indented. That's it.
  120. (straight-use-package 'aggressive-indent)
  121. (aggressive-indent-global-mode +1)
  122.  
  123. ;; Higlight your Brackets...()
  124. (straight-use-package 'rainbow-delimiters)
  125. (add-hook 'prog-mode 'rainbow-delimiters-mode)
  126.  
  127. ;; A easy-to-use project manager.
  128. (straight-use-package 'projectile)
  129. (projectile-mode +1)
  130.  
  131. ;; Beautifying Emacs.
  132.  
  133. ;; Using icons.
  134. (straight-use-package 'all-the-icons)
  135. (straight-use-package 'all-the-icons-completion)
  136. (all-the-icons-completion-mode)
  137. (add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)
  138. (straight-use-package 'all-the-icons-dired)
  139. (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
  140. (put 'dired-find-alternate-file 'disabled nil)
  141.  
  142. ;; A warm theme.
  143. (straight-use-package 'doom-themes)
  144. (load-theme 'doom-wilmersdorf t)
  145.  
  146. ;; Perfect eyecandy modeline.
  147. (straight-use-package 'doom-modeline)
  148. (add-hook 'window-setup-hook #'doom-modeline-mode)
  149. (setq doom-modeline-buffer-encoding nil
  150. doom-modeline-buffer-file-name-style 'file-name
  151. doom-modeline-unicode-fallback t)
  152.  
  153. ;; Very straight-forward dashboard.
  154. (straight-use-package 'dashboard)
  155. (setq dashboard-startup-banner (concat user-emacs-directory "logo.png"))
  156. (dashboard-setup-startup-hook)
  157. (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
  158. (setq dashboard-set-heading-icons t)
  159. (setq dashboard-set-file-icons t)
  160. (setq dashboard-set-navigator t)
  161. (setq dashboard-banner-logo-title "Welcome Back!🤵")
  162. (setq dashboard-center-content t)
  163. (setq dashboard-show-shortcuts t)
  164. (setq dashboard-items '((recents . 3)
  165. (bookmarks . 3)
  166. (projects . 3)))
  167.  
  168. ;; Some UI improvements.
  169.  
  170. ;; Popup that makes life easier.
  171. (straight-use-package 'which-key)
  172. (which-key-mode +1)
  173.  
  174. ;; Easily select items.
  175. (straight-use-package 'vertico)
  176. (vertico-mode +1)
  177.  
  178. ;; Emacs completion style enhancement.
  179. (straight-use-package 'orderless)
  180. (setq completion-styles '(orderless))
  181.  
  182. ;; Enrich completion list with annotations.
  183. (straight-use-package 'marginalia)
  184. (marginalia-mode +1)
  185.  
  186. ;; Text completion framework.
  187. (straight-use-package 'company)
  188. (add-hook 'after-init-hook 'global-company-mode)
  189. (setq company-minimum-prefix-length 1
  190. company-ideal-dealy 0.0
  191. company-tooltip-align-annotations t
  192. company-selection-wrap-around t)
  193. (company-tng-configure-default)
  194.  
  195. ;; Displays current match and total matches information
  196. (straight-use-package 'anzu)
  197. (global-anzu-mode +1)
  198.  
  199. ;; Ligatures
  200. (straight-use-package
  201. '(el-get :type git :host github :repo "mickeynp/ligature.el"))
  202. ;; Enable the "www" ligature in every possible major mode
  203. (ligature-set-ligatures 't '("www"))
  204. ;; Enable all Cascadia Code ligatures in programming modes
  205. (ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "<!--" "####" "~~>" "***" "||=" "||>"
  206. ":::" "::=" "=:=" "===" "==>" "=!=" "=>>" "=<<" "=/=" "!=="
  207. "!!." ">=>" ">>=" ">>>" ">>-" ">->" "->>" "-->" "---" "-<<"
  208. "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->"
  209. "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "</>" "###" "#_(" "..<"
  210. "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~="
  211. "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|"
  212. "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:"
  213. ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:"
  214. "<$" "<=" "<>" "<-" "<<" "<+" "</" "#{" "#[" "#:" "#=" "#!"
  215. "##" "#(" "#?" "#_" "%%" ".=" ".-" ".." ".?" "+>" "++" "?:"
  216. "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)"
  217. "\\\\" "://"))
  218.  
  219. ;; Enables ligature checks globally in all buffers.
  220. (global-ligature-mode t)
  221.  
  222. ;; Emacs as IDE Setup.
  223.  
  224. ;; Setup LSP.
  225. (straight-use-package 'eglot)
  226. (require 'eglot)
  227.  
  228. ;; For C/C++ development.
  229. (add-to-list 'eglot-server-programs '((c-mode c++-mode). ("ccls")))
  230. (add-hook 'c-mode-hook 'eglot-ensure)
  231. (add-hook 'c++-mode-hook 'eglot-ensure)
  232.  
  233. ;; For Python development.
  234. (add-to-list 'eglot-server-programs '((python-mode). ("pylsp")))
  235. (add-hook 'python-mode-hook 'eglot-ensure)
  236.  
  237. ;; For Rust development.
  238. (straight-use-package 'rust-mode)
  239. (add-to-list 'eglot-server-programs '((rust-mode). ("rust-analyzer")))
  240. (add-hook 'rust-mode-hook 'eglot-ensure)
  241.  
  242. ;; Format-on-save.
  243. (add-hook 'c-mode-hook (lambda () (add-hook 'before-save-hook 'eglot-format nil t)))
  244. (add-hook 'c++-mode-hook (lambda () (add-hook 'before-save-hook 'eglot-format nil t)))
  245. (add-hook 'python-mode-hook (lambda () (add-hook 'before-save-hook 'eglot-format nil t)))
  246. (add-hook 'rust-mode-hook (lambda () (add-hook 'before-save-hook 'eglot-format nil t)))
  247.  
  248. ;; Get some fancy highlighting in your code.
  249. (straight-use-package 'tree-sitter)
  250. (straight-use-package 'tree-sitter-langs)
  251. (global-tree-sitter-mode)
  252. (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
  253.  
  254. ;; Docker is here.
  255. (straight-use-package 'dockerfile-mode)
  256.  
  257. ;; Best GIT interface ever, Magit.
  258. (straight-use-package 'magit)
  259.  
  260. ;; The most important tool for a developer, Terminal.
  261. (straight-use-package 'vterm)
  262. (straight-use-package 'vterm-toggle)
  263. (global-set-key [C-f2] 'vterm-toggle-cd)
  264.  
  265. ;; Custom.el
  266.  
  267. ~/.config/emacs ❯ cat custom.el
  268. (custom-set-variables
  269. ;; custom-set-variables was added by Custom.
  270. ;; If you edit it by hand, you could mess it up, so be careful.
  271. ;; Your init file should contain only one such instance.
  272. ;; If there is more than one, they won't work right.
  273. '(warning-suppress-log-types '((comp) (comp) (comp) (comp) (comp) (comp)))
  274. '(warning-suppress-types '((comp) (comp) (comp) (comp) (comp))))
  275. (custom-set-faces
  276. ;; custom-set-faces was added by Custom.
  277. ;; If you edit it by hand, you could mess it up, so be careful.
  278. ;; Your init file should contain only one such instance.
  279. ;; If there is more than one, they won't work right.
  280. )
  281. ~/.config/emacs ❯
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement