Browse Source

Split interface / projects from readme

main
parent
commit
9733e2736d
  1. 447
      README.org
  2. 104
      modules/interface.org
  3. 104
      modules/projects.org

447
README.org

@ -130,313 +130,146 @@ Here's a complete list of all of the options configurable for each host, and the
(when (file-exists-p mod-file)
(org-babel-load-file mod-file))))
#+end_src
# ** Lines
# Relative line numbers are important when using =VI= emulation keys. You can prefix most commands with a *number*, allowing you to jump up / down by a line count.
*** HTTP
# #+begin_example
# 5:
# 4:
# 3:
# 2:
# 1:
# 156: << CURRENT LINE >>
# 1:
# 2:
# 3:
# 4:
# 5:
# #+end_example
Instead of the popular =restclient= package, I use [[https://github.com/zweifisch/ob-http][ob-http]] as a lightweight alternative.
#+begin_src emacs-lisp
(use-package ob-http
:after org
:config (org-babel-do-load-languages
'org-babel-load-languages
'((http . t))))
#+end_src
*** C/C++
#+ATTR_ORG: :width 420px
#+ATTR_HTML: :width 420px
#+ATTR_LATEX: :width 420px
[[./docs/images/2021-02-13-example-ccls.gif]]
Add support for C/C++ languages.
+ Configure the [[https://github.com/MaskRay/ccls][ccls]] language server
+ Load babel language modules for C/C++
+ Create a new structure templates for C/C++
- ~<cc~ for C
- ~<cpp~ for C++
#+begin_src emacs-lisp
(use-package ccls
:hook ((c-mode c++-mode objc-mode cuda-mode) .
(lambda ()
(require 'ccls)
(lsp-deferred)))
:config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
(add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
(org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
#+end_src
*** Python
Install the =pyls= language server.
#+begin_src shell :tangle no
pip3 install --user "python-language-server[all]"
#+end_src
[[https://www.emacswiki.org/emacs/PythonProgrammingInEmacs][Python-mode]] is an Emacs built in mode.
+ Load the babel language module for Python
+ Add a python source code block structure template with ~<py~
#+begin_src emacs-lisp
(use-package python-mode
:hook (python-mode . lsp-deferred)
:config (require 'dap-python)
(add-to-list 'org-src-lang-modes '("python" . python))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
:custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
(dap-python-executable "python3") ;; Same as above.
(dap-python-debugger 'debugpy))
#+end_src
*** PlantUML
Download and install [[https://plantuml.com][PlantUML]], a text-based markup language for creating UML diagrams.
+ Load the babel language module for PlantUML
+ Create a structure template with ~<pl~
#+begin_src emacs-lisp
(use-package plantuml-mode
:after org
:custom (plantuml-default-exec-mode 'jar)
(plantuml-jar-path "~/.local/bin/plantuml.jar")
(org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
(org-startup-with-inline-images t)
:config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
(add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
#+end_src
Toggle inline images with =SPC t i=.
#+begin_src emacs-lisp
(dotfiles/leader
"ti" '(org-toggle-inline-images :which-key "Images"))
#+end_src
* Interface
:PROPERTIES:
:header-args: :tangle modules/interface.el
:END:
#+ATTR_ORG: :width 420px
#+ATTR_HTML: :width 420px
#+ATTR_LATEX: :width 420px
[[./docs/images/what-is-emacs-teaser.png]]
*Bring Emacs out of the eighties*
** Ivy
Download and configure [[https://oremacs.com/swiper/][ivy]], a powerful selection menu for Emacs.
#+begin_src emacs-lisp
(use-package ivy
:diminish
:config (ivy-mode 1))
#+end_src
Counsel is a customized set of commands to replace built in completion buffers.
#+begin_src emacs-lisp
(use-package counsel
:after ivy
:custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
:config (counsel-mode 1))
#+end_src
Switch buffers with =SPC , (comma)=.
#+begin_src emacs-lisp
(dotfiles/leader
"," '(counsel-switch-buffer :which-key "Buffers"))
#+end_src
Provide more information about each item with [[https://github.com/Yevgnen/ivy-rich][ivy-rich]].
#+begin_src emacs-lisp
(use-package ivy-rich
:after counsel
:init (ivy-rich-mode 1))
#+end_src
** Fonts
Write out to all *3* of Emacs' default font faces.
#+begin_src emacs-lisp
(set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
(set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
(set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
#+end_src
Define a transient keybinding for scaling the text.
#+begin_src emacs-lisp
(defhydra hydra-text-scale (:timeout 4)
"Scale"
("j" text-scale-increase "Increase")
("k" text-scale-decrease "Decrease")
("f" nil "Finished" :exit t))
#+end_src
Increase the font size in buffers with =SPC t f=.
+ Increase =j=
+ Decrease =k=
+ Finish =f=
#+begin_src emacs-lisp
(dotfiles/leader
"tf" '(hydra-text-scale/body :which-key "Font"))
#+end_src
** Lines
Relative line numbers are important when using =VI= emulation keys. You can prefix most commands with a *number*, allowing you to jump up / down by a line count.
#+begin_example
5:
4:
3:
2:
1:
156: << CURRENT LINE >>
1:
2:
3:
4:
5:
#+end_example
https://github.com/emacsmirror/linum-relative
+ Integrate with ~display-line-numbers-mode~ for performance
#+begin_src emacs-lisp
(use-package linum-relative
:commands (linum-relative-global-mode)
:custom (linum-relative-backend 'display-line-numbers-mode))
#+end_src
Add line numbers to the toggles behind =SPC t l=.
#+begin_src emacs-lisp
(dotfiles/leader
"tl" '(linum-relative-global-mode :which-key "Lines"))
#+end_src
https://github.com/Fanael/rainbow-delimiters
+ Colourize nested parenthesis
#+begin_src emacs-lisp
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
#+end_src
** Themes
#+ATTR_ORG: :width 420px
#+ATTR_HTML: :width 420px
#+ATTR_LATEX: :width 420px
[[./docs/images/what-is-emacs-customizable.gif]]
Cherry pick a few modules from =doom-emacs=. High quality and modern colour themes are provided in the [[https://github.com/hlissner/emacs-doom-themes][doom-themes]] package.
#+begin_src emacs-lisp
(use-package doom-themes
:init (load-theme 'doom-moonlight t))
#+end_src
[[https://github.com/seagle0128/doom-modeline][doom-modeline]] provides an elegant status bar / modeline.
#+begin_src emacs-lisp
(use-package doom-modeline
:custom (doom-modeline-height 16)
:config (doom-modeline-mode 1))
#+end_src
Load a theme with =SPC t t=.
#+begin_src emacs-lisp
(dotfiles/leader
"tt" '(counsel-load-theme t t :which-key "Theme"))
#+end_src
** Pretty
Make programming buffers prettier with [[https://github.com/pretty-mode/pretty-mode][pretty-mode]], complimentary to the built in ~prettify-symbols-mode~.
#+begin_src emacs-lisp
(use-package pretty-mode
:hook (python-mode . turn-on-pretty-mode))
#+end_src
** Ligatures
Enable font ligatures via [[https://github.com/jming422/fira-code-mode][fira-code-mode]], perform this action *only* when ~Fira Code~ is the current font.
#+begin_src emacs-lisp
(when (display-graphic-p)
(use-package fira-code-mode
:hook (prog-mode org-mode)))
#+end_src
Toggle global ligature mode with =SPC t g=.
#+begin_src emacs-lisp
(dotfiles/leader
"tg" '(global-fira-code-mode :which-key "Ligatures"))
#+end_src
** Dashboard
#+ATTR_ORG: :width 420px
#+ATTR_HTML: :width 420px
#+ATTR_LATEX: :width 420px
[[./docs/images/desktop.png]]
Present a dashboard when first launching Emacs. Customize the buttons of the navigator:
+ Brain @ http://localhost:8080
+ Homepage @ https://chrishayward.xyz
+ Athabasca @ https://login.athabascau.ca/cas/login
+ Bookshelf @ https://online.vitalsource.com
#+begin_src emacs-lisp
(use-package dashboard
:custom (dashboard-center-content t)
(dashboard-set-init-info t)
(dashboard-set-file-icons t)
(dashboard-set-heading-icons t)
(dashboard-set-navigator t)
(dashboard-startup-banner 'logo)
(dashboard-projects-backend 'projectile)
(dashboard-items '((projects . 5) (recents . 5) (agenda . 10)))
(dashboard-navigator-buttons `(((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0)
"Brain" "Knowledge base"
(lambda (&rest _) (browse-url "http://localhost:8080"))))
((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0)
"Homepage" "Personal website"
(lambda (&rest _) (browse-url "https://chrishayward.xyz"))))
((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0)
"Athabasca" "Univeristy login"
(lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login"))))
((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0)
"Bookshelf" "Vitalsource bookshelf"
(lambda (&rest _) (browse-url "https://online.vitalsource.com"))))))
:config (dashboard-setup-startup-hook))
#+end_src
When running in *daemon* mode, ensure that the dashboard is the initial buffer.
#+begin_src emacs-lisp
(setq initial-buffer-choice
(lambda ()
(get-buffer "*dashboard*")))
#+end_src
# https://github.com/emacsmirror/linum-relative
# + Integrate with ~display-line-numbers-mode~ for performance
# #+begin_src emacs-lisp
# (use-package linum-relative
# :commands (linum-relative-global-mode)
# :custom (linum-relative-backend 'display-line-numbers-mode))
# #+end_src
# Add line numbers to the toggles behind =SPC t l=.
# #+begin_src emacs-lisp
# (dotfiles/leader
# "tl" '(linum-relative-global-mode :which-key "Lines"))
# #+end_src
# https://github.com/Fanael/rainbow-delimiters
# + Colourize nested parenthesis
# #+begin_src emacs-lisp
# (use-package rainbow-delimiters
# :hook (prog-mode . rainbow-delimiters-mode))
# #+end_src
# ** Themes
# #+ATTR_ORG: :width 420px
# #+ATTR_HTML: :width 420px
# #+ATTR_LATEX: :width 420px
# [[./docs/images/what-is-emacs-customizable.gif]]
# Cherry pick a few modules from =doom-emacs=. High quality and modern colour themes are provided in the [[https://github.com/hlissner/emacs-doom-themes][doom-themes]] package.
# #+begin_src emacs-lisp
# (use-package doom-themes
# :init (load-theme 'doom-moonlight t))
# #+end_src
# [[https://github.com/seagle0128/doom-modeline][doom-modeline]] provides an elegant status bar / modeline.
# #+begin_src emacs-lisp
# (use-package doom-modeline
# :custom (doom-modeline-height 16)
# :config (doom-modeline-mode 1))
# #+end_src
# Load a theme with =SPC t t=.
# #+begin_src emacs-lisp
# (dotfiles/leader
# "tt" '(counsel-load-theme t t :which-key "Theme"))
# #+end_src
# ** Pretty
# Make programming buffers prettier with [[https://github.com/pretty-mode/pretty-mode][pretty-mode]], complimentary to the built in ~prettify-symbols-mode~.
# #+begin_src emacs-lisp
# (use-package pretty-mode
# :hook (python-mode . turn-on-pretty-mode))
# #+end_src
# ** Ligatures
# Enable font ligatures via [[https://github.com/jming422/fira-code-mode][fira-code-mode]], perform this action *only* when ~Fira Code~ is the current font.
# #+begin_src emacs-lisp
# (when (display-graphic-p)
# (use-package fira-code-mode
# :hook (prog-mode org-mode)))
# #+end_src
# Toggle global ligature mode with =SPC t g=.
# #+begin_src emacs-lisp
# (dotfiles/leader
# "tg" '(global-fira-code-mode :which-key "Ligatures"))
# #+end_src
# ** Dashboard
# #+ATTR_ORG: :width 420px
# #+ATTR_HTML: :width 420px
# #+ATTR_LATEX: :width 420px
# [[./docs/images/desktop.png]]
# Present a dashboard when first launching Emacs. Customize the buttons of the navigator:
# + Brain @ http://localhost:8080
# + Homepage @ https://chrishayward.xyz
# + Athabasca @ https://login.athabascau.ca/cas/login
# + Bookshelf @ https://online.vitalsource.com
# #+begin_src emacs-lisp
# (use-package dashboard
# :custom (dashboard-center-content t)
# (dashboard-set-init-info t)
# (dashboard-set-file-icons t)
# (dashboard-set-heading-icons t)
# (dashboard-set-navigator t)
# (dashboard-startup-banner 'logo)
# (dashboard-projects-backend 'projectile)
# (dashboard-items '((projects . 5) (recents . 5) (agenda . 10)))
# (dashboard-navigator-buttons `(((,(all-the-icons-fileicon "brain" :height 1.1 :v-adjust 0.0)
# "Brain" "Knowledge base"
# (lambda (&rest _) (browse-url "http://localhost:8080"))))
# ((,(all-the-icons-material "public" :height 1.1 :v-adjust 0.0)
# "Homepage" "Personal website"
# (lambda (&rest _) (browse-url "https://chrishayward.xyz"))))
# ((,(all-the-icons-faicon "university" :height 1.1 :v-adjust 0.0)
# "Athabasca" "Univeristy login"
# (lambda (&rest _) (browse-url "https://login.athabascau.ca/cas/login"))))
# ((,(all-the-icons-faicon "book" :height 1.1 :v-adjust 0.0)
# "Bookshelf" "Vitalsource bookshelf"
# (lambda (&rest _) (browse-url "https://online.vitalsource.com"))))))
# :config (dashboard-setup-startup-hook))
# #+end_src
# When running in *daemon* mode, ensure that the dashboard is the initial buffer.
# #+begin_src emacs-lisp
# (setq initial-buffer-choice
# (lambda ()
# (get-buffer "*dashboard*")))
# #+end_src

104
modules/interface.org

@ -0,0 +1,104 @@
#+TITLE: Interface
#+AUTHOR: Christopher James Hayward
#+EMAIL: chris@chrishayward.xyz
#+PROPERTY: header-args:emacs-lisp :tangle interface.el :comments org
#+PROPERTY: header-args:shell :tangle no
#+PROPERTY: header-args :results silent :eval no-export :comments org
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
#+ATTR_ORG: :width 420px
#+ATTR_HTML: :width 420px
#+ATTR_LATEX: :width 420px
[[../docs/images/what-is-emacs-teaser.png]]
*Bring Emacs out of the eighties*
* Completion
There's a lot of occasions Emacs asks to input text to match a file name in a directory, just one example of an oppertunity for a completion system. *Swiper*[fn:1] is a family of packages that work towards this common goal in Emacs.
** Selection menu
*Ivy*[fn:1] is a powerful selection menu for Emacs.
#+begin_src emacs-lisp
(use-package ivy
:diminish
:config (ivy-mode 1))
#+end_src
** Replace built in commands
*Counsel*[fn:1] is a customized set of commands to replace built in completion buffers.
#+begin_src emacs-lisp
(use-package counsel
:after ivy
:custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
:config (counsel-mode 1))
#+end_src
** Additional details
Provide more information about each item in the completion menu with *Ivy rich*[fn:2].
#+begin_src emacs-lisp
(use-package ivy-rich
:after counsel
:init (ivy-rich-mode 1))
#+end_src
* Fonts
Write out to all of Emacs' available font faces with the unified font defined in the options.
#+begin_src emacs-lisp
(set-face-attribute 'default nil :font dotfiles/font :height dotfiles/font-size)
(set-face-attribute 'fixed-pitch nil :font dotfiles/font :height dotfiles/font-size)
(set-face-attribute 'variable-pitch nil :font dotfiles/font :height dotfiles/font-size)
#+end_src
** Text scaling
Define a transient keybinding for Scaling the text.
#+begin_src emacs-lisp
(defhydra hydra-text-scale (:timeout 4)
"Scale"
("j" text-scale-increase "Increase")
("k" text-scale-decrease "Decrease")
("f" nil "Finished" :exit t))
#+end_src
+ Scale the text inside of buffers with =SPC t f=
* Increase =j=
* Decrease =k=
* Finished =f=
#+begin_src emacs-lisp
(dotfiles/leader
"tf" '(hydra-text-scale/body :which-key "Font"))
#+end_src
* Icons
- [ ] All the icons
- [ ] All the icons dired
* Themes
* Line numbering
* Pretty symbols
* Ligatures
* Dashboard
* Resources
[fn:1] https://github.com/abo-abo/swiper
[fn:2] https://github.com/Yevgnen/ivy-rich

104
modules/projects.org

@ -9,6 +9,11 @@
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
#+ATTR_ORG: :width 420px
#+ATTR_HTML: :width 420px
#+ATTR_LATEX: :width 420px
[[../docs/images/2021-02-13-example-ccls.gif]]
An *IDE*[fn:1] like experience or better can be achieved within Emacs using two *Microsoft*[fn:2] open-source initiatives:
+ *Debug Adapter Protocol*[fn:3]
@ -152,7 +157,7 @@ Finally we can include the *Go-mode*[fn:15] package, adding integration with *Ls
#+begin_src emacs-lisp
(use-package go-mode
:hook (go-mode . lsp)
:hook (go-mode . lsp-deferred)
:custom (lsp-go-gopls-server-path "~/.go/bin/gopls"))
#+end_src
@ -177,6 +182,96 @@ Add a golang source code block structure template with ~<go~:
(add-to-list 'org-structure-template-alist '("go" . "src go"))
#+end_src
** HTTP
Interact with HTTP/HTTPS endpoints using the *Ob-http*[fn:16] package. See how it works in my post *Kanye as a Service*[fn:17].
#+begin_src emacs-lisp
(use-package ob-http
:after org
:config (org-babel-do-load-languages
'org-babel-load-languages
'((http . t))))
#+end_src
** C/C++
Add support for the C/C++ family of languages.
+ Configure the *CCLS*[fn:18] language server
+ Load babel language modules for C/C++
+ Create new structure templates for C/C++
* ~<cc~ for C
* ~<cpp~ for C++
#+begin_src emacs-lisp
(use-package ccls
:hook ((c-mode c++-mode objc-mode cuda-mode) .
(lambda ()
(require 'ccls)
(lsp-deferred)))
:config (add-to-list 'org-structure-template-alist '("cc" . "src C"))
(add-to-list 'org-structure-template-alist '("cpp" . "src C++"))
(org-babel-do-load-languages 'org-babel-load-languages '((C . t))))
#+end_src
** Python
Add support for Python / Python 3 with full support for *DAP*[fn:3] and *LSP*[fn:4].
*** Setup
Install the *pyls*[fn:19] language server.
#+begin_src shell
pip3 install --user "python-language-server[all]"
#+end_src
*Python mode*[fn:20] is an Emacs built in mode for working with Python buffers.
+ Load the babel language modules for Python
+ Add a structure template with ~<py~
#+begin_src emacs-lisp
(use-package python-mode
:hook (python-mode . lsp-deferred)
:config (require 'dap-python)
(add-to-list 'org-src-lang-modes '("python" . python))
(add-to-list 'org-structure-template-alist '("py" . "src python"))
(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
:custom (python-shell-interpreter "python3") ;; Required if "python" is not python 3.
(dap-python-executable "python3") ;; Same as above.
(dap-python-debugger 'debugpy))
#+end_src
** PlantUML
Download and install *PlantUML*[fn:21], a text-based markup language for creating UML diagrams.
+ Load the babel language module for *PlantUML*
+ Create a structure template with ~<pl~
#+begin_src emacs-lisp
(use-package plantuml-mode
:after org
:custom (plantuml-default-exec-mode 'jar)
(plantuml-jar-path "~/.local/bin/plantuml.jar")
(org-plantuml-jar-path (expand-file-name "~/.local/bin/plantuml.jar"))
(org-startup-with-inline-images t)
:config (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
(add-to-list 'org-structure-template-alist '("pl" . "src plantuml"))
(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))))
#+end_src
*** View inside of buffers
Toggle inline images with =SPC t i=.
#+begin_src emacs-lisp
(dotfiles/leader
"ti" '(org-toggle-inline-images :which-key "Images"))
#+end_src
* Resources
[fn:1] https://en.wikipedia.org/wiki/Integrated_development_environment
@ -194,3 +289,10 @@ Add a golang source code block structure template with ~<go~:
[fn:13] https://git.zx2c4.com/password-store/tree/contrib/emacs
[fn:14] https://pkg.go.dev/golang.org/x/tools/gopls
[fn:15] https://emacswiki.org/emacs/GoMode
[fn:16] https://github.com/zweifisch/ob-http
[fn:17] https://chrishayward.xyz/posts/kanye-as-a-service/
[fn:18] https://github.com/MaskRay/ccls
[fn:19] https://pypi.org/project/python-language-server/
[fn:20] https://emacswiki.org/emacs/PythonProgrammingInEmacs
[fn:21] https://plantuml.com
[fn:22] https://github.com/skuro/plantuml-mode
Loading…
Cancel
Save