From d26a4084158e8b9179b8f9903ea7c42f1675bf1c Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Wed, 7 Oct 2020 10:21:05 -0700 Subject: [PATCH] Upgrade to emacs 27.1, modify bashrc, and make ruby mode play nice with flycheck --- README.md | 17 +++++++++++++++++ dotfiles/bash/bashrc | 4 ++++ dotfiles/emacs.d/init.el | 36 ++++++++++++++++++++++++------------ dotfiles/emacs.d/package.el | 4 ---- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index a2ac6ce..06ae7fe 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,23 @@ Finally, `cd` to the root of your project and run `gtags`. You now have function Before programming Java, install `eclim`, and `eclipse`. +### Ruby + +Ruby makes using emacs a challenge. + +Flycheck likes to complain about `bundle exec` even on emacs 27.1+. There are a few things you need to do to make things work nicely: + +1. Use `lsp-mode` instead of robe and launch a ruby server with that. For some reason robe gets in the way of things like `.dir-locals.el`. +2. On a per-project basis, put a `.dir-locals.el` file with the following in it: + +``` +((ruby-mode . ((eval . (setq flycheck-command-wrapper-function + (lambda (command) + (append '("bundle" "exec") command))))))) +``` + +Which will allow bundle exec to work with flycheck. + ## Joe Editor Always build from source to get the latest features. You will need at least diff --git a/dotfiles/bash/bashrc b/dotfiles/bash/bashrc index 802e408..499336a 100644 --- a/dotfiles/bash/bashrc +++ b/dotfiles/bash/bashrc @@ -135,6 +135,10 @@ export HISTCONTROL=ignoredups # If go is installed, set the $GOPATH to the projects directory created above. if which go > /dev/null; then export GOPATH=$HOME/projects/go; fi +# For emacs 27.1+. This way no matter what config changes or version of emacs +# I find myself on it will always work the same. +export XDG_CONFIG_HOME="${HOME}/.emacs.d" + # ------------ END EXPORTS ------------# diff --git a/dotfiles/emacs.d/init.el b/dotfiles/emacs.d/init.el index be5d634..277f344 100644 --- a/dotfiles/emacs.d/init.el +++ b/dotfiles/emacs.d/init.el @@ -19,7 +19,9 @@ There are two things you can do about this warning: (when (< emacs-major-version 24) ;; For important compatibility libraries like cl-lib (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))))) -(package-initialize) + +(when (< emacs-major-version 27) + (package-initialize)) (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t) @@ -45,6 +47,17 @@ There are two things you can do about this warning: (setq inhibit-startup-screen t) ;;-------------------------------------------------------------------------------------- +;; Emacs 27+ Configs +;;-------------------------------------------------------------------------------------- + +;; Set the directory to the home directory. This has the side effect of making +;; emacs load files from the home directory when called as emacs -nw xyz. +(when (>= emacs-major-version 27) + (setq default-directory "~/") + (setq command-line-default-directory "~/")) + + +;;-------------------------------------------------------------------------------------- ;; Display battery life in modeline ;;-------------------------------------------------------------------------------------- @@ -119,7 +132,7 @@ There are two things you can do about this warning: (name . "\*info\*"))) ("Dired" (mode . dired-mode)) ;; Dev has groups for all languages you program in - ("Dev" (or (mode . cc-mode) + ("Dev" (or (filename . ".c") (filename . ".cpp") (filename . ".hpp") @@ -304,13 +317,6 @@ There are two things you can do about this warning: (require 'rvm) (rvm-use-default) -(add-hook 'ruby-mode-hook 'robe-mode) - -(eval-after-load 'company - '(push 'company-robe company-backends)) - -(add-hook 'robe-mode-hook 'ac-robe-setup) - (advice-add 'inf-ruby-console-auto :before #'rvm-activate-corresponding-ruby) ;;;;;;;;;;; C/C++ @@ -383,10 +389,16 @@ There are two things you can do about this warning: ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. - '(lisp-indent-function (quote common-lisp-indent-function)) + '(lisp-indent-function 'common-lisp-indent-function) '(package-selected-packages - (quote - (arjen-grey-theme oceanic-theme company-lsp projectile smex grizzl flycheck-pos-tip flycheck material-theme expand-region wrap-region rainbow-delimiters powerline linum-relative golden-ratio fill-column-indicator autopair exec-path-from-shell ws-butler yaml-mode python-mode protobuf-mode paredit nasm-mode meson-mode markdown-mode magit gradle-mode gitignore-mode feature-mode counsel company-jedi jedi-core company-emacs-eclim company-irony company ag)))) + '(arjen-grey-theme oceanic-theme company-lsp projectile smex grizzl flycheck-pos-tip flycheck material-theme expand-region wrap-region rainbow-delimiters powerline linum-relative golden-ratio fill-column-indicator autopair exec-path-from-shell ws-butler yaml-mode python-mode protobuf-mode paredit nasm-mode meson-mode markdown-mode magit gradle-mode gitignore-mode feature-mode counsel company-jedi jedi-core company-emacs-eclim company-irony company ag)) + '(safe-local-variable-values + '((eval setq flycheck-command-wrapper-function + (lambda + (command) + (append + '("bundle" "exec") + command)))))) (custom-set-faces ;; custom-set-faces was added by Custom. diff --git a/dotfiles/emacs.d/package.el b/dotfiles/emacs.d/package.el index d0be4a5..1a2e19e 100644 --- a/dotfiles/emacs.d/package.el +++ b/dotfiles/emacs.d/package.el @@ -33,7 +33,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;; ;; Programming modes - cc-mode feature-mode gitignore-mode gradle-mode @@ -50,9 +49,6 @@ ;; Rails rinari - ;; Ruby autocomplete - robe - ;; RVM support rvm ;;;;;;;;;;;;;;;;;;;;