whompmacs/whomp/whomp-development.el

108 lines
3.7 KiB
EmacsLisp

;;
;; development assistance packages
;;
;; dev layer toggles
(defcustom whomp-development nil
"Whether or not to enable development assistance packages."
:type '(set (const :tag "None" nil)
(const :tag "lsp" lspmode) ;; generally required for other modes
(const :tag "magit" magitmode) ;; git integration
(const :tag "projectile" projectilemode) ;; project management
(const :tag "go" gomode) ;; go language support
(const :tag "python" pythonmode) ;; python language support
(const :tag "elpy" elpymode) ;; python language support (elpy)
(const :tag "yaml" yamlmode) ;; yaml language support
(const :tag "rainbow-delimiters" rainbowmode) ;; rainbow-delimiters support
)
:group 'whomp-config)
;; lsp-mode
(when (memq 'lspmode whomp-development)
(straight-use-package 'lsp-mode)
(straight-use-package 'lsp-ui)
(when (eq 'treemacs whomp-dirbrowser)
(straight-use-package 'lsp-treemacs))
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024))
(whomp/add-key-binding "l" 'lsp-keymap-prefix "lsp-keymap-prefix")
(straight-use-package 'eglot)
(require 'eglot)
(message "lsp-mode loaded"))
;; magit
(when (memq 'magitmode whomp-development)
(straight-use-package 'magit)
(straight-use-package 'forge)
(straight-use-package 'magit-todos)
(whomp/add-key-binding "g s" 'magit-status "Git status (magit entrypoint)")
(whomp/add-key-binding "g l" 'magit-log "Git log (magit entrypoint")
(whomp/add-key-binding "g b" 'magit-blame "Git blame (magit entrypoint")
(whomp/add-key-binding "g f" 'magit-find-file "Git find file (magit entrypoint")
(message "magit loaded"))
;; projectile
(when (memq 'projectilemode whomp-development)
(straight-use-package 'projectile)
(whomp/add-key-binding "p" 'projectile-command-map "Projectile commands")
(message "projectile loaded"))
;; go-mode
(when (memq 'gomode whomp-development)
(straight-use-package 'go-mode)
(straight-use-package 'go-eldoc)
(straight-use-package 'go-projectile)
(straight-use-package 'go-snippets)
(setq lsp-go-analyses '((shadow . t)
(simplifycompositelit . :json-false)))
(when (executable-find "gopls")
(add-hook 'go-mode-hook #'lsp-deferred)
(add-hook 'go-mode-hook 'eglot-ensure))
(when (executable-find "goimports")
(setq gofmt-command "goimports"))
(add-hook 'before-save-hook 'gofmt-before-save)
(message "go-mode loaded"))
;; python-mode
(when (memq 'pythonmode whomp-development)
(when (memq 'elpymode whomp-development)
(straight-use-package 'elpy)
(elpy-enable))
(when (not (memq 'elpymode whomp-development))
(add-hook 'python-mode-hook (lambda ()
(setq-local tab-width 2)))
(add-hook 'python-mode-hook #'lsp-deferred))
(when (executable-find "pylsp")
(add-hook 'python-mode-hook 'eglot-ensure))
(use-package python-black
:demand t
:straight t
:after python
:hook (python-mode . python-black-on-save-mode))
(message "python-mode loaded"))
;; yaml-mode
(when (memq 'yamlmode whomp-development)
(straight-use-package 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
;; yaml-mode is a bit too aggressive with its indentation
;; so we'll disable it and use the default
(add-hook 'yaml-mode-hook
(lambda ()
(setq-local electric-indent-inhibit t)
(setq-local electric-layout-rules nil)))
(message "yaml-mode loaded"))
;; rainbow-delimiters-mode
(when (memq 'rainbowmode whomp-development)
(straight-use-package 'rainbow-delimiters)
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
(message "rainbow-delimiters-mode loaded"))
(message "W.H.O.M.P. development assistance packages loaded")
(provide 'whomp-development)
;; whomp-development.el ends here