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.

238 lines
6.4 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-prompt-function 'epe-theme-lambda))
  71. ;; Open an =eshell= buffer with =SPC e=.
  72. (dotfiles/leader
  73. "e" '(eshell :which-key "Shell"))
  74. ;; Source
  75. ;; #+ATTR_ORG: :width 420px
  76. ;; #+ATTR_HTML: :width 420px
  77. ;; #+ATTR_LATEX: :width 420px
  78. ;; [[./docs/images/2021-02-13-example-magit.gif]]
  79. ;; Another hallmark feature is [[https://github.com/magit/magit][Magit]], a complete git porcelain within Emacs.
  80. (use-package magit
  81. :commands magit-status
  82. :custom (magit-display-buffer-function
  83. #'magit-display-buffer-same-window-except-diff-v1))
  84. ;; Work directly with github issues / pull requests using [[https://github.com/magit/forge][Forge]].
  85. ;; + Requires a valid ~$GITHUB_TOKEN~
  86. (use-package forge
  87. :after magit)
  88. ;; Open the *status* page for the current repository with =SPC g=.
  89. (dotfiles/leader
  90. "g" '(magit-status :which-key "Magit"))
  91. ;; Windows
  92. ;; Window management with =SPC w=.
  93. ;; + Swap with =w=
  94. ;; + Close with =c=
  95. ;; + Motions with =h,j,k,l=
  96. ;; + Split with =s + <MOTION>=
  97. (dotfiles/leader
  98. "w" '(:ignore t :which-key "Window")
  99. "ww" '(window-swap-states :which-key "Swap")
  100. "wc" '(delete-window :which-key "Close")
  101. "wh" '(windmove-left :which-key "Left")
  102. "wj" '(windmove-down :which-key "Down")
  103. "wk" '(windmove-up :which-key "Up")
  104. "wl" '(windmove-right :which-key "Right")
  105. "ws" '(:ignore t :which-key "Split")
  106. "wsj" '(split-window-below :which-key "Down")
  107. "wsl" '(split-window-right :which-key "Right"))
  108. ;; Shortcuts
  109. ;; Implement shortcut bindings, cherry picked from Doom emacs.
  110. ;; + Close buffers with =SPC c=
  111. ;; + Find files with =SPC . (period)=
  112. (dotfiles/leader
  113. "." '(find-file :which-key "Files")
  114. "c" '(kill-buffer-and-window :which-key "Close"))
  115. ;; Quit emacs with =SPC q=.
  116. ;; + Saving =q=
  117. ;; + Without =w=
  118. ;; + Frame (daemon) =f=
  119. (dotfiles/leader
  120. "q" '(:ignore t :which-key "Quit")
  121. "qq" '(save-buffers-kill-emacs :which-key "Save")
  122. "qw" '(kill-emacs :which-key "Now")
  123. "qf" '(delete-frame :which-key "Frame"))
  124. ;; Place runtime tweaks behind =SPC t=.
  125. (dotfiles/leader
  126. "t" '(:ignore t :which-key "Tweaks"))