Go a little wacky with my config :~)
This commit is contained in:
240
init.el
240
init.el
@@ -1,15 +1,8 @@
|
||||
;;; init.el --- Perl 5 Emacs Configuration
|
||||
;;; init.el --- Rawley Fowler's Emacs Configuration
|
||||
;;; Commentary:
|
||||
;;; A Perl 5 focused Emacs configuration, for the unix genie.
|
||||
|
||||
;;; 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)))
|
||||
;;; A simple Emacs configuration with Evil and Ivy, for Scala and Perl development.
|
||||
|
||||
(add-to-list 'default-frame-alist '(font . "JetBrainsMono Nerd Font-13"))
|
||||
(setq
|
||||
backup-by-copying t ; don't clobber symlinks
|
||||
backup-directory-alist '(("." . "~/.saves")) ; don't litter my fs tree
|
||||
@@ -33,7 +26,7 @@
|
||||
(global-display-line-numbers-mode 1)
|
||||
|
||||
(defun set-exec-path-from-shell ()
|
||||
"Set up Emacs' 'exec-path' and PATH environment."
|
||||
"Set up Emacs' \='exec-path' and PATH environment."
|
||||
(interactive)
|
||||
(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)
|
||||
@@ -42,76 +35,158 @@
|
||||
|
||||
(add-to-list 'load-path "~/.emacs.d/extras")
|
||||
|
||||
;; Packages
|
||||
(require 'package)
|
||||
|
||||
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
|
||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
|
||||
;; Add melpa to your packages repositories
|
||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
|
||||
|
||||
(package-initialize)
|
||||
|
||||
(defconst global/pkgs
|
||||
'(dracula-theme
|
||||
flycheck
|
||||
raku-mode
|
||||
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)))
|
||||
;; Install use-package if not already installed
|
||||
(unless (package-installed-p 'use-package)
|
||||
(package-refresh-contents)
|
||||
(package-install 'use-package))
|
||||
|
||||
;; General Configutations
|
||||
(global-flycheck-mode)
|
||||
(setq flycheck-perlcritic-severity 3)
|
||||
(require 'use-package)
|
||||
|
||||
(require 'tree-sitter)
|
||||
(require 'tree-sitter-langs)
|
||||
;; Various modes
|
||||
(use-package raku-mode)
|
||||
(use-package web-mode)
|
||||
(use-package json-mode)
|
||||
(use-package php-mode)
|
||||
(use-package dockerfile-mode)
|
||||
|
||||
(require 'ctrlf)
|
||||
(ctrlf-mode +1)
|
||||
;; Enable defer and ensure by default for use-package
|
||||
;; 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)
|
||||
(ido-mode 1)
|
||||
;; Enable scala-mode for highlighting, indentation and motion commands
|
||||
(use-package scala-mode
|
||||
:interpreter ("scala" . scala-mode))
|
||||
|
||||
(require 'smex)
|
||||
(smex-initialize)
|
||||
;; Enable sbt mode for executing sbt commands
|
||||
(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)
|
||||
(centaur-tabs-mode t)
|
||||
(global-set-key (kbd "C-<prior>") 'centaur-tabs-backward)
|
||||
(global-set-key (kbd "C-<next>") 'centaur-tabs-forward)
|
||||
(setq centaur-tabs-plain-icons t)
|
||||
(setq centaur-tabs-set-bar 'under)
|
||||
(setq x-underline-at-descent-line t)
|
||||
(setq centaur-tabs-enable-key-bindings t)
|
||||
(centaur-tabs-change-fonts "JetBrainsMono Nerd Font" 140)
|
||||
;; Enable nice rendering of diagnostics like compile errors.
|
||||
(use-package flycheck
|
||||
:init (global-flycheck-mode))
|
||||
|
||||
(use-package lsp-mode
|
||||
;; Optional - enable lsp-mode automatically in scala files
|
||||
;; You could also swap out lsp for lsp-deffered in order to defer loading
|
||||
:hook (scala-mode . lsp)
|
||||
(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 ()
|
||||
"Save and kill buffer."
|
||||
(interactive)
|
||||
(save-buffer)(kill-current-buffer))
|
||||
(evil-ex-define-cmd "wq" 'save-and-kill-this-buffer)
|
||||
(save-buffer)
|
||||
(kill-current-buffer))
|
||||
|
||||
(defun kill-inner-word ()
|
||||
"It's ciw from Vim."
|
||||
(interactive)
|
||||
(backward-word)
|
||||
(kill-word 1))
|
||||
(use-package evil
|
||||
:demand t
|
||||
:init
|
||||
(evil-mode 1)
|
||||
:config
|
||||
(evil-ex-define-cmd "wq" 'save-and-kill-this-buffer))
|
||||
|
||||
;;; Language Specific Configurations
|
||||
;; Perl
|
||||
(require 'perltidy) ; Thanks to https://github.com/zakame/perltidy.el
|
||||
(require 'perl-mode)
|
||||
@@ -122,7 +197,6 @@
|
||||
(add-hook 'before-save-hook #'(lambda ()
|
||||
(when (or (eq major-mode 'perl-mode) (eq major-mode 'cperl-mode))
|
||||
(perltidy-buffer))))
|
||||
(add-hook 'cperl-mode-hook #'tree-sitter-hl-mode)
|
||||
(setq cperl-indent-parens-as-block t)
|
||||
|
||||
(eval-after-load 'cperl-mode
|
||||
@@ -140,47 +214,19 @@
|
||||
:slant 'italic
|
||||
)
|
||||
))
|
||||
(add-to-list 'auto-mode-alist '("\\.html.ep\\'" . web-mode)) ; Mojo templates
|
||||
|
||||
;; 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)
|
||||
(add-to-list 'auto-mode-alist '("\\.html.ep\\'" . web-mode))
|
||||
|
||||
(custom-set-variables
|
||||
;; custom-set-variables was added by Custom.
|
||||
;; 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.
|
||||
'(custom-enabled-themes '(dracula))
|
||||
'(custom-safe-themes
|
||||
'("fe1c13d75398b1c8fd7fdd1241a55c286b86c3e4ce513c4292d01383de152cb7" default))
|
||||
'(delete-selection-mode nil)
|
||||
'(package-selected-packages '(raku-mode docker-compose-mode flycheck dracula-theme))
|
||||
'(safe-local-variable-values
|
||||
'((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/")))))))
|
||||
'(package-selected-packages
|
||||
'(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)))
|
||||
(custom-set-faces
|
||||
;; custom-set-faces was added by Custom.
|
||||
;; 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.
|
||||
)
|
||||
|
||||
(provide 'init)
|
||||
|
||||
;;; init.el ends here.
|
||||
|
||||
Reference in New Issue
Block a user