Added config for doomemacs, removed old emacs configs and adjusted zshconfig and others
Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
This commit is contained in:
@@ -1,532 +0,0 @@
|
||||
#+TITLE: Emacs Configuration from [[https://gitlab.com/TuDatTr/][TuDatTr]]
|
||||
#+SETUPFILE: ~/Templates/Org-Mode/setupfile.org
|
||||
#+OPTIONS: \n:t
|
||||
|
||||
* Preface
|
||||
Before installing and using emacs, emacs should be run as a daemon.
|
||||
This decreases the loading times of the editor enormously and enables you to return to your former emacs session at any time.
|
||||
To do this you first need to make sure ~emace --daemon~ is run during the start up.
|
||||
To access the daemonized emacs you can either run ~emacsclient -t~ to use it in the terminal or simply ~emacsclient~ if you want to use the GUI version.
|
||||
|
||||
* Package installation
|
||||
** Preperation
|
||||
Initialize Emacs builtin package system and add the [[https://melpa.org][melpa]]-package repository.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(require 'package)
|
||||
(setq package-archives '(("melpa" . "http://melpa.org/packages/")
|
||||
("gnu" . "http://elpa.gnu.org/packages/")))
|
||||
(package-initialize)
|
||||
(package-refresh-contents)
|
||||
#+end_src
|
||||
|
||||
** Installation
|
||||
*** [[https://github.com/jwiegley/use-package][use-package]]
|
||||
=A use-package declaration for simplifying your .emacs=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-refresh-contents)
|
||||
(package-install 'use-package))
|
||||
|
||||
(require 'use-package)
|
||||
(setq use-package-always-ensure t)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/rolandwalker/simpleclip][simpleclip]]
|
||||
#+begin_src emacs-lisp
|
||||
(use-package simpleclip
|
||||
:config
|
||||
(simpleclip-mode 1))
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/myrjola/diminish.el][diminish]]
|
||||
=Diminished modes are minor modes with no modeline display=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package diminish)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/emacscollective/no-littering][no-littering]]
|
||||
=Help keeping ~/.emacs.d clean=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package no-littering)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/emacs-evil/evil][evil]]/[[https://github.com/emacs-evil/evil-collection][evil-collection]]
|
||||
=The extensible vi layer for Emacs.=
|
||||
=A set of keybindings for evil-mode=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package evil
|
||||
:init
|
||||
(setq evil-want-keybinding nil)
|
||||
:config
|
||||
(evil-mode 1)
|
||||
(setq evil-search-module 'evil-search)
|
||||
|
||||
)
|
||||
|
||||
(use-package evil-collection
|
||||
:config
|
||||
(evil-collection-init))
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/abo-abo/swiper][Ivy]]/[[https://github.com/abo-abo/swiper][Counsil]]/[[https://github.com/abo-abo/swiper][Swiper]]
|
||||
=Ivy - a generic completion frontend for Emacs=
|
||||
=Swiper - isearch with an overview, and more. Oh, man!=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package prescient)
|
||||
|
||||
(use-package ivy-prescient
|
||||
:config
|
||||
(ivy-prescient-mode 1))
|
||||
|
||||
(use-package ivy)
|
||||
|
||||
(use-package counsel
|
||||
:diminish counsel-mode
|
||||
:config
|
||||
(counsel-mode 1))
|
||||
|
||||
(use-package swiper
|
||||
:bind ("C-s" . 'swiper))
|
||||
#+end_src
|
||||
|
||||
*** [[https://magit.vc/][Magit]]
|
||||
=A Git Porcelain inside Emacs.=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package magit)
|
||||
#+end_src
|
||||
|
||||
*** [[https://www.gnu.org/software/auctex/][AUCTeX]]
|
||||
=an extensible package for writing and formatting TeX files.=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package auctex
|
||||
:defer t
|
||||
:config
|
||||
(setq TeX-parse-self t)
|
||||
(setq-default TeX-master nil)
|
||||
(setq TeX-PDF-mode t)
|
||||
(add-to-list 'TeX-view-program-list '(("Zathura" "zathura %o")))
|
||||
(add-to-list 'TeX-view-program-selection '((output-pdf "Zathura")))
|
||||
)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/yjwen/org-reveal][ox-reveal]]
|
||||
=Exports Org-mode contents to Reveal.js HTML presentation.=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package ox-reveal)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/marsmining/ox-twbs][ox-twbs]]
|
||||
=Export org-mode docs as HTML compatible with Twitter Bootstrap.=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package ox-twbs)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/sabof/org-bullets][org-bullets]]
|
||||
=utf-8 bullets for org-mode=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package org-bullets)
|
||||
#+end_src
|
||||
|
||||
*** [[https://elpa.gnu.org/packages/rainbow-mode.html][rainbow-mode]]
|
||||
=Colorize color names in buffers=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package rainbow-mode)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/Fanael/rainbow-delimiters][rainbow-delimiters]]
|
||||
=Emacs rainbow delimiters mode=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package rainbow-delimiters)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/joaotavora/yasnippet][yasnippet]]
|
||||
=A template system for Emacs=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package yasnippet
|
||||
:ensure
|
||||
:config
|
||||
(setq yas-snippet-dirs '("~/.emacs.d/snippets/"))
|
||||
(yas-reload-all)
|
||||
(add-hook 'prog-mode-hook 'yas-minor-mode)
|
||||
(add-hook 'text-mode-hook 'yas-minor-mode)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/company-mode/company-mode][company-mode]]
|
||||
=Modular in-buffer completion framework for Emacs=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package company
|
||||
:ensure
|
||||
;; :custom
|
||||
;; (company-idle-delay 0.5) ;; how long to wait until popup
|
||||
;; (company-begin-commands nil) ;; uncomment to disable popup
|
||||
:bind
|
||||
(:map company-active-map
|
||||
("C-n". company-select-next)
|
||||
("C-p". company-select-previous)
|
||||
("M-<". company-select-first)
|
||||
("M->". company-select-last))
|
||||
(:map company-mode-map
|
||||
("<tab>" . tab-indent-or-complete)
|
||||
("TAB" . tab-indent-or-complete)))
|
||||
|
||||
(defun company-yasnippet-or-completion ()
|
||||
(interactive)
|
||||
(or (do-yas-expand)
|
||||
(company-complete-common)))
|
||||
|
||||
(defun check-expansion ()
|
||||
(save-excursion
|
||||
(if (looking-at "\\_>") t
|
||||
(backward-char 1)
|
||||
(if (looking-at "\\.") t
|
||||
(backward-char 1)
|
||||
(if (looking-at "::") t nil)))))
|
||||
|
||||
(defun do-yas-expand ()
|
||||
(let ((yas/fallback-behavior 'return-nil))
|
||||
(yas/expand)))
|
||||
|
||||
(defun tab-indent-or-complete ()
|
||||
(interactive)
|
||||
(if (minibufferp)
|
||||
(minibuffer-complete)
|
||||
(if (or (not yas/minor-mode)
|
||||
(null (do-yas-expand)))
|
||||
(if (check-expansion)
|
||||
(company-complete-common)
|
||||
(indent-for-tab-command)))))
|
||||
#+end_src
|
||||
|
||||
# *** [[https://github.com/TommyX12/company-tabnine][tabnine-company]]
|
||||
# =A company-mode backend for TabNine, the all-language autocompleter: https://tabnine.com/=
|
||||
#
|
||||
# #+begin_src emacs-lisp
|
||||
# (use-package company-tabnine
|
||||
# :ensure t)
|
||||
# ;; Trigger completion immediately.
|
||||
# (setq company-idle-delay 0)
|
||||
#
|
||||
# ;; Number the candidates (use M-1, M-2 etc to select completions).
|
||||
# (setq company-show-numbers t)
|
||||
#
|
||||
# (add-to-list 'company-backends #'company-tabnine)
|
||||
# #+end_src
|
||||
|
||||
*** [[https://github.com/flycheck/flycheck][flycheck]]
|
||||
=On the fly syntax checking for GNU Emacs=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package flycheck
|
||||
:ensure
|
||||
:config
|
||||
(global-flycheck-mode))
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/hniksic/emacs-htmlize][htmlize.el]]
|
||||
=Convert buffer text and decorations to HTML.=
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package htmlize)
|
||||
#+end_src
|
||||
|
||||
** lsp-mode
|
||||
#+begin_src emacs-lisp
|
||||
(use-package lsp-mode
|
||||
:ensure
|
||||
:commands lsp
|
||||
:custom
|
||||
;; what to use when checking on-save. "check" is default, I prefer clippy
|
||||
(lsp-rust-analyzer-cargo-watch-command "clippy")
|
||||
(lsp-eldoc-render-all t)
|
||||
(lsp-idle-delay 2.0)
|
||||
;; This controls the overlays that display type and other hints inline. Enable
|
||||
;; / disable as you prefer. Well require a `lsp-workspace-restart' to have an
|
||||
;; effect on open projects.
|
||||
(lsp-rust-server 'rust-analyzer)
|
||||
(lsp-rust-analyzer-server-display-inlay-hints t)
|
||||
(lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
|
||||
(lsp-rust-analyzer-display-chaining-hints t)
|
||||
(lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names t)
|
||||
(lsp-rust-analyzer-display-closure-return-type-hints t)
|
||||
(lsp-rust-analyzer-display-parameter-hints t)
|
||||
(lsp-rust-analyzer-display-reborrow-hints t)
|
||||
:config
|
||||
(add-hook 'lsp-mode-hook 'lsp-ui-mode))
|
||||
(add-hook 'python-mode-hook (lambda() (lsp-python-enable)))
|
||||
|
||||
(use-package lsp-ui
|
||||
:ensure
|
||||
:commands lsp-ui-mode
|
||||
:custom
|
||||
(lsp-ui-peek-always-show t)
|
||||
(lsp-ui-sideline-show-hover t)
|
||||
(lsp-ui-doc-enable nil))
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/brotzeit/rustic][rustic]]
|
||||
=Emacs configuration for Rust=
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package rustic
|
||||
:ensure
|
||||
:bind (:map rustic-mode-map
|
||||
;; ("M-j" . lsp-ui-imenu)
|
||||
("M-?" . lsp-find-references)
|
||||
("C-c C-c l" . flycheck-list-errors)
|
||||
("C-c C-c a" . lsp-execute-code-action)
|
||||
("C-c C-c r" . lsp-rename)
|
||||
("C-c C-c q" . lsp-workspace-restart)
|
||||
("C-c C-c Q" . lsp-workspace-shutdown)
|
||||
("C-c C-c s" . lsp-rust-analyzer-status))
|
||||
:config
|
||||
;; comment to disable rustfmt on save
|
||||
(setq rustic-format-on-save t))
|
||||
#+END_SRC
|
||||
|
||||
*** dash.el
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package dash)
|
||||
#+END_SRC
|
||||
|
||||
*** rust-playground
|
||||
#+begin_src emacs-lisp
|
||||
(use-package rust-playground :ensure)
|
||||
#+end_src
|
||||
|
||||
*** rust-playground
|
||||
#+begin_src emacs-lisp
|
||||
(use-package toml-mode :ensure)
|
||||
#+end_src
|
||||
|
||||
*** lldb
|
||||
#+begin_src emacs-lisp
|
||||
(use-package exec-path-from-shell
|
||||
:ensure
|
||||
:init (exec-path-from-shell-initialize))
|
||||
|
||||
(when (executable-find "lldb-mi")
|
||||
(use-package dap-mode
|
||||
:ensure
|
||||
:config
|
||||
(dap-ui-mode)
|
||||
(dap-ui-controls-mode 1)
|
||||
|
||||
(require 'dap-lldb)
|
||||
(require 'dap-gdb-lldb)
|
||||
;; installs .extension/vscode
|
||||
(dap-gdb-lldb-setup)
|
||||
(dap-register-debug-template
|
||||
"Rust::LLDB Run Configuration"
|
||||
(list :type "lldb"
|
||||
:request "launch"
|
||||
:name "LLDB::Run"
|
||||
:gdbpath "rust-lldb"
|
||||
;; uncomment if lldb-mi is not in PATH
|
||||
;; :lldbmipath "path/to/lldb-mi"
|
||||
))))
|
||||
#+end_src
|
||||
|
||||
*** projectile
|
||||
#+begin_src emacs-lisp
|
||||
(use-package projectile)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/astahlman/ob-async][ob-async]]
|
||||
#+begin_src emacs-lisp
|
||||
(use-package ob-async)
|
||||
#+end_src
|
||||
|
||||
*** [[https://github.com/ledger/ledger-mode][ledger-mode]]
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package ledger-mode
|
||||
:mode ("\\.ledger\\'")
|
||||
:config
|
||||
(autoload 'ledger-mode "ledger-mode" "A major mode for Ledger" t)
|
||||
(add-to-list 'load-path
|
||||
(expand-file-name "/path/to/ledger/source/lisp/"))
|
||||
(add-to-list 'auto-mode-alist '("\\.ledger$" . ledger-mode))
|
||||
)
|
||||
#+END_SRC
|
||||
|
||||
*** [[https://github.com/yoshiki/yaml-mode][yaml-mode]]
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(use-package yaml-mode
|
||||
:config
|
||||
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode)))
|
||||
#+END_SRC
|
||||
|
||||
*** [[https://github.com/ethereum/emacs-solidit][solidity-mode]]
|
||||
#+begin_src emacs-lisp
|
||||
(use-package solidity-mode)
|
||||
#+end_src
|
||||
* Appearance
|
||||
This section is for appearance customization. Either via packages or manually.
|
||||
|
||||
** [[https://github.com/balajisivaraman/emacs-one-themes][emacs-one-themes]]
|
||||
=A port of the Vim/Atom One Dark and Light themes to Emacs=
|
||||
|
||||
##+begin_src emacs-lisp
|
||||
# (use-package one-themes
|
||||
# :init
|
||||
# (load-theme 'one-dark t))
|
||||
##+end_src
|
||||
|
||||
** Transparent Emacs (Commented out)
|
||||
#+begin_comment
|
||||
Makes the default color of the background of emacs the same as the terminals color.
|
||||
This is kind of a janky solution, but it works.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'window-setup-hook
|
||||
'(lambda ()
|
||||
(if not (display-graphic-p)
|
||||
(set-face-background 'default "unspecified-bg"))))
|
||||
#+end_src
|
||||
#+end_comment
|
||||
** Menubar
|
||||
|
||||
Remove the menu/tool-bar at the top of the screen for better immersion.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(menu-bar-mode -1)
|
||||
(tool-bar-mode -1)
|
||||
#+end_src
|
||||
|
||||
* Emacs Configuration
|
||||
** Symbolic Links
|
||||
Follow symlinks without asking for confirmation.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq vc-follow-symlinks t)
|
||||
#+end_src
|
||||
|
||||
** Tab Behavior (spaces > tabs)
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq-default indent-tabs-mode nil)
|
||||
#+END_SRC
|
||||
|
||||
* Mode Configuration
|
||||
** Org-mode
|
||||
*** Enable org-bullets and hide leading stars.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'org-mode-hook
|
||||
(lambda ()
|
||||
(org-bullets-mode 1)
|
||||
(setq org-pretty-entities f)
|
||||
(setq org-src-fontify-natively 1)))
|
||||
#+end_src
|
||||
|
||||
*** Enable utf8x on latex output
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-latex-inputenc-alist '(("utf8" . "utf8x")))
|
||||
#+end_src
|
||||
|
||||
*** minted options for pdfexport
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-latex-listings 'minted
|
||||
org-latex-packages-alist '(("" "minted"))
|
||||
org-latex-pdf-process
|
||||
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
|
||||
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
|
||||
#+end_src
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-latex-minted-options '(("breaklines" "true")
|
||||
("breakanywhere" "true")))
|
||||
#+end_src
|
||||
|
||||
** yassnipped code completion in company
|
||||
https://robert.kra.hn/posts/rust-emacs-setup/#changelog
|
||||
#+begin_src emacs-lisp
|
||||
(defun company-yasnippet-or-completion ()
|
||||
(interactive)
|
||||
(or (do-yas-expand)
|
||||
(company-complete-common)))
|
||||
|
||||
(defun check-expansion ()
|
||||
(save-excursion
|
||||
(if (looking-at "\\_>") t
|
||||
(backward-char 1)
|
||||
(if (looking-at "\\.") t
|
||||
(backward-char 1)
|
||||
(if (looking-at "::") t nil)))))
|
||||
|
||||
(defun do-yas-expand ()
|
||||
(let ((yas/fallback-behavior 'return-nil))
|
||||
(yas/expand)))
|
||||
|
||||
(defun tab-indent-or-complete ()
|
||||
(interactive)
|
||||
(if (minibufferp)
|
||||
(minibuffer-complete)
|
||||
(if (or (not yas/minor-mode)
|
||||
(null (do-yas-expand)))
|
||||
(if (check-expansion)
|
||||
(company-complete-common)
|
||||
(indent-for-tab-command)))))
|
||||
#+end_src
|
||||
|
||||
*** Keybindings
|
||||
#+begin_src emacs-lisp
|
||||
(define-key org-mode-map (kbd "C-c ,") 'org-insert-structure-template)
|
||||
(define-key evil-visual-state-map "Y" 'simpleclip-copy)
|
||||
#+end_src
|
||||
|
||||
Enables specific languages for org-babel, so those languages can be used and compiled in code blocks and disable the compilation confirmation. The code afterwords enables proper indentation inside those source blocks.
|
||||
#+begin_src emacs-lisp
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'((emacs-lisp . t)
|
||||
(C . t)
|
||||
(makefile . t)
|
||||
(shell . t)
|
||||
(latex . t)
|
||||
;; (rust . t)
|
||||
(python . t)))
|
||||
|
||||
(setq org-confirm-babel-evaluate nil)
|
||||
(setq org-src-tab-acts-natively t)
|
||||
#+end_src
|
||||
|
||||
** C-mode
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'c-mode-hook
|
||||
(lambda ()
|
||||
(display-line-numbers-mode 1)))
|
||||
#+end_src
|
||||
|
||||
** C++-mode
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'c++-mode-hook
|
||||
(lambda ()
|
||||
(display-line-numbers-mode 1)))
|
||||
#+end_src
|
||||
|
||||
** p4-mode
|
||||
#+begin_src emacs-lisp
|
||||
(add-to-list 'auto-mode-alist '("\\.p4\\'" . c-mode))
|
||||
#+end_src
|
||||
|
||||
** markdown-mode
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'markdown-mode-hook
|
||||
(lambda ()
|
||||
(setq markdown-fontify-code-blocks-natively t)))
|
||||
#+end_src
|
||||
Reference in New Issue
Block a user