Go a little wacky with my config :~)
This commit is contained in:
244
init.el
244
init.el
@@ -1,15 +1,8 @@
|
|||||||
;;; init.el --- Perl 5 Emacs Configuration
|
;;; init.el --- Rawley Fowler's Emacs Configuration
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
;;; A Perl 5 focused Emacs configuration, for the unix genie.
|
;;; A simple Emacs configuration with Evil and Ivy, for Scala and Perl development.
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
(server-start)
|
|
||||||
|
|
||||||
;; -- Get Font Here --
|
|
||||||
;; https://github.com/slavfox/Cozette/releases
|
|
||||||
(add-to-list 'default-frame-alist '(font . "JetBrainsMono Nerd Font-16"))
|
|
||||||
(add-to-list 'default-frame-alist (list '(width . 40) '(height . 40)))
|
|
||||||
|
|
||||||
|
(add-to-list 'default-frame-alist '(font . "JetBrainsMono Nerd Font-13"))
|
||||||
(setq
|
(setq
|
||||||
backup-by-copying t ; don't clobber symlinks
|
backup-by-copying t ; don't clobber symlinks
|
||||||
backup-directory-alist '(("." . "~/.saves")) ; don't litter my fs tree
|
backup-directory-alist '(("." . "~/.saves")) ; don't litter my fs tree
|
||||||
@@ -33,7 +26,7 @@
|
|||||||
(global-display-line-numbers-mode 1)
|
(global-display-line-numbers-mode 1)
|
||||||
|
|
||||||
(defun set-exec-path-from-shell ()
|
(defun set-exec-path-from-shell ()
|
||||||
"Set up Emacs' 'exec-path' and PATH environment."
|
"Set up Emacs' \='exec-path' and PATH environment."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((path-from-shell (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
|
(let ((path-from-shell (replace-regexp-in-string "[ \t\n]*$" "" (shell-command-to-string "$SHELL --login -i -c 'echo $PATH'"))))
|
||||||
(setenv "PATH" path-from-shell)
|
(setenv "PATH" path-from-shell)
|
||||||
@@ -42,76 +35,158 @@
|
|||||||
|
|
||||||
(add-to-list 'load-path "~/.emacs.d/extras")
|
(add-to-list 'load-path "~/.emacs.d/extras")
|
||||||
|
|
||||||
;; Packages
|
|
||||||
(require 'package)
|
(require 'package)
|
||||||
|
|
||||||
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
|
;; Add melpa to your packages repositories
|
||||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
|
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||||
|
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
|
|
||||||
(defconst global/pkgs
|
;; Install use-package if not already installed
|
||||||
'(dracula-theme
|
(unless (package-installed-p 'use-package)
|
||||||
flycheck
|
(package-refresh-contents)
|
||||||
raku-mode
|
(package-install 'use-package))
|
||||||
web-mode
|
|
||||||
json-mode
|
|
||||||
yaml-mode
|
|
||||||
php-mode
|
|
||||||
dockerfile-mode
|
|
||||||
ctrlf
|
|
||||||
magit
|
|
||||||
centaur-tabs
|
|
||||||
evil
|
|
||||||
smex
|
|
||||||
tree-sitter
|
|
||||||
tree-sitter-langs))
|
|
||||||
(when (not package-archive-contents)
|
|
||||||
(package-refresh-contents))
|
|
||||||
(dolist (pkg global/pkgs)
|
|
||||||
(unless (package-installed-p pkg)
|
|
||||||
(package-install pkg)))
|
|
||||||
|
|
||||||
;; General Configutations
|
(require 'use-package)
|
||||||
(global-flycheck-mode)
|
|
||||||
(setq flycheck-perlcritic-severity 3)
|
|
||||||
|
|
||||||
(require 'tree-sitter)
|
;; Various modes
|
||||||
(require 'tree-sitter-langs)
|
(use-package raku-mode)
|
||||||
|
(use-package web-mode)
|
||||||
|
(use-package json-mode)
|
||||||
|
(use-package php-mode)
|
||||||
|
(use-package dockerfile-mode)
|
||||||
|
|
||||||
(require 'ctrlf)
|
;; Enable defer and ensure by default for use-package
|
||||||
(ctrlf-mode +1)
|
;; Keep auto-save/backup files separate from source code: https://github.com/scalameta/metals/issues/1027
|
||||||
|
(setq use-package-always-defer t
|
||||||
|
use-package-always-ensure t
|
||||||
|
backup-directory-alist `((".*" . ,temporary-file-directory))
|
||||||
|
auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
|
||||||
|
|
||||||
(require 'ido)
|
;; Enable scala-mode for highlighting, indentation and motion commands
|
||||||
(ido-mode 1)
|
(use-package scala-mode
|
||||||
|
:interpreter ("scala" . scala-mode))
|
||||||
|
|
||||||
(require 'smex)
|
;; Enable sbt mode for executing sbt commands
|
||||||
(smex-initialize)
|
(use-package sbt-mode
|
||||||
|
:commands sbt-start sbt-command
|
||||||
|
:config
|
||||||
|
;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
|
||||||
|
;; allows using SPACE when in the minibuffer
|
||||||
|
(substitute-key-definition
|
||||||
|
'minibuffer-complete-word
|
||||||
|
'self-insert-command
|
||||||
|
minibuffer-local-completion-map)
|
||||||
|
;; sbt-supershell kills sbt-mode: https://github.com/hvesalai/emacs-sbt-mode/issues/152
|
||||||
|
(setq sbt:program-options '("-Dsbt.supershell=false")))
|
||||||
|
|
||||||
(require 'centaur-tabs)
|
;; Enable nice rendering of diagnostics like compile errors.
|
||||||
(centaur-tabs-mode t)
|
(use-package flycheck
|
||||||
(global-set-key (kbd "C-<prior>") 'centaur-tabs-backward)
|
:init (global-flycheck-mode))
|
||||||
(global-set-key (kbd "C-<next>") 'centaur-tabs-forward)
|
|
||||||
(setq centaur-tabs-plain-icons t)
|
(use-package lsp-mode
|
||||||
(setq centaur-tabs-set-bar 'under)
|
;; Optional - enable lsp-mode automatically in scala files
|
||||||
(setq x-underline-at-descent-line t)
|
;; You could also swap out lsp for lsp-deffered in order to defer loading
|
||||||
(setq centaur-tabs-enable-key-bindings t)
|
:hook (scala-mode . lsp)
|
||||||
(centaur-tabs-change-fonts "JetBrainsMono Nerd Font" 140)
|
(lsp-mode . lsp-lens-mode)
|
||||||
|
:config
|
||||||
|
;; Uncomment following section if you would like to tune lsp-mode performance according to
|
||||||
|
;; https://emacs-lsp.github.io/lsp-mode/page/performance/
|
||||||
|
;; (setq gc-cons-threshold 100000000) ;; 100mb
|
||||||
|
;; (setq read-process-output-max (* 1024 1024)) ;; 1mb
|
||||||
|
;; (setq lsp-idle-delay 0.500)
|
||||||
|
;; (setq lsp-log-io nil)
|
||||||
|
;; (setq lsp-completion-provider :capf)
|
||||||
|
(setq lsp-prefer-flymake nil)
|
||||||
|
;; Makes LSP shutdown the metals server when all buffers in the project are closed.
|
||||||
|
;; https://emacs-lsp.github.io/lsp-mode/page/settings/mode/#lsp-keep-workspace-alive
|
||||||
|
(setq lsp-keep-workspace-alive nil))
|
||||||
|
|
||||||
|
;; Add metals backend for lsp-mode
|
||||||
|
(use-package lsp-metals)
|
||||||
|
|
||||||
|
;; Enable nice rendering of documentation on hover
|
||||||
|
;; Warning: on some systems this package can reduce your emacs responsiveness significally.
|
||||||
|
;; (See: https://emacs-lsp.github.io/lsp-mode/page/performance/)
|
||||||
|
;; In that case you have to not only disable this but also remove from the packages since
|
||||||
|
;; lsp-mode can activate it automatically.
|
||||||
|
(use-package lsp-ui)
|
||||||
|
|
||||||
|
;; lsp-mode supports snippets, but in order for them to work you need to use yasnippet
|
||||||
|
;; If you don't want to use snippets set lsp-enable-snippet to nil in your lsp-mode settings
|
||||||
|
;; to avoid odd behavior with snippets and indentation
|
||||||
|
(use-package yasnippet)
|
||||||
|
|
||||||
|
;; Use company-capf as a completion provider.
|
||||||
|
;;
|
||||||
|
;; To Company-lsp users:
|
||||||
|
;; Company-lsp is no longer maintained and has been removed from MELPA.
|
||||||
|
;; Please migrate to company-capf.
|
||||||
|
(use-package company
|
||||||
|
:hook (scala-mode . company-mode)
|
||||||
|
:config
|
||||||
|
(setq lsp-completion-provider :capf))
|
||||||
|
|
||||||
|
;; Posframe is a pop-up tool that must be manually installed for dap-mode
|
||||||
|
(use-package posframe)
|
||||||
|
|
||||||
|
;; Use the Debug Adapter Protocol for running tests and debugging
|
||||||
|
(use-package dap-mode
|
||||||
|
:hook
|
||||||
|
(lsp-mode . dap-mode)
|
||||||
|
(lsp-mode . dap-ui-mode))
|
||||||
|
|
||||||
|
(use-package counsel
|
||||||
|
:after ivy
|
||||||
|
:config (counsel-mode))
|
||||||
|
|
||||||
|
(use-package ivy
|
||||||
|
:defer 0.1
|
||||||
|
:diminish
|
||||||
|
:bind (("C-c C-r" . ivy-resume)
|
||||||
|
("C-x B" . ivy-switch-buffer-other-window))
|
||||||
|
:custom
|
||||||
|
(ivy-count-format "(%d/%d) ")
|
||||||
|
(ivy-use-virtual-buffers t)
|
||||||
|
:config (ivy-mode))
|
||||||
|
|
||||||
|
(use-package ivy-rich
|
||||||
|
:after ivy
|
||||||
|
:custom
|
||||||
|
(ivy-virtual-abbreviate 'full
|
||||||
|
ivy-rich-switch-buffer-align-virtual-buffer t
|
||||||
|
ivy-rich-path-style 'abbrev)
|
||||||
|
:config
|
||||||
|
(ivy-set-display-transformer 'ivy-switch-buffer
|
||||||
|
'ivy-rich-switch-buffer-transformer))
|
||||||
|
|
||||||
|
(use-package swiper
|
||||||
|
:after ivy
|
||||||
|
:bind (("C-s" . swiper)
|
||||||
|
("C-r" . swiper)))
|
||||||
|
|
||||||
|
(use-package tree-sitter
|
||||||
|
:config
|
||||||
|
(add-hook 'cperl-mode-hook #'tree-sitter-hl-mode)
|
||||||
|
(add-hook 'scala-mode-hook #'tree-sitter-hl-mode)
|
||||||
|
(add-hook 'javascript-mode #'tree-sitter-hl-mode))
|
||||||
|
|
||||||
|
(use-package tree-sitter-langs
|
||||||
|
:after tree-sitter)
|
||||||
|
|
||||||
(require 'evil)
|
|
||||||
(evil-mode 1)
|
|
||||||
(defun save-and-kill-this-buffer ()
|
(defun save-and-kill-this-buffer ()
|
||||||
"Save and kill buffer."
|
"Save and kill buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
(save-buffer)(kill-current-buffer))
|
(save-buffer)
|
||||||
(evil-ex-define-cmd "wq" 'save-and-kill-this-buffer)
|
(kill-current-buffer))
|
||||||
|
|
||||||
(defun kill-inner-word ()
|
(use-package evil
|
||||||
"It's ciw from Vim."
|
:demand t
|
||||||
(interactive)
|
:init
|
||||||
(backward-word)
|
(evil-mode 1)
|
||||||
(kill-word 1))
|
:config
|
||||||
|
(evil-ex-define-cmd "wq" 'save-and-kill-this-buffer))
|
||||||
|
|
||||||
;;; Language Specific Configurations
|
|
||||||
;; Perl
|
;; Perl
|
||||||
(require 'perltidy) ; Thanks to https://github.com/zakame/perltidy.el
|
(require 'perltidy) ; Thanks to https://github.com/zakame/perltidy.el
|
||||||
(require 'perl-mode)
|
(require 'perl-mode)
|
||||||
@@ -120,9 +195,8 @@
|
|||||||
(setq cperl-highlight-variables-indiscriminately t)
|
(setq cperl-highlight-variables-indiscriminately t)
|
||||||
(defalias 'perl-mode 'cperl-mode)
|
(defalias 'perl-mode 'cperl-mode)
|
||||||
(add-hook 'before-save-hook #'(lambda ()
|
(add-hook 'before-save-hook #'(lambda ()
|
||||||
(when (or (eq major-mode 'perl-mode) (eq major-mode 'cperl-mode))
|
(when (or (eq major-mode 'perl-mode) (eq major-mode 'cperl-mode))
|
||||||
(perltidy-buffer))))
|
(perltidy-buffer))))
|
||||||
(add-hook 'cperl-mode-hook #'tree-sitter-hl-mode)
|
|
||||||
(setq cperl-indent-parens-as-block t)
|
(setq cperl-indent-parens-as-block t)
|
||||||
|
|
||||||
(eval-after-load 'cperl-mode
|
(eval-after-load 'cperl-mode
|
||||||
@@ -140,47 +214,19 @@
|
|||||||
:slant 'italic
|
:slant 'italic
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
(add-to-list 'auto-mode-alist '("\\.html.ep\\'" . web-mode)) ; Mojo templates
|
(add-to-list 'auto-mode-alist '("\\.html.ep\\'" . web-mode))
|
||||||
|
|
||||||
;; PHP
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.blade.php\\'" . web-mode))
|
|
||||||
|
|
||||||
;; Keys
|
|
||||||
(global-set-key (kbd "C-c C-c") #'kill-inner-word)
|
|
||||||
(global-set-key (kbd "M-x") #'smex)
|
|
||||||
|
|
||||||
(custom-set-variables
|
(custom-set-variables
|
||||||
;; custom-set-variables was added by Custom.
|
;; custom-set-variables was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
'(custom-enabled-themes '(dracula))
|
|
||||||
'(custom-safe-themes
|
|
||||||
'("fe1c13d75398b1c8fd7fdd1241a55c286b86c3e4ce513c4292d01383de152cb7" default))
|
|
||||||
'(delete-selection-mode nil)
|
'(delete-selection-mode nil)
|
||||||
'(package-selected-packages '(raku-mode docker-compose-mode flycheck dracula-theme))
|
'(package-selected-packages
|
||||||
'(safe-local-variable-values
|
'(evil-mode ivy-rich counsel dap-mode company yasnippet lsp-ui lsp-metals lsp-mode sbt-mode yaml-mode web-mode tree-sitter-langs spinner smex scala-mode s raku-mode php-mode markdown-mode magit lv json-mode ht flycheck evil dracula-theme dockerfile-mode ctrlf centaur-tabs)))
|
||||||
'((eval setq flycheck-perl-include-path
|
|
||||||
(add-to-list 'flycheck-perl-include-path
|
|
||||||
(concat
|
|
||||||
(expand-file-name
|
|
||||||
(locate-dominating-file default-directory ".dir-locals.el"))
|
|
||||||
"lib")))
|
|
||||||
(eval let
|
|
||||||
((project-dir
|
|
||||||
(expand-file-name
|
|
||||||
(locate-dominating-file default-directory ".dir-locals.el"))))
|
|
||||||
(setq-local flycheck-perl-include-path
|
|
||||||
(list
|
|
||||||
(concat project-dir "lib")
|
|
||||||
(concat project-dir "local/lib/perl5/")))))))
|
|
||||||
(custom-set-faces
|
(custom-set-faces
|
||||||
;; custom-set-faces was added by Custom.
|
;; custom-set-faces was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
)
|
)
|
||||||
|
|
||||||
(provide 'init)
|
|
||||||
|
|
||||||
;;; init.el ends here.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user