Files
creature/lisp/init-editorconfig.el
T
zedhugh b5d9ce18a7 use "creature/pkg-active" manage packages manually
- replace "add-pkg-in-pkg-dir" (recursive load-path scanning) with a
  central "creature/pkgs" registry that handles load path, autoloads,
  info dirs and dependencies
- adapt all init-*.el files to the new activation function
- add a top-level Makefile to byte-compile site-lisp packages
- remove unused "emacs-kv" and "emacs-db" submodules
2026-09-14 15:02:43 +08:00

41 lines
1.5 KiB
EmacsLisp

;; -*- coding: utf-8; lexical-binding: t; -*-
(unless (locate-library "editorconfig")
(require 'init-package)
(creature/pkg-active 'editorconfig)
(autoload 'editorconfig-mode "editorconfig" "" t)
(autoload 'editorconfig-conf-mode "editorconfig-conf-mode" "" t)
(add-to-list 'auto-mode-alist
'("\\.editorconfig\\'" . editorconfig-conf-mode)))
(defun creature/editorconfig-setup ()
(editorconfig-mode 1)
(unless (fboundp 'editorconfig-mode-apply)
(require 'editorconfig-tools))
;; 修复通过打开文件启动该插件时打开的文件缩进配置不对
(editorconfig-mode-apply)
(remove-hook 'find-file-hook #'creature/editorconfig-setup)
;; 防止多次执行时因为定时器被清除而报错
(when (and (boundp 'creature/editorconfig-timer)
(timerp creature/editorconfig-timer))
(cancel-timer creature/editorconfig-timer)
(makunbound 'creature/editorconfig-timer)))
(setq creature/editorconfig-timer
(run-with-idle-timer 5 nil #'creature/editorconfig-setup))
(add-hook 'find-file-hook #'creature/editorconfig-setup)
(with-eval-after-load 'editorconfig
(add-to-list 'editorconfig-indentation-alist '(js-ts-mode js-indent-level))
(add-to-list 'editorconfig-indentation-alist '(plantuml-mode plantuml-indent-level))
(add-to-list 'editorconfig-indentation-alist '(prisma-ts-mode prisma-ts-mode-indent-level))
(add-to-list 'editorconfig-indentation-alist '(graphviz-dot-mode graphviz-dot-indent-width)))
(provide 'init-editorconfig)