Emacs config utilizing prelude as a base
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.

182 lines
5.6 KiB

7 years ago
7 years ago
  1. # Configuration
  2. ## User Interface
  3. Historically Prelude had adopted a very minimalistic approach to UI and
  4. had hidden by default Emacs's menu bar and tool bar. This was changed a bit
  5. in Prelude 1.1 for the sake of being more approachable to newcomers to Emacs
  6. and now the menu bar is displayed by default. The tool bar is still hidden, as
  7. it's quite big and not that useful.
  8. !!! Tip
  9. You can toggle the menu bar by pressing `F12`.
  10. Furthermore, Prelude 1.1 displays line numbers (via `global-nlinum-mode`), just
  11. like most "modern" editors and IDEs do these days. You can go back to the way
  12. things were by setting `prelude-minimalistic-ui` to `t` in `personal/preload` or
  13. by adding the following snippets to your personal config:
  14. ``` emacs-lisp
  15. (global-nlinum-mode -1)
  16. (menu-bar-mode -1)
  17. ```
  18. !!! Note
  19. The first approach is better as it would prevent those UI elements from
  20. appearing temporarily.
  21. ## Color Themes
  22. Emacs provides a dozen of
  23. built-in themes you can use out-of-the-box by invoking the `M-x
  24. load-theme` command.
  25. [Zenburn](https://github.com/bbatsov/zenburn-emacs) is the default
  26. color theme in Prelude, but you can change it at your discretion. Why
  27. Zenburn? I (and lots of hackers around the world) find it pretty neat
  28. for some reason. Personally I find the default theme pretty tiresome
  29. for the eyes, that's why I took that "controversial" decision to
  30. replace it. You can, of course, easily go back to the default (or
  31. select another theme entirely).
  32. To disable Zenburn just put in your personal config the following
  33. line:
  34. ```emacs-lisp
  35. (disable-theme 'zenburn)
  36. ```
  37. Or you can use another theme altogether by adding something in `personal/preload` like:
  38. ```emacs-lisp
  39. (setq prelude-theme 'tango)
  40. ```
  41. !!! Note
  42. To use a non-built-in theme, like [Solarized](https://github.com/bbatsov/solarized-emacs),
  43. you'll have to install it from MELPA first by `M-x package-install RET solarized-theme`. Then add
  44. ```emacs-lisp
  45. (setq prelude-theme 'solarized-dark)
  46. ```
  47. in `personal/preload`.
  48. Finally, if you don't want any theme at all, you can add this to your
  49. `personal/preload`:
  50. ```emacs-lisp
  51. (setq prelude-theme nil)
  52. ```
  53. ## Personalizing
  54. All files you create under the `personal/` directory are yours for
  55. personalization. There is no single special personal config file --
  56. any files you create in the `personal/` directory will be loaded in
  57. lexicographical order. The overall loading precedence is:
  58. 1. `personal/preload/*`
  59. 2. `core/`
  60. 3. `personal/prelude-modules.el` (or deprecated `prelude-modules.el`)
  61. 4. `personal/*`
  62. ### Personalization Example
  63. Suppose you want to configure `go-mode` to autoformat on each save. You
  64. can create a file in `personal/`, let's call this one
  65. `config-go-mode.el` and add the following to it.
  66. ```emacs-lisp
  67. (add-hook 'go-mode-hook
  68. (lambda ()
  69. (add-hook 'before-save-hook 'gofmt-before-save)
  70. (setq tab-width 2)))
  71. ```
  72. ### General Tips
  73. **Fork** (instead of cloning) the official Prelude repo and add your
  74. own touch to it. You're advised to **avoid changing stuff outside of
  75. the personal folder** to avoid having to deal with git merge conflicts
  76. in the future.
  77. If you'd like to add some auto installation of packages in your
  78. personal config use the following code:
  79. ```emacs-lisp
  80. (prelude-require-packages '(some-package some-other-package))
  81. ```
  82. If you require just a single package you can also use:
  83. ```emacs-lisp
  84. (prelude-require-package 'some-package)
  85. ```
  86. ### Preloading personal config
  87. Sometimes you might want to load code before Prelude has started loading. Prelude will automatically preload all
  88. Emacs Lisp files in your `personal/preload` directory. Note that at this point you can't using anything from
  89. Prelude, except a few variables like `prelude-dir`, etc (since nothing is yet loaded).
  90. ### Disabling whitespace-mode
  91. Although `whitespace-mode` is awesome, some people might find it too
  92. intrusive. You can disable it in your
  93. personal config with the following bit of code:
  94. ```emacs-lisp
  95. (setq prelude-whitespace nil)
  96. ```
  97. If you like `whitespace-mode`, but prefer it to not automatically
  98. cleanup your file on save, you can disable that behavior by setting
  99. `prelude-clean-whitespace-on-save` to `nil` in your config file with:
  100. ```emacs-lisp
  101. (setq prelude-clean-whitespace-on-save nil)
  102. ```
  103. ### Disable flyspell-mode
  104. If you're not fond of spellchecking on the fly:
  105. ```emacs-lisp
  106. (setq prelude-flyspell nil)
  107. ```
  108. ### Disable automatic formatting on save
  109. If you prefer not to automatically format your file on save, you can disable that behavior by setting
  110. `prelude-format-on-save` to `nil` in your config file with:
  111. ```emacs-lisp
  112. (setq prelude-format-on-save nil)
  113. ```
  114. Currently this only affects automated formatting of Typescript files.
  115. ### Disable Super-based keybindings
  116. Out-of-the-box Prelude will create two versions of many keybindings in `prelude-mode`:
  117. * One "traditional" version with a prefix like `Control`
  118. * One "alternative" version with a prefix like `Super`
  119. The reason for this is that there are generally more options for short keybindings with `Super` - e.g. you can
  120. have `s-p`, `s-g`, etc. There's, however, a problem lying here as well - some operating systems and
  121. desktop environments might be making heavy use of such keybindings. (in most cases those would intercept them before Emacs does).
  122. `exwm` also uses those heavily. You prevent Prelude from creating such keybindings via `prelude-super-keybindings`:
  123. ```emacs-lisp
  124. (setq prelude-super-keybindings nil)
  125. ```
  126. ### Configuration per file or directory
  127. Some of these settings (those that don't need to be pre-loaded) can also be set
  128. on a per-file or directory basis by using a file local variable or a
  129. `.dir-locals.el` file.