summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--emacs/custom/my-prog.el223
1 files changed, 97 insertions, 126 deletions
diff --git a/emacs/custom/my-prog.el b/emacs/custom/my-prog.el
index f512a78..8c7925d 100644
--- a/emacs/custom/my-prog.el
+++ b/emacs/custom/my-prog.el
@@ -1,135 +1,106 @@
-;;; my-prog.el --- Configures emacs for various programming languages
+;;; my-prog.el --- Configures emacs for various programming languages -*- lexical-binding: t -*-
+
;;; Commentary:
;;; Code:
-(require 'use-package)
-
-(use-package man
- :custom
- (Man-notify-method 'aggressive)
- (Man-fontify-manpage-flag t))
-
-(use-package compile
- :ensure nil
- :custom
- (compilation-scroll-output t)
- ;; Skip over warnings and info messages in compilation
- (compilation-skip-threshold 2)
- ;; Don't freeze when process reads from stdin
- (compilation-disable-input t)
- ;; Show three lines of context around the current message
- (compilation-context-lines 3))
-
-(use-package flymake
- :ensure nil
- :hook ((prog-mode . flymake-mode)
- (conf-mode . flymake-mode))
- :bind (:map flymake-mode-map (("C-c ! s" . flymake-start)
- ("C-c ! d" . flymake-show-buffer-diagnostics)
- ("C-c ! n" . flymake-goto-next-error)
- ("C-c ! p" . flymake-goto-prev-error)))
- :custom
- (elisp-flymake-byte-compile-load-path load-path))
+(customize-set-variable 'Man-notify-method 'aggressive)
+(customize-set-variable 'Man-fontify-manpage-flag t)
+
+;; Skip over warnings and info messages in compilation
+(customize-set-variable 'compilation-skip-threshold 2)
+;; Don't freeze when process reads from stdin
+(customize-set-variable 'compilation-disable-input t)
+;; Show three lines of context around the current message
+(customize-set-variable 'compilation-context-lines 3)
+;; Jump to first error
+(customize-set-variable 'compilation-scroll-output 'first-error)
+
+(customize-set-variable 'flymake-start-on-flymake-mode t)
+(customize-set-variable 'flymake-start-on-save-buffer t)
+(customize-set-variable 'flymake-no-changes-timeout nil)
+(customize-set-variable 'flymake-proc-compilation-prevents-syntax-check t)
+(customize-set-variable 'flymake-wrap-around nil)
+(customize-set-variable 'elisp-flymake-byte-compile-load-path load-path)
+
+(with-eval-after-load 'flymake
+ (define-key flymake-mode-map (kbd "C-c ! n") 'flymake-goto-next-error)
+ (define-key flymake-mode-map (kbd "C-c ! p") 'flymake-goto-prev-error)
+ (define-key flymake-mode-map (kbd "C-c ! d") 'flymake-show-diagnostics-buffer))
+
+(dolist (hook '(prog-mode-hook conf-mode-hook))
+ (add-hook hook 'flymake-mode))
;; yasnippet is required to support place holders with eglot
-(use-package yasnippet
- :ensure t
- :hook
- ((prog-mode org-mode dap-ui-repl-mode conf-mode) . yas-minor-mode)
- :init
- (setq yas-snippet-dirs (list (expand-file-name "etc/snippets" user-emacs-directory)))
- :config
- (yas-reload-all))
-
-(use-package auto-fill
- :hook (prog-mode . auto-fill-mode)
- :custom
- ;; this does not seem to work ..
- (comment-fill-column 80)
- (comment-auto-fill-only-comments t))
-
-(use-package lispy
- :ensure t
- :config
- (dolist (hook '(emacs-lisp-mode-hook))
- (add-hook hook #'lispy-mode)))
-
-(use-package eldoc
- :ensure nil
- :hook
- ((prog-mode conf-mode) . eldoc-mode)
- :bind ("C-c C-h" . eldoc))
-
-(use-package eglot
- :after (yasnippet)
- :commands (eglot eglot-ensure)
- :ensure t
- :bind (:map eglot-mode-map
- ("C-c C-r" . eglot-rename)
- ("C-c C-a" . eglot-code-actions))
- :hook ((go-mode . eglot-ensure)
- (nix-mode . eglot-ensure)
- (eglot-managed-mode-hook . turn-on-eldoc-mode))
- :init
- (setq-default eglot-workspace-configuration
- ;; List of settings for gopls:
- ;; https://github.com/golang/tools/blob/master/gopls/doc/settings.md
- '((:gopls .
- ((staticcheck . t)
- (matcher . "CaseSensitive")
- (usePlaceholders . t))))))
-
-(use-package sh-script
- :mode ("bashrc" . sh-mode)
- :hook (after-save . executable-make-buffer-file-executable-if-script-p)
- :config
- (setq-default sh-indentation 2
- sh-basic-offset 2))
-
-(use-package python
- :mode (("\\.py$" . python-mode))
- :commands python-mode
- :hook ((python-mode . eldoc-mode))
- :custom (python-indent-offset 2))
-
-(use-package make-mode
- :config
- (add-hook 'makefile-mode-hook (lambda () (setq-local tab-width 2))))
-
-(use-package go-mode
- :after (eglot)
- :ensure t
- :hook ((before-save . gofmt-before-save))
- :bind (:map go-mode-map
- ("C-c C-n" . go-run)
- ("C-c C-c" . go-coverage)
- ("C-c ." . go-test-current-test)
- ("C-c C-f" . go-test-current-file)
- ("C-c C-p" . go-test-current-project))
- :commands (go-run
- go-coverage
- go-test-current-test
- go-test-current-file
- go-test-current-project)
- :custom
- (tab-width 4))
-
-(use-package gotest
- :ensure t
- :after (go-mode)
- :custom
- (go-test-verbose t))
-
-(use-package lisp-mode
- :bind
- (("C-c C-e" . eval-buffer)
- ("C-c C-r" . eval-region)))
-
-(use-package nix-mode
- :ensure t
- :mode "\\.nix\\'"
- :hook ((before-save . nix-format-before-save)))
+(customize-set-variable 'yas-snippet-dirs (list (expand-file-name "etc/snippets" user-emacs-directory)))
+(dolist (hook '(prog-mode-hook conf-mode-hook org-mode-hook))
+ (add-hook hook 'yas-minor-mode))
+
+;; I want comments to be wrapped at column 80
+(customize-set-variable 'comment-fill-column 80)
+(customize-set-variable 'comment-auto-fill-only-comments t)
+
+(dolist (hook '(prog-mode-hook conf-mode-hook))
+ (add-hook hook 'auto-fill-mode))
+
+(defun my/sh-mode-hook ()
+ "Hooks for `sh-mode'."
+ ;; shell scripts are made executable
+ (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
+ (customize-set-variable 'sh-indentation 2)
+ (customize-set-variable 'sh-basic-offset 2))
+
+(add-hook 'sh-mode-hook 'my/sh-mode-hook)
+
+;; set the indent level for python
+(customize-set-variable 'python-indent-offset 2)
+
+(defun my/makefile-mode-hook ()
+ "Hooks for `makefile-mode'."
+ ;; I want small tabs when working in a Makefile
+ (setq tab-width 2))
+
+(add-hook 'makefile-mode-hook 'my/makefile-mode-hook)
+
+(defun my/go-mode-hook ()
+ "Hooks for `go-mode'."
+ (add-hook 'before-save-hook 'gofmt-before-save)
+ (customize-set-variable 'go-test-verbose t)
+ (setq tab-width 4)
+ (define-key go-mode-map (kbd "C-c C-n") 'go-run)
+ (define-key go-mode-map (kbd "C-c C-c") 'go-coverage)
+ (define-key go-mode-map (kbd "C-c .") 'go-test-current-test)
+ (define-key go-mode-map (kbd "C-c C-f") 'go-test-current-file)
+ (define-key go-mode-map (kbd "C-c C-p") 'go-test-current-project))
+
+(add-hook 'go-mode-hook 'my/go-mode-hook)
+
+(defun my/elisp-mode-hook ()
+ "Hooks for `elisp-mode'."
+ (define-key emacs-lisp-mode-map (kbd "C-c C-e") 'eval-buffer)
+ (define-key emacs-lisp-mode-map (kbd "C-c C-r") 'eval-region))
+
+(add-hook 'emacs-lisp-mode-hook 'my/elisp-mode-hook)
+
+(define-key prog-mode-map (kbd "C-c C-h") 'eldoc)
+(dolist (hook '(prog-mode-hook conf-mode-hook))
+ (add-hook hook 'turn-on-eldoc-mode))
+
+;; format nix buffers on save
+(add-hook 'before-save-hook 'nix-format-before-save)
+
+;; List of settings for gopls:
+;; https://github.com/golang/tools/blob/master/gopls/doc/settings.md
+(customize-set-variable 'eglot-workspace-configuration
+ '((:gopls .
+ ((staticcheck . t)
+ (matcher . "CaseSensitive")
+ (usePlaceholders . t)))))
+
+;; ensure we load eglot for some specific modes
+(dolist (hook '(go-mode-hook nix-mode-hook))
+ (add-hook hook 'eglot-ensure))
(provide 'my-prog)
+
;;; my-prog.el ends here