diff --git a/.gitignore b/.gitignore index 448032fe71..98aa6238b2 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ savefile/ /indium-workspaces.el /persp-confs/ /tramp -/prelude-modules.el projectile-bookmarks.eld session* .cask diff --git a/README.md b/README.md index 64e049fe1b..e5fa8b298e 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,9 @@ Note that the installer will back up any existing `.emacs` file or you're doing a manual install make sure you don't have a `.emacs` file or back up your existing `.emacs.d` directory manually. -Don't forget to adjust your `prelude-modules.el` file once the installation is done. -By default most of the modules that ship with Prelude are not loaded. +Don't forget to adjust your `prelude-modules.el` file in your personal directory +once the installation is done. By default most of the modules +that ship with Prelude are not loaded. ## Installing Emacs @@ -222,8 +223,8 @@ By default most of the modules that ship with Prelude are not loaded. For more i You'll need to adjust your `prelude-modules.el` file once the installation is done. If you are doing a manual install then you first need to copy the `prelude-modules.el` available in the sample -directory to the root of `path/to/prelude/installation` and then -adjust that one. +directory to the `personal` directory under `path/to/prelude/installation` +and then adjust that one. After you've uncommented a module you should either restart Emacs or evaluate the module `require` expression with C-x C-e. @@ -359,7 +360,7 @@ For subsequent operations, only the appropriate operations (i.e. `+`, `-`, `*`, Prelude does not mess by default with the standard mapping of `Command` (to `Super`) and `Option` (to `Meta`). -If you want to swap them add this to your personal config: +If you want to swap them add this to your [personal config](#personalizing): ```lisp (setq mac-command-modifier 'meta) @@ -516,8 +517,8 @@ for the eyes, that's why I took that "controversial" decision to replace it. You can, of course, easily go back to the default (or select another theme entirely). -To disable Zenburn just put in your personal config the following -line: +To disable Zenburn just put in your [personal config](#personalizing) +the following line: ```lisp (disable-theme 'zenburn) @@ -529,7 +530,7 @@ Or you can use another theme altogether by adding something in `personal/preload (setq prelude-theme 'tango) ``` -**Note** To use a non-built-in theme, like [Solarized](https://github.com/bbatsov/zenburn-emacs), +**Note** To use a non-built-in theme, like [Solarized](https://github.com/bbatsov/solarized-emacs), you'll have to install it from MELPA first by `M-x package-install RET solarized-theme`. Then add ``` lisp @@ -546,6 +547,31 @@ Finally, if you don't want any theme at all, you can add this to your ### Personalizing +All files you create under the `personal/` directory are yours for +personalization. There is no single special personal config file -- +any files you create in the `personal/` directory will be loaded in +lexicographical order. The overall loading precedence is: + +1. `personal/preload/*` +2. `core/` +3. `personal/prelude-modules.el` (or deprecated `prelude-modules.el`) +4. `personal/*` + +#### Personalization Example + +Suppose you want to configure go-mode to autoformat on each save. You +can create a file in `personal/`, let's call this one +`config-go-mode.el` and add the following to it. + +``` emacs-lisp +(add-hook 'go-mode-hook + (lambda () + (add-hook 'before-save-hook 'gofmt-before-save) + (setq tab-width 2))) +``` + +#### Tips + **Fork** (instead of cloning) the official Prelude repo and add your own touch to it. You're advised to **avoid changing stuff outside of the personal folder** to avoid having to deal with git merge conflicts @@ -655,14 +681,14 @@ way to use Emacs is by using it the way it was intended to be used (as far as navigation is concerned at least). If you'd like to be take this a step further and disable the arrow key navigation -completely put this in your personal config: +completely put this in your [personal config](#personalizing): ```lisp (setq guru-warn-only nil) ``` To disable `guru-mode` completely add the following snippet to your -personal Emacs config: +[personal config](#personalizing): ```lisp (setq prelude-guru nil) @@ -672,7 +698,7 @@ personal Emacs config: Prelude overrides `C-a` to behave as described [here](http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/). If -you don't like that simply add this to your personal config: +you don't like that simply add this to your [personal config](#personalizing): ```lisp (global-set-key [remap move-beginning-of-line] diff --git a/core/prelude-linux.el b/core/prelude-linux.el new file mode 100644 index 0000000000..938863109b --- /dev/null +++ b/core/prelude-linux.el @@ -0,0 +1,43 @@ +;;; prelude-linux.el --- Emacs Prelude: linux specific settings. +;; +;; Copyright © 2011-2018 Bozhidar Batsov +;; +;; Author: Stanislav Arnaudov +;; URL: https://github.com/bbatsov/prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; Some Linux specific stuff. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +;; On Linux Emacs doesn't use the shell PATH if it's not started from +;; the shell. Let's fix that: +(prelude-require-packages '(exec-path-from-shell)) + +(require 'exec-path-from-shell) +(exec-path-from-shell-initialize) + +(provide 'prelude-linux) +;;; prelude-linux.el ends here diff --git a/init.el b/init.el index 87d94195a9..a9d0788a6d 100644 --- a/init.el +++ b/init.el @@ -69,8 +69,13 @@ by Prelude.") "This directory houses packages that are not yet available in ELPA (or MELPA).") (defvar prelude-savefile-dir (expand-file-name "savefile" prelude-dir) "This folder stores all the automatically generated save/history-files.") -(defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-dir) - "This files contains a list of modules that will be loaded by Prelude.") +(defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-personal-dir) + "This file contains a list of modules that will be loaded by Prelude.") +(defvar prelude-deprecated-modules-file + (expand-file-name "prelude-modules.el" prelude-dir) + (format "This file may contain a list of Prelude modules. + +This is DEPRECATED, use %s instead." prelude-modules-file)) (unless (file-exists-p prelude-savefile-dir) (make-directory prelude-savefile-dir)) @@ -117,13 +122,26 @@ by Prelude.") (when (eq system-type 'darwin) (require 'prelude-macos)) +;; Linux specific settings +(when (eq system-type 'gnu/linux) + (require 'prelude-linux)) + (message "Loading Prelude's modules...") ;; the modules (if (file-exists-p prelude-modules-file) - (load prelude-modules-file) - (message "Missing modules file %s" prelude-modules-file) - (message "You can get started by copying the bundled example file from sample/prelude-modules.el")) + (progn + (load prelude-modules-file) + (if (file-exists-p prelude-deprecated-modules-file) + (message "Loading new modules configuration, ignoring DEPRECATED prelude-module.el"))) + (if (file-exists-p prelude-deprecated-modules-file) + (progn + (load prelude-deprecated-modules-file) + (message (format "The use of %s is DEPRECATED! Use %s instead!" + prelude-deprecated-modules-file + prelude-modules-file))) + (message "Missing modules file %s" prelude-modules-file) + (message "You can get started by copying the bundled example file from sample/prelude-modules.el"))) ;; config changes made through the customize UI will be stored here (setq custom-file (expand-file-name "custom.el" prelude-personal-dir)) @@ -131,7 +149,9 @@ by Prelude.") ;; load the personal settings (this includes `custom-file') (when (file-exists-p prelude-personal-dir) (message "Loading personal configuration files in %s..." prelude-personal-dir) - (mapc 'load (directory-files prelude-personal-dir 't "^[^#\.].*el$"))) + (mapc 'load (delete + prelude-modules-file + (directory-files prelude-personal-dir 't "^[^#\.].*\\.el$")))) (message "Prelude is ready to do thy bidding, Master %s!" current-user) diff --git a/modules/prelude-lsp.el b/modules/prelude-lsp.el new file mode 100644 index 0000000000..ff84c5367d --- /dev/null +++ b/modules/prelude-lsp.el @@ -0,0 +1,63 @@ +;;; prelude-lsp.el --- lsp-mode setup +;; +;; Copyright © 2011-2018 Bozhidar Batsov +;; +;; Author: Bozhidar Batsov, Ben Alex +;; URL: https://github.com/bbatsov/prelude +;; Version: 1.0.0 +;; Keywords: convenience + +;; This file is not part of GNU Emacs. + +;;; Commentary: + +;; lsp-mode config. + +;;; License: + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License +;; as published by the Free Software Foundation; either version 3 +;; of the License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + +(prelude-require-packages '(company-lsp + lsp-mode + lsp-ui)) + +(require 'lsp-ui) +(require 'company-lsp) +(require 'lsp-imenu) + +(push 'company-lsp company-backends) +(add-hook 'lsp-mode-hook 'lsp-ui-mode) +(add-hook 'lsp-after-open-hook 'lsp-enable-imenu) + +(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions) +(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references) +(define-key lsp-ui-mode-map (kbd "C-c C-l .") 'lsp-ui-peek-find-definitions) +(define-key lsp-ui-mode-map (kbd "C-c C-l ?") 'lsp-ui-peek-find-references) +(define-key lsp-ui-mode-map (kbd "C-c C-l r") 'lsp-rename) +(define-key lsp-ui-mode-map (kbd "C-c C-l x") 'lsp-restart-workspace) +(define-key lsp-ui-mode-map (kbd "C-c C-l w") 'lsp-ui-peek-find-workspace-symbol) +(define-key lsp-ui-mode-map (kbd "C-c C-l i") 'lsp-ui-peek-find-implementation) +(define-key lsp-ui-mode-map (kbd "C-c C-l d") 'lsp-describe-thing-at-point) + +(setq lsp-ui-sideline-enable t) +(setq lsp-ui-doc-enable t) +(setq lsp-ui-peek-enable t) +(setq lsp-ui-peek-always-show t) + +(provide 'prelude-lsp) +;;; prelude-lsp.el ends here diff --git a/modules/prelude-rust.el b/modules/prelude-rust.el index b8d5762c6b..b2d27db58b 100644 --- a/modules/prelude-rust.el +++ b/modules/prelude-rust.el @@ -1,6 +1,6 @@ ;;; prelude-rust.el --- Emacs Prelude: Rust programming support. ;; -;; Authors: Doug MacEachern, Manoel Vilela +;; Authors: Doug MacEachern, Manoel Vilela, Ben Alex ;; Version: 1.0.1 ;; Keywords: convenience rust @@ -36,23 +36,34 @@ ;; * cargo (Rust Package Manager) ;; * racer (Rust Completion Tool) ;; * rustfmt (Rust Tool for formatting code) +;; * rls (Rust Language Server, if the prelude-lsp feature is enabled) (prelude-require-packages '(rust-mode - racer - flycheck-rust cargo)) +(if (featurep 'prelude-lsp) + (prelude-require-package 'lsp-rust) + (prelude-require-packages '(racer + flycheck-rust))) + (setq rust-format-on-save t) +(setq lsp-rust-rls-command '("rustup" "run" "stable" "rls")) (with-eval-after-load 'rust-mode - (add-hook 'rust-mode-hook 'racer-mode) - (add-hook 'racer-mode-hook 'eldoc-mode) (add-hook 'rust-mode-hook 'cargo-minor-mode) - (add-hook 'rust-mode-hook 'flycheck-rust-setup) - (add-hook 'flycheck-mode-hook 'flycheck-rust-setup) + + (if (featurep 'prelude-lsp) + (progn (require 'lsp-rust) + (add-hook 'rust-mode-hook #'lsp-rust-enable)) + (add-hook 'rust-mode-hook 'racer-mode) + (add-hook 'racer-mode-hook 'eldoc-mode) + (add-hook 'rust-mode-hook 'flycheck-rust-setup) + (add-hook 'flycheck-mode-hook 'flycheck-rust-setup)) (defun prelude-rust-mode-defaults () - (local-set-key (kbd "C-c C-d") 'racer-describe) + (unless (featurep 'prelude-lsp) + (local-set-key (kbd "C-c C-d") 'racer-describe)) + ;; Prevent #! from chmodding rust files to be executable (remove-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) ;; CamelCase aware editing operations diff --git a/sample/prelude-modules.el b/sample/prelude-modules.el index 8e7a1320a1..806c116b5d 100644 --- a/sample/prelude-modules.el +++ b/sample/prelude-modules.el @@ -24,6 +24,7 @@ (require 'prelude-js) ;; (require 'prelude-latex) (require 'prelude-lisp) +(require 'prelude-lsp) ;; (require 'prelude-ocaml) (require 'prelude-org) ;; Org-mode helps you keep TODO lists, notes and more (require 'prelude-perl) diff --git a/utils/installer.sh b/utils/installer.sh index ed3c4e3042..df4c73430a 100755 --- a/utils/installer.sh +++ b/utils/installer.sh @@ -202,7 +202,7 @@ then make_prelude_dirs # Reinstate files that weren't replaced tar --skip-old-files -xf "$PRELUDE_INSTALL_DIR_ORIG.pre-prelude.tar" "$PRELUDE_INSTALL_DIR" > /dev/null 2>&1 - [ -n "$PRELUDE_INTO" ] && cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR" + [ -n "$PRELUDE_INTO" ] && cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR/personal" elif [ -e "$PRELUDE_INSTALL_DIR" ] then # File exist but not a regular file or directory @@ -215,7 +215,7 @@ else # Nothing yet so just install prelude install_prelude make_prelude_dirs - cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR" + cp "$PRELUDE_INSTALL_DIR/sample/prelude-modules.el" "$PRELUDE_INSTALL_DIR/personal" fi if [ -z "$PRELUDE_SKIP_BC" ];