Allman style (derivative of Linux with an offset of 2) C# style (full on C# styling (basically Linux, offset of 4))
444 lines
18 KiB
Org Mode
444 lines
18 KiB
Org Mode
#+TITLE: Oreodave's Emacs configuration
|
|
#+AUTHOR: Oreodave
|
|
#+DESCRIPTION: My Doom Emacs configuration!
|
|
|
|
* Preclude
|
|
This is my [[https://github.com/hlissner/doom-emacs][Doom Emacs]] configuration, which I try to use for as many things as
|
|
possible. It is currently my main editor overall, literally overtaking my life.
|
|
* Personal
|
|
Setting up variables and basic stuff that doesn't require a lot of work.
|
|
** Doom Variables
|
|
#+BEGIN_SRC elisp
|
|
(after! core-keybinds
|
|
(setq doom-localleader-key ",")
|
|
(setq doom-theme 'doom-molokai)
|
|
(setq doom-font (font-spec :family "Hack" :size 20)))
|
|
#+END_SRC
|
|
- Set the doom localleader to "," because it's faster
|
|
- Using the font [[https://sourcefoundry.org/hack/][Hack]] with Fira code ligatures
|
|
** Other variables
|
|
#+BEGIN_SRC elisp
|
|
(setq completion-ignore-case t)
|
|
(setq truncate-lines t)
|
|
(setq display-line-numbers-type nil)
|
|
(display-battery-mode 1)
|
|
|
|
(setq-default frame-title-format '("%b - εmacs"))
|
|
|
|
(cl-pushnew '("Libgen" "https://libgen.me/search/all?search=%s") +lookup-provider-url-alist :key #'car)
|
|
#+END_SRC
|
|
Some quality of life things and others that I couldn't really put in one category
|
|
- Displaying line numbers isn't usually something I do. If need be, I'll just
|
|
open them with *<SPC>tl*.
|
|
- Set org directory
|
|
- Add libgen to search providers
|
|
- Looking at my battery percentage isn't very necessary but still really cool
|
|
* Personal functions
|
|
Personal functionality that aid my workflow or are just cool.
|
|
** Reload
|
|
#+BEGIN_SRC elisp
|
|
(defun oreodave/reload ()
|
|
"Reload instance of doom"
|
|
(interactive)
|
|
(load-file (concat doom-private-dir "config.el")))
|
|
#+END_SRC
|
|
Reload the doom session by brute force fully loading the "config.el" file in the
|
|
doom private directory.
|
|
** Go to Books
|
|
#+BEGIN_SRC elisp
|
|
(defun oreodave/goto-books ()
|
|
"Goto the books section"
|
|
(interactive)
|
|
(dired (concat org-directory "/Books")))
|
|
#+END_SRC
|
|
Open a Dired session to the books directory in the org-directory.
|
|
** Change theme
|
|
#+BEGIN_SRC elisp
|
|
(setq oreodave/theme-list '(doom-solarized-dark doom-gruvbox doom-city-lights
|
|
doom-outrun-electric doom-vibrant doom-molokai
|
|
doom-solarized-light doom-acario-light))
|
|
|
|
(defun oreodave/set-new-theme ()
|
|
"Set the theme from my own selection, mutate as you see fit"
|
|
(interactive)
|
|
(ivy-read "Select theme: "
|
|
oreodave/theme-list
|
|
:caller 'oreodave/set-new-theme
|
|
:action (lambda (x) ; Shamelessly copied from counsel in case of change
|
|
(condition-case nil
|
|
(progn
|
|
(mapc #'disable-theme custom-enabled-themes)
|
|
(load-theme (intern x) t)
|
|
(when (fboundp 'powerline-reset)
|
|
(powerline-reset)))
|
|
(error "Problem loading theme %s" x)))))
|
|
#+END_SRC
|
|
Allow user to set a theme from a limited set of candidates, based on
|
|
"oreodave/theme-list".
|
|
|
|
- Themes sanctioned by me:
|
|
- doom-solarized-dark: just the right everything. best for day.
|
|
- doom-gruvbox: good contrast, better for night.
|
|
- doom-city-lights: Eh contrast, quite dark
|
|
- doom-outrun-electric: Interesting colour palette
|
|
- doom-vibrant: Good contrast, bit lighter
|
|
- doom-molokai: hacker style
|
|
- doom-solarized-light: Light orange theme that's actually okay on the eyes
|
|
- doom-acario-light: Light theme with not bad colours
|
|
- Themes not sanctioned:
|
|
- Any of the base16 themes for anything other than editing code, not org.
|
|
Contrast isn't good enough
|
|
- Light themes other than Emacs default, maybe sometimes solarized-light
|
|
- Horrid low contrast ones with no colour. Grayscale particularly. I can't
|
|
handle those.
|
|
** Go to School directory
|
|
#+BEGIN_SRC elisp
|
|
(defun oreodave/goto-school ()
|
|
"Goto the school directory"
|
|
(interactive)
|
|
(dired (expand-file-name "~/School")))
|
|
#+END_SRC
|
|
Going to the school directory, quick access to school work.
|
|
** Weather
|
|
#+BEGIN_SRC elisp
|
|
(defun oreodave/weather ()
|
|
"Check the weather at the 'location' stored in password store"
|
|
(interactive)
|
|
(wttrin (password-store-get "location")))
|
|
#+END_SRC
|
|
Function to quickly check weather, which is what I wanted wttrin for.
|
|
** Oreomode
|
|
#+BEGIN_SRC elisp
|
|
(defun oreodave/oreomode()
|
|
(interactive)
|
|
(evil-window-vsplit) ; Full length vertical
|
|
(evil-window-split) ; half length horizontal
|
|
(+treemacs/toggle)
|
|
(message "Oreomode complete!"))
|
|
#+END_SRC
|
|
A little routine to turn on most of my helper things that I use on a daily basis
|
|
but put into its own procedure because I don't want it active all the time.
|
|
* Packages Config
|
|
** Projectile
|
|
#+BEGIN_SRC elisp
|
|
(after! projectile
|
|
(setq oreodave-tags-alist '("Makefile" "node_modules" "bin" "dist" "obj" "'*.json'"))
|
|
(defun oreodave/config/construct-tags ()
|
|
(reduce (lambda (x y) (concat x y)) (mapcar (lambda (i) (concat " --exclude=" i)) oreodave-tags-alist)
|
|
:initial-value "exctags -Re ")
|
|
)
|
|
(setq projectile-tags-command (oreodave/config/construct-tags))
|
|
(cl-pushnew "CMakeLists.txt" projectile-project-root-files :test #'string=))
|
|
#+END_SRC
|
|
|
|
Really simple, just want to set projectile-tags-command when projectile has
|
|
loaded, and easily add new ignores if necessary. Add a new ignore to the tags-alist.
|
|
|
|
Add a few items to the projectile-root-files list
|
|
** DAP
|
|
#+BEGIN_SRC elisp
|
|
(after! dap-mode
|
|
(defun oreodave/debug ()
|
|
(interactive)
|
|
(dap-ui-mode)
|
|
(dap-ui-locals)
|
|
(dap-ui-sessions))
|
|
(map!
|
|
:leader
|
|
:desc "Start debugging setup" "cD" #'oreodave/debug))
|
|
#+END_SRC
|
|
A keybind and a routine
|
|
|
|
- Routine sets up the panes that I like to use, instead of having to M-x'ing it
|
|
- *<SPC>cD* starts up the routine
|
|
|
|
** Wakatime
|
|
#+BEGIN_SRC elisp
|
|
(after! wakatime-mode
|
|
(setq wakatime-cli-path (expand-file-name "~/.local/bin/wakatime"))
|
|
(setq wakatime-api-key (password-store-get "Keys/Wakatime"))
|
|
(global-wakatime-mode +1))
|
|
#+END_SRC
|
|
Using new password holder (pass) to help with secure transactions. Doing all
|
|
other stuff as well, cos Henrik may remove the Wakatime module.
|
|
** Elfeed
|
|
#+BEGIN_SRC elisp
|
|
(after! elfeed
|
|
(defun oreodave/elfeed/load-feeds ()
|
|
(interactive)
|
|
(setq elfeed-feeds nil)
|
|
(elfeed-load-opml (concat org-directory "/elfeed.opml")))
|
|
|
|
(defun oreodave/elfeed/on-new-feed ()
|
|
(interactive)
|
|
(elfeed-org-export-opml)
|
|
(write-file (concat org-directory "/elfeed.opml"))
|
|
(kill-current-buffer))
|
|
|
|
(map!
|
|
(:map elfeed-search-mode-map
|
|
:localleader
|
|
:desc "Update feeds" "u" #'elfeed-update)
|
|
(:leader
|
|
:prefix "o"
|
|
:desc "Open RSS" "f" #'=rss))
|
|
|
|
(add-hook 'elfeed-org-new-entry-hook 'oreodave/elfeed/on-new-feed))
|
|
#+END_SRC
|
|
** Dashboard
|
|
#+BEGIN_SRC elisp
|
|
(defun doom-display-benchmark-h (&optional return-p)
|
|
"Display a benchmark, showing number of packages and modules, and how quickly
|
|
they were loaded at startup.
|
|
|
|
If RETURN-P, return the message as a string instead of displaying it."
|
|
(funcall (if return-p #'format #'message)
|
|
"εmacs loaded %d packages, %d modules in %.03fs"
|
|
(- (length load-path) (length doom--initial-load-path))
|
|
(if doom-modules (hash-table-count doom-modules) 0)
|
|
(or doom-init-time
|
|
(setq doom-init-time
|
|
(float-time (time-subtract (current-time) before-init-time))))))
|
|
|
|
(setq fancy-splash-image "~/Pictures/space.png") ; splash image
|
|
(setq +doom-dashboard-name "*dashboard*")
|
|
|
|
(setq +doom-dashboard-functions ; limit the dashboard items
|
|
'(doom-dashboard-widget-banner
|
|
doom-dashboard-widget-shortmenu
|
|
doom-dashboard-widget-loaded))
|
|
|
|
(setq +doom-dashboard-menu-sections ; Set a specific amount of items
|
|
'(("Open org-agenda"
|
|
:icon (all-the-icons-octicon "calendar" :face 'font-lock-keyword-face)
|
|
:when (fboundp 'org-agenda)
|
|
:action org-agenda)
|
|
("Open books"
|
|
:icon (all-the-icons-octicon "book" :face 'font-lock-keyword-face)
|
|
:action oreodave/goto-books)
|
|
("Check the weather"
|
|
:icon (all-the-icons-wicon "rain" :face 'font-lock-keyword-face)
|
|
:action oreodave/weather)
|
|
("Jump to bookmark"
|
|
:icon (all-the-icons-octicon "bookmark" :face 'font-lock-keyword-face)
|
|
:action bookmark-jump)))
|
|
#+END_SRC
|
|
- Space image comes from [[https://flaticon.com][website]]
|
|
- Remove the Github link to the official Doom Emacs repository: it's in muscle memory
|
|
at this point.
|
|
- Added my own menu items:
|
|
- Books
|
|
- Weather
|
|
** Org calendar
|
|
#+BEGIN_SRC elisp
|
|
(use-package! org-gcal
|
|
:config
|
|
(setq org-gcal-client-id (password-store-get "GoogleCalendar/id"))
|
|
(setq org-gcal-client-secret (password-store-get "GoogleCalendar/secret"))
|
|
(setq org-gcal-file-alist '(("aryadevchavali1@gmail.com" . "~/Text/schedule.org"))))
|
|
#+END_SRC
|
|
* Language Config
|
|
** C-style languages
|
|
#+BEGIN_SRC elisp
|
|
(after! cc-mode
|
|
(c-add-style "Allman"
|
|
'((c-basic-offset . 2)
|
|
(c-comment-only-line-offset . 0)
|
|
(c-hanging-braces-alist (brace-list-open)
|
|
(brace-entry-open)
|
|
(substatement-open after)
|
|
(block-close . c-snug-do-while)
|
|
(arglist-cont-nonempty))
|
|
(c-cleanup-list brace-else-brace)
|
|
(c-offsets-alist
|
|
(statement-block-intro . +)
|
|
(knr-argdecl-intro . 0)
|
|
(substatement-open . 0)
|
|
(substatement-label . 0)
|
|
(label . 0)
|
|
(statement-cont . +))))
|
|
(c-add-style "C#"
|
|
'((c-basic-offset . 4)
|
|
(c-comment-only-line-offset .0)
|
|
(c-hanging-braces-alist (brace-list-open)
|
|
(brace-entry-open)
|
|
(substatement-open after)
|
|
(block-close . c-snug-do-while)
|
|
(arglist-cont-nonempty))
|
|
(c-cleanup-list brace-else-brace)
|
|
(c-offsets-alist
|
|
(statement-block-intro . 0)
|
|
(knr-argdecl-intro . 0)
|
|
(substatement-open . 0)
|
|
(substatement-label . 0)
|
|
(statement-cont . +)
|
|
(label . 0)))))
|
|
#+END_SRC
|
|
Emacs doesn't have the full range of styles that I want, so lemme just do it myself.
|
|
** CSharp
|
|
#+BEGIN_SRC elisp
|
|
(after! csharp-mode
|
|
(setq omnisharp-server-executable-path "~/bin/omnisharp/run")
|
|
(defun oreodave/csharp/get-unit-test-in-project ()
|
|
"Unit test anywhere using CTags or ETags and C#"
|
|
(interactive)
|
|
(let* ((tags-file (counsel-etags-locate-tags-file))
|
|
(cands (counsel-etags-collect-cands "void.*Test" t buffer-file-name))) ; void.*Test assumes your tests are using something like XUnit and end with Test
|
|
(ivy-read
|
|
"Choose test: "
|
|
cands
|
|
:action
|
|
(lambda (item)
|
|
;; From the counsel-etags file-open-api function
|
|
(when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" item)
|
|
(let*
|
|
((file (match-string-no-properties 1 item))
|
|
(linenum (match-string-no-properties 2 item))
|
|
;; always calculate path relative to TAGS
|
|
(default-directory (counsel-etags-tags-file-directory)))
|
|
|
|
(counsel-etags-push-marker-stack (point-marker))
|
|
(find-file file)
|
|
(counsel-etags-forward-line linenum)
|
|
(omnisharp-unit-test-at-point))))
|
|
:caller 'oreodave/csharp/get-unit-tests-in-project)))
|
|
|
|
(setq c-basic-offset 4)
|
|
(c-set-style "java"))) ; Hook for csharp setting variables
|
|
(add-hook! 'csharp-mode-hook
|
|
'(lambda()
|
|
(omnisharp-mode)
|
|
(map! ; CSharp Keybinds
|
|
:map csharp-mode-map
|
|
:localleader
|
|
:desc "Format buffer" "=" #'omnisharp-code-format-entire-file
|
|
(:prefix "t"
|
|
:desc "Select Test in Project" "t" #'oreodave/csharp/get-unit-test-in-project)))
|
|
#+END_SRC
|
|
|
|
- I have custom installed the omnisharp roslyn executable, so I'd rather use
|
|
that
|
|
- C# code is better at 4 space indents, but I indent most of my C code at 2
|
|
space indents because it looks nicer :)
|
|
- Implemented my own function which piggy backs counsel etags to globally search
|
|
tags for test specific context, then goes to it and uses an omnisharp test
|
|
command to unit test it. Basically global test search in C# projects. To use
|
|
this, just make sure you have tags compiled and that all your tests are
|
|
written as some public void *name* _Test (i.e. they are appended with _Test so
|
|
that the pattern can be matched)
|
|
** Python
|
|
#+BEGIN_SRC elisp
|
|
(after! python
|
|
(setq python-version-checked t)
|
|
(setq python-python-command "python3")
|
|
(setq python-shell-interpreter "python3")
|
|
(setq flycheck-python-pycompile-executable "python3")
|
|
|
|
(map! ; Python keybinds
|
|
:map python-mode-map
|
|
:localleader
|
|
:desc "Start python minor" "c" #'run-python
|
|
:desc "Format buffer" "=" #'py-yapf-buffer
|
|
(:prefix "s"
|
|
:desc "Send region REPL" "r" #'python-shell-send-region
|
|
:desc "Send buffer" "b" #'python-shell-send-buffer
|
|
:desc "Send function" "f" #'python-shell-send-defun)))
|
|
#+END_SRC
|
|
- I do python development for Python3, so I need to set the flycheck python checker, as well as the interpreter, to be Python3
|
|
- Most of my python work is in scripts or ideas, so I don't need extensive testing utilities or anything like that
|
|
- I run my python code a LOT and thus need commands for sending bits or whole scripts into the REPL
|
|
** JavaScript/TypeScript
|
|
#+BEGIN_SRC elisp
|
|
(after! typescript-mode
|
|
(setq typescript-indent-level 2)
|
|
(setq tide-format-options '(:indentSize 2 :tabSize 2))
|
|
(after! lsp
|
|
(cl-pushnew '(typescript-mode . "typescript") lsp-language-id-configuration :key #'car)
|
|
(lsp-register-client
|
|
(make-lsp-client
|
|
:new-connection (lsp-stdio-connection "typescript-language-server --stdio")
|
|
:major-modes '(typescript-mode)
|
|
:server-id 'typescript))))
|
|
#+END_SRC
|
|
- Typescript (in my opinion) should be indented by 2
|
|
- Setup the LSP server on the lsp-language-id-config in case it hasn't already
|
|
** Org
|
|
#+BEGIN_SRC elisp
|
|
(setq org-agenda-files "~/Text")
|
|
(setq org-directory "~/Text")
|
|
(map! ; Org keybinds
|
|
:map org-mode-map
|
|
:localleader
|
|
:desc "Org dispatch" "e" #'org-export-dispatch
|
|
:desc "Export to ODT" "E" #'org-pandoc-export-to-odt
|
|
(:prefix ("N" . "+narrow")
|
|
:desc "Narrow to subtree" "n" #'org-narrow-to-subtree
|
|
:desc "Go out of narrow" "o" #'widen
|
|
:desc "Narrow tags" "t" #'org-tags-sparse-tree))
|
|
#+END_SRC
|
|
I like using the org dispatch facilities more than the default export keybinds
|
|
in Doom, so I need this binding
|
|
* Keymap
|
|
#+BEGIN_SRC elisp
|
|
(map!
|
|
:leader
|
|
:desc "Compile via make" "cC" #'+make/run ; I compile stuff all the time
|
|
:desc "Shell command" "!" #'shell-command ; Better than M-!
|
|
|
|
(:prefix ("m" . "personal") ; Personal
|
|
:desc "Open books" "b" #'oreodave/goto-books ; I like my books
|
|
:desc "Open school dir" "s" #'oreodave/goto-school ; I like my schooling
|
|
:desc "Open weather" "w" #'oreodave/weather ; Nah I don't like the weather
|
|
:desc "Change theme" "t" #'oreodave/set-new-theme ; From my own collection
|
|
:desc "Reload emacs" "r" #'oreodave/reload) ; Reload is necessary
|
|
|
|
(:after counsel ; Counsel or ivy
|
|
:desc "M-x" "<SPC>" #'counsel-M-x ; Redefine as M-x because of my muscle memory with spacemacs
|
|
:desc "Find file here" "f." #'counsel-find-file ; Sometimes use this instead of <SPC>ff
|
|
(:prefix ("/" . "search")
|
|
:desc "FZF!" "f" #'counsel-fzf ; Just in case I need a counsel-ui for a gitignored directory
|
|
:desc "RipGrep!" "r" #'counsel-rg ; Ripgrep is faster than Ag in most cases and makes me feel cool
|
|
:desc "Search Tags" "t" #'counsel-etags-find-tag
|
|
:desc "List Tags" "T" #'counsel-etags-list-tag
|
|
:desc "Buffer Tags" "s" #'counsel-imenu
|
|
:desc "Lookup" "o" #'+lookup/online
|
|
:desc "Lookup select" "O" #'+lookup/online-select
|
|
:desc "Search buffer" "/" #'swiper-isearch)); is quicker to do than <SPC>/b, for something that is done so often
|
|
|
|
(:prefix ("w" . "window") ; Windows
|
|
:desc "Close window" "d" #'+workspace/close-window-or-workspace ; is slightly closer together than <SPC>wc
|
|
:desc "Switch window" "W" #'ace-window ; is also used in spacemacs so I'd rather use this
|
|
:desc "Swap windows" "S" #'ace-swap-window) ; allows me to switch windows more efficiently than before, better than just motions
|
|
|
|
(:prefix ("c" . "code") ; Code
|
|
:desc "Fold all in level" "f" #'hs-hide-level
|
|
(:after format-all
|
|
:desc "Format code" "=" #'format-all-buffer)
|
|
(:after lsp
|
|
:desc "Execute action" "a" #'lsp-execute-code-action))
|
|
|
|
(:prefix ("b" . "buffers") ; Buffers
|
|
:desc "Close buffer" "d" #'doom/kill-this-buffer-in-all-windows)
|
|
|
|
(:after projectile
|
|
:desc "Switch to p-buffer" ">" #'projectile-switch-to-buffer ; Opposing <SPC>< which counsel's all buffers
|
|
(:prefix ("p" . "project")
|
|
:desc "Regen tags" "g" #'projectile-regenerate-tags
|
|
:desc "Open project files" "f" #'projectile-find-file))
|
|
|
|
(:prefix ("z" . "font") ; Fonts
|
|
:desc "Increase font" "+" #'doom/increase-font-size
|
|
:desc "Decrease font" "-" #'doom/decrease-font-size
|
|
:desc "Adjust font" "z" #'text-scale-adjust)
|
|
|
|
(:prefix ("F" . "frame") ; Frames
|
|
:desc "Kill frame" "d" #'delete-frame
|
|
:desc "Current buffer frame" "m" #'make-frame
|
|
:desc "Choose Buffer frame" "n" #'display-buffer-other-frame
|
|
:desc "Switch frames" "o" #'other-frame)
|
|
|
|
(:prefix ("o" . "open")
|
|
:after org
|
|
:desc "Calendar" "c" #'=calendar))
|
|
#+END_SRC
|