I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
6.5 KiB

4 years ago
4 years ago
4 years ago
  1. ;; Keys
  2. ;; Make the =ESC= key quit (most) prompts, instead of the default =C-g=.
  3. (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
  4. ;; 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.
  5. (use-package which-key
  6. :diminish which-key-mode
  7. :custom (which-key-idle-delay dotfiles/idle)
  8. :config (which-key-mode))
  9. ;; Turn Emacs into Vim with [[https://evil.readthedocs.io/en/latest/index.html][evil-mode]], the extensible VI layer for Emacs.
  10. (use-package evil
  11. :custom (evil-want-integration t) ;; Required for `evil-collection'.
  12. (evil-want-keybinding nil) ;; Same as above
  13. :config (evil-mode 1))
  14. ;; Unfortunately the default keybindings are *lacking*, but there is a community curated package [[https://github.com/emacs-evil/evil-collection][evil-collection]], which does a much better job implementing keybindings you would expect to find.
  15. (use-package evil-collection
  16. :after evil
  17. :config (evil-collection-init))
  18. ;; Surround text with functions, quotations, and any other symbols using the [[https://github.com/emacs-evil/evil-surround][evil-surround]] package.
  19. (use-package evil-surround
  20. :after evil
  21. :config (global-evil-surround-mode 1))
  22. ;; Toggle block comments using [[https://github.com/redguardtoo/evil-nerd-commenter][evil-nerd-commentor]] and =M-;=.
  23. (use-package evil-nerd-commenter
  24. :after evil
  25. :bind ("M-;" . evilnc-comment-or-uncomment-lines))
  26. ;; 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.
  27. (use-package general
  28. :after evil
  29. :config
  30. (general-create-definer dotfiles/leader
  31. :states '(normal motion)
  32. :keymaps 'override
  33. :prefix dotfiles/leader-key
  34. :global-prefix dotfiles/leader-key-global))
  35. ;; Use [[https://github.com/abo-abo/hydra][hydra]] for transient keybindings sharing a common prefix.
  36. (use-package hydra
  37. :defer t)
  38. ;; Help
  39. ;; Use the built-in ~describe-*~ functionality of Emacs to quickly access documentation for packages, variables, and functions. Run helper functions with =SPC h=.
  40. ;; + Packages =p=
  41. ;; + Variables =v=
  42. ;; + Functions =f=
  43. (dotfiles/leader
  44. "h" '(:ignore t :which-key "Help")
  45. "hp" '(describe-package :which-key "Package")
  46. "hv" '(describe-variable :which-key "Variable")
  47. "hf" '(describe-function :which-key "Function"))
  48. ;; Files
  49. ;; For file navigation I use =dired=, included with Emacs by default. Dired feels more modern with prioritized icon fonts using [[https://github.com/domtronn/all-the-icons.el][all-the-icons]]. This makes navigation and visually parsing directories much faster, given that file types are quickly identified by their corresponding icons.
  50. (use-package all-the-icons)
  51. ;; Integration with =dired= comes from the [[https://github.com/jtbm37/all-the-icons-dired][all-the-icons-dired]] package.
  52. (use-package all-the-icons-dired
  53. :hook (dired-mode . all-the-icons-dired-mode))
  54. ;; When opening =dired=, I don't want to have to press =RET= twice to navigate to the current directory. Avoid this with ~dired-jump~, included in the =dired-x= package shipped with =dired= and Emacs.
  55. (require 'dired-x)
  56. ;; By default =dired= will create a new buffer everytime you press =RET= over a directory. This leads to unwanted =dired= buffers needing closure. Avoid this behaviour with [[https://github.com/crocket/dired-single][dired-single]], reusing the same dired buffer.
  57. ;; + Move up a directory with =h=
  58. ;; + Open a single buffer with =l=
  59. (use-package dired-single
  60. :config (evil-collection-define-key 'normal 'dired-mode-map
  61. "h" 'dired-single-up-directory
  62. "l" 'dired-single-buffer))
  63. ;; Open a dired buffer with =SPC d=.
  64. (dotfiles/leader
  65. "d" '(dired-jump :which-key "Dired"))
  66. ;; Shell
  67. ;; While not a traditional terminal emulator, =eshell= provides me with all of the functionality I expect and require from one. Some users may be wanting more, I would recommend they look into =vterm= included in the destkop module. Configure the infamous lambda prompt using [[https://github.com/zwild/eshell-prompt-extras][eshell-prompt-extras]] package.
  68. (use-package eshell-prompt-extras
  69. :custom (eshell-highlight-prompt nil)
  70. (eshell-prefer-lisp-functions nil)
  71. (eshell-prompt-function 'epe-theme-lambda))
  72. ;; Make ~pfetch~ output as a visual command.
  73. (with-eval-after-load 'eshell
  74. (add-to-list 'eshell-visual-commands "pfetch"))
  75. ;; Open an =eshell= buffer with =SPC e=.
  76. (dotfiles/leader
  77. "e" '(eshell :which-key "Shell"))
  78. ;; Source
  79. ;; #+ATTR_ORG: :width 420px
  80. ;; #+ATTR_HTML: :width 420px
  81. ;; #+ATTR_LATEX: :width 420px
  82. ;; [[./docs/images/2021-02-13-example-magit.gif]]
  83. ;; Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
  84. (use-package magit
  85. :commands magit-status
  86. :custom (magit-display-buffer-function
  87. #'magit-display-buffer-same-window-except-diff-v1))
  88. ;; Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
  89. ;; + Requires a valid ~$GITHUB_TOKEN~
  90. (use-package forge
  91. :after magit)
  92. ;; Open the *status* page for the current repository with =SPC g=.
  93. (dotfiles/leader
  94. "g" '(magit-status :which-key "Magit"))
  95. ;; Windows
  96. ;; Window management with =SPC w=.
  97. ;; + Swap with =w=
  98. ;; + Close with =c=
  99. ;; + Motions with =h,j,k,l=
  100. ;; + Split with =s + <MOTION>=
  101. (dotfiles/leader
  102. "w" '(:ignore t :which-key "Window")
  103. "ww" '(window-swap-states :which-key "Swap")
  104. "wc" '(delete-window :which-key "Close")
  105. "wh" '(windmove-left :which-key "Left")
  106. "wj" '(windmove-down :which-key "Down")
  107. "wk" '(windmove-up :which-key "Up")
  108. "wl" '(windmove-right :which-key "Right")
  109. "ws" '(:ignore t :which-key "Split")
  110. "wsj" '(split-window-below :which-key "Down")
  111. "wsl" '(split-window-right :which-key "Right"))
  112. ;; Shortcuts
  113. ;; Implement shortcut bindings, cherry picked from Doom emacs.
  114. ;; + Close buffers with =SPC c=
  115. ;; + Find files with =SPC . (period)=
  116. (dotfiles/leader
  117. "." '(find-file :which-key "Files")
  118. "c" '(kill-buffer-and-window :which-key "Close"))
  119. ;; Quit emacs with =SPC q=.
  120. ;; + Saving =q=
  121. ;; + Without =w=
  122. ;; + Frame (daemon) =f=
  123. (dotfiles/leader
  124. "q" '(:ignore t :which-key "Quit")
  125. "qq" '(save-buffers-kill-emacs :which-key "Save")
  126. "qw" '(kill-emacs :which-key "Now")
  127. "qf" '(delete-frame :which-key "Frame"))
  128. ;; Place runtime tweaks behind =SPC t=.
  129. (dotfiles/leader
  130. "t" '(:ignore t :which-key "Tweaks"))