diff options
Diffstat (limited to 'emacs')
| -rw-r--r-- | emacs/README.md | 34 | ||||
| -rw-r--r-- | emacs/emacs.bash | 5 | ||||
| -rw-r--r-- | emacs/emacs.el | 162 | ||||
| -rw-r--r-- | emacs/plan.org | 4 |
4 files changed, 205 insertions, 0 deletions
diff --git a/emacs/README.md b/emacs/README.md new file mode 100644 index 00000000..d26b89d8 --- /dev/null +++ b/emacs/README.md @@ -0,0 +1,34 @@ +# Don't fear the Emacs + +If you are here, you are probably thinking about adopting Emacs as your editor. +Perhaps you are facing analysis paralysis, wondering what's the best way to do it. + +Just do it! +It's a bit alien at first, but I didn't need much time to do all my editing in Emacs. +I haven't learnt Emacs Lisp and I haven't adopted any large configuration package. + +[My `emacs.el` right now is 80 lines](https://github.com/alexpdp7/alexpdp7/blob/811f60a331da44c9621d771ccc34ee0c0555080e/emacs/emacs.el). +Perhaps when you read this, my current config will be much bigger.. +But I'm definitely happy today with my 80-line config. + +You can start without a configuration. +Whenever you can't do something, search Internet. +You will quickly learn the hotkeys you need the most. +Once you can search, undo, cut, copy, and paste, you can take your time with the rest. +Don't avoid the menus. +Sometimes it's just easier to hit F10 and find something in the menus. +You can also M-x to execute commands, like `indent-region`. + +When you get to the point where you really need to add packages, I do recommend you use [straight.el](https://github.com/radian-software/straight.el), it makes installing packages easy. +Maybe it has some drawbacks, but with straight.el, I've been able to create a configuration that I feel is productive. +(Although it seems to have some issues with corporate firewalls. But I added comments about solving that.) + +Some of the stuff in my `emacs.el` is maybe not critical, like Helm and Projectile. +I really like Projectile, but often I just run `emacs $file` in a new terminal tab. +It's easy, and you don't need to learn a ton of window/buffer/etc. management. +(Be sure to check [emacs.bash](https://github.com/alexpdp7/alexpdp7/blob/master/emacs/emacs.bash) for something you can source in your bash to prevent frequent Emacs startups.) + +Many other stuff is support for things I do: AsciiDoc, Vale, Rust, Python, Java, YAML, Ansible, Puppet. +You probably need other plugins, and maybe you don't need them right now. + +Maybe try out some of the large configurations, to learn what fancy stuff is available and add it as you become comfortable with the previous thing you configured. diff --git a/emacs/emacs.bash b/emacs/emacs.bash new file mode 100644 index 00000000..2312f786 --- /dev/null +++ b/emacs/emacs.bash @@ -0,0 +1,5 @@ +# source this file from your bash startup script + +alias emacs="emacsclient --create-frame -t" +export ALTERNATE_EDITOR="" +export EDITOR="emacsclient -t" diff --git a/emacs/emacs.el b/emacs/emacs.el new file mode 100644 index 00000000..cd4ba72d --- /dev/null +++ b/emacs/emacs.el @@ -0,0 +1,162 @@ +;; symlink this file to ~/.emacs + +;; if you get "End of file during parsing", refer to: +;; +;; https://github.com/radian-software/straight.el#debugging +;; +;; , particularly the note "Sometimes, in a corporate environment"... you +;; might need to clone straight.el into ~/.emacs.d manually + +(defvar bootstrap-version) +(let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) + (bootstrap-version 6)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) + +;; Nicer defaults + +(setq compilation-scroll-output t) +(setq column-number-mode t) +(setq-default show-trailing-whitespace t) + +;; From https://www.emacswiki.org/emacs/SmoothScrolling#h5o-8 +(setq scroll-step 1) +(setq scroll-conservatively 10000) +(setq auto-window-vscroll nil) + +;; Colorblind friendly theme. +;; Emacs 28 has modus themes, but EL9 only has emacs 27 + +(straight-use-package 'modus-themes) +(require 'modus-themes) +(load-theme 'modus-operandi :no-confirm) + +;; Install xclip so cutting/copying in Emacs on a terminal affects the graphical clipboard + +(straight-use-package 'xclip) +(xclip-mode 1) + +;; Fancy undo + +(straight-use-package 'undo-tree) +(global-undo-tree-mode) +(setq undo-tree-visualizer-diff t) +(setq undo-tree-visualizer-timestamp t) +(setq undo-tree-auto-save-history t) + +;; Do not spill temporary files everywhere + +;; https://stackoverflow.com/a/18330742 +(defvar --backup-directory (concat user-emacs-directory "backups")) +(if (not (file-exists-p --backup-directory)) + (make-directory --backup-directory t)) +(setq backup-directory-alist `(("." . ,--backup-directory))) + +;; https://www.reddit.com/r/emacs/comments/tejte0/undotree_bug_undotree_files_scattering_everywhere/?rdt=39892 +(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))) + +;; nicer completion UI + +(straight-use-package 'helm) + +(global-set-key (kbd "M-x") #'helm-M-x) +(global-set-key (kbd "C-x C-f") #'helm-find-files) +(global-set-key (kbd "C-x C-b") #'helm-mini) + +(setq helm-ff-skip-boring-files t) + +;; nicer project support + +(straight-use-package 'projectile) +(straight-use-package 'helm-projectile) + +(projectile-mode +1) +(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) +(helm-projectile-on) + +;; LSP base for Rust and Java + +(straight-use-package 'lsp-mode) +(straight-use-package 'company-mode) +(straight-use-package 'lsp-ui) +(straight-use-package 'yasnippet) + +(add-hook 'java-mode-hook (lambda () + (setq c-basic-offset 2 + indent-tabs-mode f))) + +(yas-global-mode 1) + +;; Rust support + +(straight-use-package 'rust-mode) +(add-hook 'rust-mode-hook #'lsp) +(add-hook 'rust-mode-hook + (lambda () (setq indent-tabs-mode nil))) +(setq rust-format-on-save t) + +;; Python support + +(straight-use-package 'elpy) +(elpy-enable) + +;;; Java Support + +(straight-use-package 'lsp-java) +(add-hook 'java-mode-hook 'lsp) + +;; YAML support + +(straight-use-package 'yaml-mode) + +;; lsp-mode seems unusably slow, so don't install the Ansible language server +;; if you want to get it working, try https://www.reddit.com/r/emacs/comments/ybbkks/how_to_properly_set_up_lsp_ansible_language/itfxoaa/ + +(straight-use-package 'ansible) +(add-hook 'yaml-mode-hook 'ansible) + +;; Puppet support; mostly for syntax highlighting + +(straight-use-package 'puppet-mode) + +;; ==== WORK ==== + +;; Abbrevs for work, declared in emacs.el for version control + +(clear-abbrev-table global-abbrev-table) + +(progn + (when (boundp 'daoc-mode-abbrev-table) + (clear-abbrev-table adoc-mode-abbrev-table)) + (define-abbrev-table 'adoc-mode-abbrev-table + '( + ("oomit" "_...output omitted..._") +))) + +(set-default 'abbrev-mode t) + +(setq save-abbrevs nil) + +;; AsciiDoc + Vale + Aspell support for work + +(straight-use-package 'adoc-mode) + +(straight-use-package + '(flymake-vale :type git :host github :repo "tpeacock19/flymake-vale")) + +(add-hook 'adoc-mode-hook #'flymake-vale-load) +(add-hook 'find-file-hook 'flymake-vale-maybe-load) +(add-hook 'adoc-mode-hook 'flymake-mode) + +(straight-use-package 'flymake-aspell) +(add-hook 'adoc-mode-hook #'flymake-aspell-setup) +(setq ispell-dictionary "en_US-RH") + +(add-hook 'adoc-mode-hook (lambda () (setq flymake-aspell-aspell-mode "asciidoc"))) diff --git a/emacs/plan.org b/emacs/plan.org new file mode 100644 index 00000000..2edcc74b --- /dev/null +++ b/emacs/plan.org @@ -0,0 +1,4 @@ +* https://www.reddit.com/r/emacs/comments/10nmcus/dont_fear_the_emacs/ +* Magit +* mu4e +* Elfeed + elfeed-protocol/fever |
