Browse Source

Reorganize modules

main
parent
commit
845cafc03b
  1. 295
      README.org
  2. 2
      init.el
  3. 32
      modules/projects.el

295
README.org

@ -66,7 +66,7 @@ All of the available modules are defined in the ~dotfiles/modules-available~ con
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defconst dotfiles/modules-available (defconst dotfiles/modules-available
'(core desktop writing projects interface)
'(core editor desktop writing projects interface)
"All of the available modules for hosts to load.") "All of the available modules for hosts to load.")
#+end_src #+end_src
@ -214,7 +214,7 @@ Breaking down the project into logical units or chapters to keep the code more m
Minimal configuration to make Emacs usable for my own personal workflow. This does very little in the ways of improving the visuals, only removing what is included by default and not required. Minimal configuration to make Emacs usable for my own personal workflow. This does very little in the ways of improving the visuals, only removing what is included by default and not required.
*** Cleanup
*** Startup
Emacs creates a lot of files relative to ~user-emacs-directory~, these files are not part of this immutable configuration and do not belong in the emacs directory. How can we solve this issue? Shortly after initialization, before most packages are loaded, we change the value to ~dotfiles/cache~. I elaborate more on the technique in my post [[https://chrishayward.xyz/posts/immutable-emacs/][Immutable Emacs]]. Emacs creates a lot of files relative to ~user-emacs-directory~, these files are not part of this immutable configuration and do not belong in the emacs directory. How can we solve this issue? Shortly after initialization, before most packages are loaded, we change the value to ~dotfiles/cache~. I elaborate more on the technique in my post [[https://chrishayward.xyz/posts/immutable-emacs/][Immutable Emacs]].
@ -334,6 +334,13 @@ Build all of the =org= files within a given directory.
(org-babel-tangle-file f)))) (org-babel-tangle-file f))))
#+end_src #+end_src
** Editor
:PROPERTIES:
:header-args: :tangle modules/editor.el :results silent
:END:
This section contains configuration for improving the editor experience within Emacs.
*** Keys *** Keys
Make the =ESC= key quit (most) prompts, instead of the default =C-g=. Make the =ESC= key quit (most) prompts, instead of the default =C-g=.
@ -342,8 +349,6 @@ Make the =ESC= key quit (most) prompts, instead of the default =C-g=.
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
#+end_src #+end_src
**** Hints
Download [[https://github.com/justbur/emacs-which-key][which-key]], a package that displays the current incomplete keybinding input in a mini-buffer, showing available completion options. Download [[https://github.com/justbur/emacs-which-key][which-key]], a package that displays the current incomplete keybinding input in a mini-buffer, showing available completion options.
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -353,28 +358,6 @@ Download [[https://github.com/justbur/emacs-which-key][which-key]], a package th
:config (which-key-mode)) :config (which-key-mode))
#+end_src #+end_src
**** Leader
Implement the *leader* key using [[https://github.com/noctuid/general.el][general.el]], letting us easily configure prefixed keybindings in a much cleaner manner than the default methods.
#+begin_src emacs-lisp
(use-package general
:config
(general-create-definer dotfiles/leader
:states '(normal motion)
:keymaps 'override
:prefix dotfiles/leader-key
:global-prefix dotfiles/leader-key-global))
#+end_src
Use [[https://github.com/abo-abo/hydra][hydra]] for transient keybindings sharing a common prefix.
#+begin_src emacs-lisp
(use-package hydra)
#+end_src
**** Evil
After a few hour with =vim= I knew it was game over, I cannot even think of another way I would feel comfortable editing text. Luckily, there exist packages to emulate this within Emacs. [[https://evil.readthedocs.io/en/latest/index.html][evil-mode]] is the extensible VI layer for Emacs. After a few hour with =vim= I knew it was game over, I cannot even think of another way I would feel comfortable editing text. Luckily, there exist packages to emulate this within Emacs. [[https://evil.readthedocs.io/en/latest/index.html][evil-mode]] is the extensible VI layer for Emacs.
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -407,19 +390,26 @@ https://github.com/redguardtoo/evil-nerd-commenter
:bind ("M-;" . evilnc-comment-or-uncomment-lines)) :bind ("M-;" . evilnc-comment-or-uncomment-lines))
#+end_src #+end_src
**** Shortcuts
Implement the *leader* key using [[https://github.com/noctuid/general.el][general.el]], letting us easily configure prefixed keybindings in a much cleaner manner than the default methods.
Again cherry picked from =Doom=, I want to continue utilizing the muscle memory I have developed from a year of mainlining the framework.
#+begin_src emacs-lisp
(use-package general
:config
(general-create-definer dotfiles/leader
:states '(normal motion)
:keymaps 'override
:prefix dotfiles/leader-key
:global-prefix dotfiles/leader-key-global))
#+end_src
+ Close buffers with =SPC c=
+ Find files with =SPC . (period)=
Use [[https://github.com/abo-abo/hydra][hydra]] for transient keybindings sharing a common prefix.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(dotfiles/leader
"." '(find-file :which-key "Files")
"c" '(kill-buffer-and-window :which-key "Close"))
(use-package hydra)
#+end_src #+end_src
*** Help
Run helper functions with =SPC h=. Run helper functions with =SPC h=.
+ Packages =p= + Packages =p=
+ Variables =v= + Variables =v=
@ -433,68 +423,48 @@ Run helper functions with =SPC h=.
"hf" '(describe-function :which-key "Function")) "hf" '(describe-function :which-key "Function"))
#+end_src #+end_src
Quit emacs with =SPC q=.
+ Saving =q=
+ Without =w=
+ Frame (daemon) =f=
*** Files
#+begin_src emacs-lisp
(dotfiles/leader
"q" '(:ignore t :which-key "Quit")
"qq" '(save-buffers-kill-emacs :which-key "Save")
"qw" '(kill-emacs :which-key "Now")
"qf" '(delete-frame :which-key "Frame"))
#+end_src
Emacs' can feel more modern when icon-fonts are installed and prioritized. I feel that this makes navigation of folders much faster, given that file types may be quickly identified by their corresponding icons.
Window management with =SPC w=.
+ Swap with =w=
+ Close with =c=
+ Motions with =h,j,k,l=
+ Split with =s + <MOTION>=
https://github.com/domtronn/all-the-icons.el
+ Collects various icon fonts
#+begin_src emacs-lisp #+begin_src emacs-lisp
(dotfiles/leader
"w" '(:ignore t :which-key "Window")
"ww" '(window-swap-states :which-key "Swap")
"wc" '(delete-window :which-key "Close")
"wh" '(windmove-left :which-key "Left")
"wj" '(windmove-down :which-key "Down")
"wk" '(windmove-up :which-key "Up")
"wl" '(windmove-right :which-key "Right")
"ws" '(:ignore t :which-key "Split")
"wsj" '(split-window-below :which-key "Down")
"wsl" '(split-window-right :which-key "Right"))
(use-package all-the-icons)
#+end_src #+end_src
Place runtime tweaks behind =SPC t=.
https://github.com/jtbm37/all-the-icons-dired
+ Integration with dired
#+begin_src emacs-lisp #+begin_src emacs-lisp
(dotfiles/leader
"t" '(:ignore t :which-key "Tweaks"))
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
#+end_src #+end_src
*** Git
Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
When opening =dired=, I don't want to have to press =RET= twice to navigate to the current directory. This can be avoided with ~dired-jump~, included in the =dired-x= package shipped with =dired=.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package magit
:custom (magit-display-buffer-function
#'magit-display-buffer-same-window-except-diff-v1))
(require 'dired-x)
#+end_src #+end_src
Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
+ Requires a valid ~$GITHUB_TOKEN~
By default =dired= will create a new buffer everytime you press =RET= over a directory. In my workflow this leads to many unwanted =dired= buffers that have to be cleaned up manually. [[https://github.com/crocket/dired-single][Dired-single]] lets us reuse the same dired buffer.
+ Move up a directory with =h=
+ Open a single buffer with =l=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package forge)
(use-package dired-single
:config (evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-single-up-directory
"l" 'dired-single-buffer))
#+end_src #+end_src
Open the *status* page for the current repository with =SPC g=.
Open a dired buffer with =SPC d=.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(dotfiles/leader (dotfiles/leader
"g" '(magit-status :which-key "Magit"))
"d" '(dired-jump :which-key "Dired"))
#+end_src #+end_src
*** Shell *** Shell
@ -517,48 +487,83 @@ Open an =eshell= buffer with =SPC e=.
"e" '(eshell :which-key "Shell")) "e" '(eshell :which-key "Shell"))
#+end_src #+end_src
*** Files
*** Source
Emacs' can feel more modern when icon-fonts are installed and prioritized. I feel that this makes navigation of folders much faster, given that file types may be quickly identified by their corresponding icons.
Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
https://github.com/domtronn/all-the-icons.el
+ Collects various icon fonts
#+begin_src emacs-lisp
(use-package magit
:custom (magit-display-buffer-function
#'magit-display-buffer-same-window-except-diff-v1))
#+end_src
Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
+ Requires a valid ~$GITHUB_TOKEN~
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package all-the-icons)
(use-package forge)
#+end_src #+end_src
https://github.com/jtbm37/all-the-icons-dired
+ Integration with dired
Open the *status* page for the current repository with =SPC g=.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(dotfiles/leader
"g" '(magit-status :which-key "Magit"))
#+end_src #+end_src
When opening =dired=, I don't want to have to press =RET= twice to navigate to the current directory. This can be avoided with ~dired-jump~, included in the =dired-x= package shipped with =dired=.
*** Windows
Window management with =SPC w=.
+ Swap with =w=
+ Close with =c=
+ Motions with =h,j,k,l=
+ Split with =s + <MOTION>=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'dired-x)
(dotfiles/leader
"w" '(:ignore t :which-key "Window")
"ww" '(window-swap-states :which-key "Swap")
"wc" '(delete-window :which-key "Close")
"wh" '(windmove-left :which-key "Left")
"wj" '(windmove-down :which-key "Down")
"wk" '(windmove-up :which-key "Up")
"wl" '(windmove-right :which-key "Right")
"ws" '(:ignore t :which-key "Split")
"wsj" '(split-window-below :which-key "Down")
"wsl" '(split-window-right :which-key "Right"))
#+end_src #+end_src
By default =dired= will create a new buffer everytime you press =RET= over a directory. In my workflow this leads to many unwanted =dired= buffers that have to be cleaned up manually. [[https://github.com/crocket/dired-single][Dired-single]] lets us reuse the same dired buffer.
*** Shortcuts
+ Move up a directory with =h=
+ Open a single buffer with =l=
Implement a few shortcut bindings, cherry picked from Doom emacs.
+ Close buffers with =SPC c=
+ Find files with =SPC . (period)=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package dired-single
:config (evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-single-up-directory
"l" 'dired-single-buffer))
(dotfiles/leader
"." '(find-file :which-key "Files")
"c" '(kill-buffer-and-window :which-key "Close"))
#+end_src #+end_src
Open a dired buffer with =SPC d=.
Quit emacs with =SPC q=.
+ Saving =q=
+ Without =w=
+ Frame (daemon) =f=
#+begin_src emacs-lisp #+begin_src emacs-lisp
(dotfiles/leader (dotfiles/leader
"d" '(dired-jump :which-key "Dired"))
"q" '(:ignore t :which-key "Quit")
"qq" '(save-buffers-kill-emacs :which-key "Save")
"qw" '(kill-emacs :which-key "Now")
"qf" '(delete-frame :which-key "Frame"))
#+end_src
Place runtime tweaks behind =SPC t=.
#+begin_src emacs-lisp
(dotfiles/leader
"t" '(:ignore t :which-key "Tweaks"))
#+end_src #+end_src
** Desktop ** Desktop
@ -1063,6 +1068,55 @@ http://company-mode.github.io/
Support for individual languages are implemented here. Support for individual languages are implemented here.
**** Go
Install the =gopls= language server.
#+begin_src sh :tangle no
GO111MODULE=on go get golang.org/x/tools/gopls@latest
#+end_src
Set the ~GOPATH~ environment variable prior to loading, this allows us to change the default value of ~$HOME/go~ to ~$HOME/.go~.
#+begin_src emacs-lisp
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
#+end_src
Additionally, include the =bin= subdirectory of the ~$GOPATH~ in the ~$PATH~ variable, adding compiled golang programs.
#+begin_src emacs-lisp
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
#+end_src
Finally we can include the =go-mode= package, integrating it with =lsp=.
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
#+end_src
Apply some custom behaviour before saving:
+ Format buffer
+ Organize imports
#+begin_src emacs-lisp
(defun dotfiles/go-hook ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
#+end_src
#+begin_src emacs-lisp
(add-hook 'go-mode-hook #'dotfiles/go-hook)
#+end_src
Add a golang source code block structure template with ~<go~:
#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist '("go" . "src go"))
#+end_src
**** C/C++ **** C/C++
Install the [[https://github.com/MaskRay/ccls][ccls]] language server, and allow us to create a new structure template for C/C++ with ~<cc~. Install the [[https://github.com/MaskRay/ccls][ccls]] language server, and allow us to create a new structure template for C/C++ with ~<cc~.
@ -1126,55 +1180,6 @@ Toggle inline images with =SPC t i=.
"ti" '(org-display-inline-images :which-key "Images")) "ti" '(org-display-inline-images :which-key "Images"))
#+end_src #+end_src
**** Go
Install the =gopls= language server.
#+begin_src sh :tangle no
GO111MODULE=on go get golang.org/x/tools/gopls@latest
#+end_src
Set the ~GOPATH~ environment variable prior to loading, this allows us to change the default value of ~$HOME/go~ to ~$HOME/.go~.
#+begin_src emacs-lisp
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
#+end_src
Additionally, include the =bin= subdirectory of the ~$GOPATH~ in the ~$PATH~ variable, adding compiled golang programs.
#+begin_src emacs-lisp
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
#+end_src
Finally we can include the =go-mode= package, integrating it with =lsp=.
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
#+end_src
Apply some custom behaviour before saving:
+ Format buffer
+ Organize imports
#+begin_src emacs-lisp
(defun dotfiles/go-hook ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
#+end_src
#+begin_src emacs-lisp
(add-hook 'go-mode-hook #'dotfiles/go-hook)
#+end_src
Add a golang source code block structure template with ~<go~:
#+begin_src emacs-lisp
(add-to-list 'org-structure-template-alist '("go" . "src go"))
#+end_src
** Interface ** Interface
:PROPERTIES: :PROPERTIES:
:header-args: :tangle modules/interface.el :results silent :header-args: :tangle modules/interface.el :results silent

2
init.el

@ -11,7 +11,7 @@
"The default browser used by the system.") "The default browser used by the system.")
(defconst dotfiles/modules-available (defconst dotfiles/modules-available
'(core desktop writing projects interface)
'(core editor desktop writing projects interface)
"All of the available modules for hosts to load.") "All of the available modules for hosts to load.")
(defvar dotfiles/modules (defvar dotfiles/modules

32
modules/projects.el

@ -30,6 +30,22 @@
(use-package company-lsp (use-package company-lsp
:custom (company-backend 'company-lsp)) :custom (company-backend 'company-lsp))
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
(defun dotfiles/go-hook ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'dotfiles/go-hook)
(add-to-list 'org-structure-template-alist '("go" . "src go"))
(use-package ccls (use-package ccls
:hook ((c-mode c++-mode objc-mode cuda-mode) . :hook ((c-mode c++-mode objc-mode cuda-mode) .
(lambda () (lambda ()
@ -58,19 +74,3 @@
(dotfiles/leader (dotfiles/leader
"ti" '(org-display-inline-images :which-key "Images")) "ti" '(org-display-inline-images :which-key "Images"))
(setenv "GOPATH" (concat (getenv "HOME") "/.go/"))
(setenv "PATH" (concat (getenv "GOPATH") "bin:" (getenv "PATH")))
(use-package go-mode
:hook (go-mode . lsp)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
(defun dotfiles/go-hook ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'dotfiles/go-hook)
(add-to-list 'org-structure-template-alist '("go" . "src go"))
Loading…
Cancel
Save