Port remaining configuration from old emacs module

This commit is contained in:
Wojciech Kozlowski 2022-04-10 19:38:45 +02:00
parent 265ac8aa8a
commit f3c01bb322
3 changed files with 115 additions and 9 deletions

116
config.el
View File

@ -41,6 +41,7 @@
(set-face-attribute 'font-lock-keyword-face nil :weight 'bold) (set-face-attribute 'font-lock-keyword-face nil :weight 'bold)
(set-face-attribute 'font-lock-type-face nil :weight 'bold) (set-face-attribute 'font-lock-type-face nil :weight 'bold)
(set-face-attribute 'show-paren-match nil :background nil)))) (set-face-attribute 'show-paren-match nil :background nil))))
(after! whitespace (set-face-attribute 'whitespace-line nil :background nil))
;; This determines the style of line numbers in effect. If set to `nil', line ;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'. ;; numbers are disabled. For relative line numbers, set this to `relative'.
@ -96,8 +97,16 @@
;; Remove the silly doom newline advice. ;; Remove the silly doom newline advice.
(advice-remove 'newline-and-indent #'+default--newline-indent-and-continue-comments-a) (advice-remove 'newline-and-indent #'+default--newline-indent-and-continue-comments-a)
;; Rainbow delimiters in all prog-mode buffers. ;; I actually like it when Emacs recenters the screen while scrolling. This may
(add-hook! prog-mode #'rainbow-delimiters-mode-enable) ;; be an issue in large files. When that becomes an issue add an exception here.
(setq scroll-conservatively 0)
;; Add some extra whitespace highlights to doom's opinion.
(advice-add 'doom-highlight-non-default-indentation-h
:after
(lambda () (when (bound-and-true-p whitespace-mode)
(appendq! whitespace-style '(trailing lines-tail empty))
(whitespace-mode +1))))
;; ----------------------------------------------------------------------------- ;; -----------------------------------------------------------------------------
;; Additional coniguration for doom modules. ;; Additional coniguration for doom modules.
@ -112,6 +121,17 @@
;; Python virtualenv configuration. ;; Python virtualenv configuration.
(after! lsp-pyright (setq lsp-pyright-venv-path (concat (getenv "HOME") "/.virtualenvs"))) (after! lsp-pyright (setq lsp-pyright-venv-path (concat (getenv "HOME") "/.virtualenvs")))
;; Rainbow delimiters in all prog-mode buffers.
(add-hook! prog-mode #'rainbow-delimiters-mode-enable)
;; Make TRAMP easier to use for sudo on remote hosts.
(after! tramp
;; This line proxies all sudo connections via an ssh connection to the provided hostname.
(add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
;; This rule is an exception to the above so that local sudo does not proxy via ssh. This has to
;; be added last so that it is the first element of the list.
(add-to-list 'tramp-default-proxies-alist '("localhost" "\\`root\\'" nil)))
;; Extra VTerm configuration. ;; Extra VTerm configuration.
(after! vterm (after! vterm
(setq vterm-shell "/bin/zsh" (setq vterm-shell "/bin/zsh"
@ -129,21 +149,96 @@
;; Configuration for additional packages on top of doom and its modules. ;; Configuration for additional packages on top of doom and its modules.
;; ----------------------------------------------------------------------------- ;; -----------------------------------------------------------------------------
;; Faster navigation.
(use-package! ace-jump-mode
:bind (("C-c SPC" . ace-jump-mode)))
;; A nicer interface for ripgrep. Note that since doom required rg we don't
;; consider the case if it's not installed.
(use-package! deadgrep
:init
(setq deadgrep-project-root-function
(lambda ()
(read-directory-name "Base directory: " nil default-directory t)))
:bind
(("C-x C-g" . deadgrep))
(:map deadgrep-mode-map
("C-o" . deadgrep-open-result-other-window)
("<RET>" . deadgrep-visit-result-other-window))
:config
(defun deadgrep-open-result-other-window ()
"Open the result in other window without changing to it."
(interactive)
(save-selected-window (deadgrep-visit-result-other-window))))
;; Duplicate things.
(use-package! duplicate-thing
:bind (("M-C" . duplicate-thing)))
;; It's the 21st century, a file explorer should be pretty.
(use-package! treemacs-icons-dired
:after dired
:hook (dired-mode . treemacs-icons-dired-mode))
;; Kill line when calling kill-region without a selected region. ;; Kill line when calling kill-region without a selected region.
(use-package! whole-line-or-region (use-package! whole-line-or-region
:config :config
(define-key whole-line-or-region-local-mode-map [remap comment-dwim] nil) (define-key whole-line-or-region-local-mode-map [remap comment-dwim] nil)
(whole-line-or-region-global-mode t)) (whole-line-or-region-global-mode t))
;; Duplicate things. ;; -----------------------------------------------------------------------------
(use-package! duplicate-thing ;; Global configuration.
:bind (("M-C" . duplicate-thing))) ;; -----------------------------------------------------------------------------
(setq-default
;; Standard fill-column width.
fill-column 100
;; Do not use tab characters for indentation.
indent-tabs-mode nil
;; Kill whole line when point at beginning of line.
kill-whole-line t
;; Always indent. Why would I ever want to insert a tab?
tab-always-indent t
;; Default indentation size - applies even when indent-tabs-mode is nil.
tab-width 8
;; Highlight lines that are too long in whitespace mode.
whitespace-line-column fill-column)
;; CamelCase as separate words.
(global-subword-mode t)
;; Doom emacs recommends `visual-line-mode' as it claims wrapping is expensive.
(global-visual-line-mode t)
;; But "C-e" behaves differently in `visual-line-mode' than when they are
;; wrapped. It goes to the end of the visual line, not the logical line. This
;; can be fixed by defining the following aliases.
(defalias #'end-of-visual-line #'end-of-line)
(defalias #'beginning-of-visual-line #'beginning-of-line)
(defun indent-region-or-buffer ()
"Indent a region if selected, otherwise the whole buffer."
(interactive)
(if (region-active-p)
(indent-region (region-beginning) (region-end))
(indent-region (point-min) (point-max))))
(defun unfill-paragraph (&optional region)
"Takes a multi-line paragraph and makes it into a single line of text."
(interactive (progn (barf-if-buffer-read-only) '(t)))
(let ((fill-column (point-max))
;; This would override `fill-column' if it's an integer.
(emacs-lisp-docstring-fill-column t))
(fill-paragraph nil region)))
;; ----------------------------------------------------------------------------- ;; -----------------------------------------------------------------------------
;; Keybindings. ;; Global keybindings.
;; ----------------------------------------------------------------------------- ;; -----------------------------------------------------------------------------
(map! (map!
;; For functions defined above.
"M-Q" #'unfill-paragraph
"C-M-\\" #'indent-region-or-buffer
;; Create binding before dired is loaded. ;; Create binding before dired is loaded.
"C-x C-j" #'dired-jump "C-x C-j" #'dired-jump
;; More convenient window switching. ;; More convenient window switching.
@ -152,4 +247,11 @@
;; Kill current buffer without prompting. ;; Kill current buffer without prompting.
:desc "kill-buffer" "C-x k" (lambda () :desc "kill-buffer" "C-x k" (lambda ()
(interactive) (interactive)
(let (kill-buffer-query-functions) (kill-buffer)))) (let (kill-buffer-query-functions) (kill-buffer)))
;; Scroll up/down, but keep point in place.
"C-<" (lambda()
(interactive)
(let ((scroll-preserve-screen-position nil)) (scroll-down 1)))
"C->" (lambda()
(interactive)
(let ((scroll-preserve-screen-position nil)) (scroll-up 1))))

View File

@ -68,7 +68,7 @@
:emacs :emacs
dired ; making dired pretty [functional] dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent electric ; smarter, keyword-based electric-indent
;;ibuffer ; interactive buffer management (ibuffer +icons) ; interactive buffer management
(undo +tree) ; persistent, smarter undo for your inevitable mistakes (undo +tree) ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree vc ; version-control and Emacs, sitting in a tree

View File

@ -7,8 +7,12 @@
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror: ;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;(package! some-package) ;;(package! some-package)
(package! ace-jump-mode
:recipe (:local-repo "repos/ace-jump-mode"))
(package! deadgrep)
(package! duplicate-thing) (package! duplicate-thing)
(package! treemacs-icons-dired)
(package! whole-line-or-region) (package! whole-line-or-region)
;; To install a package directly from a remote git repo, you must specify a ;; To install a package directly from a remote git repo, you must specify a