From c3fc728d9826ab38733c6d71083cd1be85245e0d Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sat, 20 Feb 2021 22:01:34 -0500 Subject: [PATCH] Add Clojure, Python, Terraform, and YAML config --- emacs/.emacs.d/config/init-clojure.el | 50 +++++++++++++++++++++++ emacs/.emacs.d/config/init-python.el | 54 +++++++++++++++++++++++++ emacs/.emacs.d/config/init-terraform.el | 7 ++++ emacs/.emacs.d/config/init-yaml.el | 9 +++++ emacs/.emacs.d/init.el | 4 ++ 5 files changed, 124 insertions(+) create mode 100644 emacs/.emacs.d/config/init-clojure.el create mode 100644 emacs/.emacs.d/config/init-python.el create mode 100644 emacs/.emacs.d/config/init-terraform.el create mode 100644 emacs/.emacs.d/config/init-yaml.el diff --git a/emacs/.emacs.d/config/init-clojure.el b/emacs/.emacs.d/config/init-clojure.el new file mode 100644 index 0000000..ce0fad7 --- /dev/null +++ b/emacs/.emacs.d/config/init-clojure.el @@ -0,0 +1,50 @@ +;; -*- lexical-binding: t; -*- + +;; Clojure configuration +(use-package clojure-mode + :mode (("\\.clj\\'" . clojure-mode) + ("\\.cljs\\'" . clojurescript-mode) + ("\\.cljc\\'" . clojurec-mode) + ("\\.edn\\'" . clojure-mode)) + :config + (define-clojure-indent + (defroutes 'defun) + (GET 2) + (POST 2) + (PUT 2) + (DELETE 2) + (HEAD 2) + (ANY 2) + (OPTIONS 2) + (PATCH 2) + (rfn 2) + (let-routes 1) + (context 2) + (:= 3) + (:+ 3) + (match 1) + (for-all 2) + (checking 2) + (let-flow 1))) + +;; Flycheck support +(use-package flycheck-clj-kondo + :after (clojure-mode) + :if (executable-find "clj-kondo")) + +(use-package cider + :commands (cider-mode cider-jack-in cider-jack-in-clojurescript) + :custom + (cider-known-endpoints + '(("local" "localhost" "4005"))) + (cider-prompt-for-symbol nil) + (general-def cider-mode-map "C-c t" cider-test-commands-map) + :hook ((clojure-mode . cider-mode) + (clojurescript-mode . cider-mode) + (clojurec-mode . cider-mode)) + :general + (cider-stacktrace-mode-map "SPC" leader-map) + ('normal cider-mode-map "M-." #'cider-find-var) + (cider-repl-mode-map "C-c C-l" #'cider-repl-clear-buffer)) + +(provide 'init-clojure) diff --git a/emacs/.emacs.d/config/init-python.el b/emacs/.emacs.d/config/init-python.el new file mode 100644 index 0000000..b0c48d2 --- /dev/null +++ b/emacs/.emacs.d/config/init-python.el @@ -0,0 +1,54 @@ +;; -*- lexical-binding: t; -*- + +;; Python configuration +(use-package python + :defer t + :straight (:type built-in) + :config + ;; Redefine the python-mypy flycheck checker to account for projectile-compilation-dir + (flycheck-define-checker python-mypy + "Mypy syntax and type checker. Requires mypy>=0.580. + + See URL `http://mypy-lang.org/'." + :command ("mypy" + "--show-column-numbers" + (config-file "--config-file" flycheck-python-mypy-config) + (option "--cache-dir" flycheck-python-mypy-cache-dir) + source-original) + :error-patterns + ((error line-start (file-name) ":" line (optional ":" column) + ": error:" (message) line-end) + (warning line-start (file-name) ":" line (optional ":" column) + ": warning:" (message) line-end) + (info line-start (file-name) ":" line (optional ":" column) + ": note:" (message) line-end)) + :modes python-mode + ;; Ensure the file is saved, to work around + ;; https://github.com/python/mypy/issues/4746. + :predicate flycheck-buffer-saved-p + :working-directory (lambda (checker) + (or (projectile-compilation-dir) + default-directory)))) + +;; pyvenv to track virtual environments +(use-package pyvenv + :defer 3 + :config + (pyvenv-mode) + (pyvenv-tracking-mode)) + +;; pyenv to track Python version +(use-package pyenv-mode + :defer t) + +;; LSP using Microsoft's pyright language server +(use-package lsp-pyright + :hook (python-mode . (lambda () + (require 'lsp-pyright) + (lsp-deferred))) + :custom + (lsp-pyright-use-library-code-for-types t) + :general + (python-mode-map "C-c C-d" #'lsp-describe-thing-at-point)) + +(provide 'init-python) diff --git a/emacs/.emacs.d/config/init-terraform.el b/emacs/.emacs.d/config/init-terraform.el new file mode 100644 index 0000000..c8bdc3d --- /dev/null +++ b/emacs/.emacs.d/config/init-terraform.el @@ -0,0 +1,7 @@ +;; -*- lexical-binding: t; -*- + +;; Configuration as code! +(use-package terraform-mode + :mode "\\.tf\\'") + +(provide 'init-terraform) diff --git a/emacs/.emacs.d/config/init-yaml.el b/emacs/.emacs.d/config/init-yaml.el new file mode 100644 index 0000000..e169577 --- /dev/null +++ b/emacs/.emacs.d/config/init-yaml.el @@ -0,0 +1,9 @@ +;; -*- lexical-binding: t; -*- + +;; YAML - literally the worst but still holds an important place in my life +(use-package yaml-mode + :mode ("\\.yaml\\'" "\\.yml\\'") + :config + (add-hook 'yaml-mode-hook #'highlight-indent-guides-mode)) + +(provide 'init-yaml) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 2db95c7..ec3a511 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -70,6 +70,10 @@ (require 'init-ide) (require 'init-eshell) (require 'init-help) +(require 'init-python) +(require 'init-clojure) +(require 'init-yaml) +(require 'init-terraform) ;; Load the custom file (when (file-exists-p custom-file)