Add set-indent-width & toggle-indent-style commands
And SPC t I keybind Also sorts keybinds under the SPC t prefix
This commit is contained in:
parent
d2b694ed53
commit
c627972d20
2 changed files with 36 additions and 7 deletions
|
@ -162,6 +162,34 @@ Respects `require-final-newline'."
|
|||
(interactive)
|
||||
(set-buffer-file-coding-system 'undecided-dos nil))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/toggle-indent-style ()
|
||||
"Switch between tabs and spaces indentation style in the current buffer."
|
||||
(interactive)
|
||||
(setq indent-tabs-mode (not indent-tabs-mode))
|
||||
(message "Indent style changed to %s" (if indent-tabs-mode "tabs" "spaces")))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/set-indent-width (width)
|
||||
"Change the indentation width of the current buffer."
|
||||
(interactive
|
||||
(list (if (integerp current-prefix-arg)
|
||||
current-prefix-arg
|
||||
(read-number "New indent size: "))))
|
||||
(setq tab-width width
|
||||
standard-indent width)
|
||||
(when (boundp 'evil-shift-width)
|
||||
(setq evil-shift-width width))
|
||||
(cond ((require 'editorconfig nil t)
|
||||
(dolist (var (cdr (assq major-mode editorconfig-indentation-alist)))
|
||||
(doom-log "Updated %s = %d" var width)
|
||||
(set var width)))
|
||||
((require 'dtrt-indent nil t)
|
||||
(when-let (var (nth 2 (assq major-mode dtrt-indent-hook-mapping-list)))
|
||||
(doom-log "Updated %s = %d" var width)
|
||||
(set var width))))
|
||||
(message "Changed indentation to %d" width))
|
||||
|
||||
|
||||
;;
|
||||
;; Hooks
|
||||
|
|
|
@ -804,15 +804,16 @@
|
|||
|
||||
;;; <leader> t --- toggle
|
||||
(:prefix-map ("t" . "toggle")
|
||||
:desc "Flyspell" "s" #'flyspell-mode
|
||||
:desc "Flycheck" "f" #'flycheck-mode
|
||||
:desc "Line numbers" "l" #'doom/toggle-line-numbers
|
||||
:desc "Frame fullscreen" "F" #'toggle-frame-fullscreen
|
||||
:desc "Indent guides" "i" #'highlight-indent-guides-mode
|
||||
:desc "Impatient mode" "h" #'+impatient-mode/toggle
|
||||
:desc "Big mode" "b" #'doom-big-font-mode
|
||||
:desc "Flycheck" "f" #'flycheck-mode
|
||||
:desc "Frame fullscreen" "F" #'toggle-frame-fullscreen
|
||||
:desc "Evil goggles" "g" #'evil-goggles-mode
|
||||
:desc "org-tree-slide mode" "p" #'+org-present/start))
|
||||
:desc "Impatient mode" "h" #'+impatient-mode/toggle
|
||||
:desc "Indent guides" "i" #'highlight-indent-guides-mode
|
||||
:desc "Indent style" "I" #'doom/toggle-indent-style
|
||||
:desc "Line numbers" "l" #'doom/toggle-line-numbers
|
||||
:desc "org-tree-slide mode" "p" #'+org-present/start
|
||||
:desc "Flyspell" "s" #'flyspell-mode))
|
||||
|
||||
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue