Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/bbatsov/prelude:
  [Fix bbatsov#1208] Correct RegExp collisions while loading personal config.
  Rust Language Server (RLS) support
  Move `prelude-modules.el` under `personal` directory
  [Fix bbatsov#1171] Add gnu/linux specific module and exec-path-from-shell support on linux (bbatsov#1203)
  [Fix bbatsov#596] Improve personal config instructions (bbatsov#1202)
  Fix solarized url
  • Loading branch information
suutari-ai committed Dec 16, 2018
2 parents 5858e74 + bb152ad commit 554b11a
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 28 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ savefile/
/indium-workspaces.el
/persp-confs/
/tramp
/prelude-modules.el
projectile-bookmarks.eld
session*
.cask
Expand Down
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 <kbd>C-x C-e</kbd>.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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]
Expand Down
43 changes: 43 additions & 0 deletions core/prelude-linux.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
;;; prelude-linux.el --- Emacs Prelude: linux specific settings.
;;
;; Copyright © 2011-2018 Bozhidar Batsov
;;
;; Author: Stanislav Arnaudov <[email protected]>
;; 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
32 changes: 26 additions & 6 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -117,21 +122,36 @@ 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))

;; 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)

Expand Down
63 changes: 63 additions & 0 deletions modules/prelude-lsp.el
Original file line number Diff line number Diff line change
@@ -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
27 changes: 19 additions & 8 deletions modules/prelude-rust.el
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sample/prelude-modules.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions utils/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" ];
Expand Down

0 comments on commit 554b11a

Please sign in to comment.