Move editorconfig out of core into tools/editorconfig
This commit is contained in:
parent
99ca62c106
commit
8d936f2d0b
6 changed files with 74 additions and 57 deletions
|
@ -117,62 +117,6 @@ fundamental-mode) for performance sake."
|
||||||
;; Core Plugins
|
;; Core Plugins
|
||||||
;;
|
;;
|
||||||
|
|
||||||
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
|
|
||||||
;; specify their own formatting rules.
|
|
||||||
(def-package! editorconfig
|
|
||||||
:hook (doom-init . editorconfig-mode)
|
|
||||||
:config
|
|
||||||
;; Register missing indent variables
|
|
||||||
(setq editorconfig-indentation-alist
|
|
||||||
(append '((mips-mode mips-tab-width)
|
|
||||||
(haxor-mode haxor-tab-width)
|
|
||||||
(nasm-mode nasm-basic-offset))
|
|
||||||
editorconfig-indentation-alist))
|
|
||||||
|
|
||||||
;; editorconfig cannot procure the correct settings for extension-less files.
|
|
||||||
;; Executable scripts with a shebang line, for example. So why not use Emacs'
|
|
||||||
;; major mode to drop editorconfig a hint? This is accomplished by temporarily
|
|
||||||
;; appending an extension to `buffer-file-name' when we talk to editorconfig.
|
|
||||||
(defvar doom-editorconfig-mode-alist
|
|
||||||
'((sh-mode . "sh")
|
|
||||||
(python-mode . "py")
|
|
||||||
(ruby-mode . "rb")
|
|
||||||
(perl-mode . "pl")
|
|
||||||
(php-mode . "php"))
|
|
||||||
"An alist mapping major modes to extensions. Used by
|
|
||||||
`doom*editorconfig-smart-detection' to give editorconfig filetype hints.")
|
|
||||||
|
|
||||||
(defun doom*editorconfig-smart-detection (orig-fn &rest args)
|
|
||||||
"Retrieve the properties for the current file. If it doesn't have an
|
|
||||||
extension, try to guess one."
|
|
||||||
(let ((buffer-file-name
|
|
||||||
(if (and (not (bound-and-true-p org-src-mode))
|
|
||||||
(file-name-extension buffer-file-name))
|
|
||||||
buffer-file-name
|
|
||||||
(format "%s%s" buffer-file-name
|
|
||||||
(if-let* ((ext (cdr (assq major-mode doom-editorconfig-mode-alist))))
|
|
||||||
(concat "." ext)
|
|
||||||
"")))))
|
|
||||||
(apply orig-fn args)))
|
|
||||||
(advice-add #'editorconfig-call-editorconfig-exec :around #'doom*editorconfig-smart-detection)
|
|
||||||
|
|
||||||
;; Editorconfig makes indentation too rigid in Lisp modes, so tell
|
|
||||||
;; editorconfig to ignore indentation. I prefer dynamic indentation support
|
|
||||||
;; built into Emacs.
|
|
||||||
(dolist (mode '(emacs-lisp-mode lisp-mode))
|
|
||||||
(map-delete editorconfig-indentation-alist mode))
|
|
||||||
|
|
||||||
(defvar whitespace-style)
|
|
||||||
(defun doom|editorconfig-whitespace-mode-maybe (&rest _)
|
|
||||||
"Show whitespace-mode when file uses TABS (ew)."
|
|
||||||
(when indent-tabs-mode
|
|
||||||
(let ((whitespace-style '(face tabs tab-mark trailing-lines tail)))
|
|
||||||
(whitespace-mode +1))))
|
|
||||||
(add-hook 'editorconfig-custom-hooks #'doom|editorconfig-whitespace-mode-maybe))
|
|
||||||
|
|
||||||
(def-package! editorconfig-conf-mode
|
|
||||||
:mode "\\.?editorconfig$")
|
|
||||||
|
|
||||||
;; Auto-close delimiters and blocks as you type
|
;; Auto-close delimiters and blocks as you type
|
||||||
(def-package! smartparens
|
(def-package! smartparens
|
||||||
:config
|
:config
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
(package! ace-window)
|
(package! ace-window)
|
||||||
(package! avy)
|
(package! avy)
|
||||||
(package! command-log-mode)
|
(package! command-log-mode)
|
||||||
(package! editorconfig)
|
|
||||||
(package! expand-region)
|
(package! expand-region)
|
||||||
(package! helpful)
|
(package! helpful)
|
||||||
(package! pcre2el)
|
(package! pcre2el)
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
:tools
|
:tools
|
||||||
dired ; making dired pretty [functional]
|
dired ; making dired pretty [functional]
|
||||||
|
editorconfig ; let someone else argue about tabs vs spaces
|
||||||
ein ; tame Jupyter notebooks with emacs
|
ein ; tame Jupyter notebooks with emacs
|
||||||
electric-indent ; smarter, keyword-based electric-indent
|
electric-indent ; smarter, keyword-based electric-indent
|
||||||
eshell ; a consistent, cross-platform shell (WIP)
|
eshell ; a consistent, cross-platform shell (WIP)
|
||||||
|
|
18
modules/tools/editorconfig/README.org
Normal file
18
modules/tools/editorconfig/README.org
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#+TITLE: :tools editorconfig
|
||||||
|
|
||||||
|
Editorconfig integration for Doom.
|
||||||
|
|
||||||
|
* Table of Contents :TOC:
|
||||||
|
- [[Module Flags][Module Flags]]
|
||||||
|
- [[Prerequisites][Prerequisites]]
|
||||||
|
- [[Configuration][Configuration]]
|
||||||
|
|
||||||
|
* Module Flags
|
||||||
|
This module provides no flags.
|
||||||
|
|
||||||
|
* Prerequisites
|
||||||
|
~editorconfig~ is an optional requirement of this package. The elisp-only
|
||||||
|
implementation may be sufficient, but has fewer features.
|
||||||
|
|
||||||
|
* Configuration
|
||||||
|
|
51
modules/tools/editorconfig/config.el
Normal file
51
modules/tools/editorconfig/config.el
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
;;; tools/editorconfig/config.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; Handles whitespace (tabs/spaces) settings externally. This way projects can
|
||||||
|
;; specify their own formatting rules.
|
||||||
|
(def-package! editorconfig
|
||||||
|
:hook (doom-init . editorconfig-mode)
|
||||||
|
:config
|
||||||
|
;; Register missing indent variables
|
||||||
|
(setq editorconfig-indentation-alist
|
||||||
|
(append '((mips-mode mips-tab-width)
|
||||||
|
(haxor-mode haxor-tab-width)
|
||||||
|
(nasm-mode nasm-basic-offset))
|
||||||
|
editorconfig-indentation-alist))
|
||||||
|
|
||||||
|
;; editorconfig cannot procure the correct settings for extension-less files.
|
||||||
|
;; Executable scripts with a shebang line, for example. So why not use Emacs'
|
||||||
|
;; major mode to drop editorconfig a hint? This is accomplished by temporarily
|
||||||
|
;; appending an extension to `buffer-file-name' when we talk to editorconfig.
|
||||||
|
(defvar doom-editorconfig-mode-alist
|
||||||
|
'((sh-mode . "sh")
|
||||||
|
(python-mode . "py")
|
||||||
|
(ruby-mode . "rb")
|
||||||
|
(perl-mode . "pl")
|
||||||
|
(php-mode . "php"))
|
||||||
|
"An alist mapping major modes to extensions. Used by
|
||||||
|
`doom*editorconfig-smart-detection' to give editorconfig filetype hints.")
|
||||||
|
|
||||||
|
(defun doom*editorconfig-smart-detection (orig-fn &rest args)
|
||||||
|
"Retrieve the properties for the current file. If it doesn't have an
|
||||||
|
extension, try to guess one."
|
||||||
|
(let ((buffer-file-name
|
||||||
|
(if (and (not (bound-and-true-p org-src-mode))
|
||||||
|
(file-name-extension buffer-file-name))
|
||||||
|
buffer-file-name
|
||||||
|
(format "%s%s" buffer-file-name
|
||||||
|
(if-let* ((ext (cdr (assq major-mode doom-editorconfig-mode-alist))))
|
||||||
|
(concat "." ext)
|
||||||
|
"")))))
|
||||||
|
(apply orig-fn args)))
|
||||||
|
(advice-add #'editorconfig-call-editorconfig-exec :around #'doom*editorconfig-smart-detection)
|
||||||
|
|
||||||
|
;; Editorconfig makes indentation too rigid in Lisp modes, so tell
|
||||||
|
;; editorconfig to ignore indentation there. I prefer dynamic indentation
|
||||||
|
;; support built into Emacs.
|
||||||
|
(dolist (mode '(emacs-lisp-mode lisp-mode))
|
||||||
|
(map-delete editorconfig-indentation-alist mode)))
|
||||||
|
|
||||||
|
|
||||||
|
(def-package! editorconfig-conf-mode
|
||||||
|
:mode "\\.?editorconfig$")
|
||||||
|
|
4
modules/tools/editorconfig/packages.el
Normal file
4
modules/tools/editorconfig/packages.el
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
;; -*- no-byte-compile: t; -*-
|
||||||
|
;;; tools/editorconfig/packages.el
|
||||||
|
|
||||||
|
(package! editorconfig)
|
Loading…
Add table
Add a link
Reference in a new issue