diff --git a/core/autoload/text.el b/core/autoload/text.el index ee1108101..ec23b2706 100644 --- a/core/autoload/text.el +++ b/core/autoload/text.el @@ -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 diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 0fa7b7b48..d9b2c0b7d 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -804,15 +804,16 @@ ;;; 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)) ;;