add package to load-path only when needed

This commit is contained in:
zedhugh committed 2024-09-15 03:10:48 +08:00
1 parent a4f03a72d0
commit 5dea4193e2
22 files changed
+167 -38

No files matched your search

+6
View File
@@ -1,5 +1,11 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "ace-window")
(add-pkg-in-pkg-dir "posframe")
(add-pkg-in-pkg-dir "avy")
(require 'lazy-load)
+3
View File
@@ -1,5 +1,8 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "awesome-pair")
(require 'lazy-load)
+4
View File
@@ -1,5 +1,9 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(unless (locate-library "editorconfig")
(add-pkg-in-pkg-dir "editorconfig-emacs"))
(autoload 'editorconfig-mode "editorconfig" "" t)
(defun creature/editorconfig-setup ()
+3
View File
@@ -1,5 +1,8 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "emmet-mode")
(autoload 'emmet-mode "emmet-mode" "" t)
(with-eval-after-load 'emmet-mode
+9
View File
@@ -1,5 +1,14 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "vimrc-mode")
(add-pkg-in-pkg-dir "yaml-mode")
(add-pkg-in-pkg-dir "lua-mode")
(add-pkg-in-pkg-dir "nginx-mode")
(add-pkg-in-pkg-dir "pdf-tools")
(add-pkg-in-pkg-dir "tablist")
(add-pkg-in-pkg-dir "saveplace-pdf-view")
(add-pkg-in-pkg-dir "graphviz-dot-mode")
(autoload 'vimrc-mode "vimrc-mode" "" t)
(add-to-list 'auto-mode-alist '("\\.vim\\(rc\\)?\\'" . vimrc-mode))
+4
View File
@@ -1,5 +1,9 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "eslint-disable-rule")
(add-pkg-in-pkg-dir "emacs-flymake-eslint")
(defun creature/flymake-show-diagnostics-buffer-and-jump ()
(interactive)
(flymake-show-diagnostics-buffer)
+6
View File
@@ -1,5 +1,11 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "magit")
(add-pkg-in-pkg-dir "dash")
(add-pkg-in-pkg-dir "git-modes")
(add-pkg-in-pkg-dir "with-editor")
(require 'lazy-load)
(lazy-load-global-keys
+9
View File
@@ -1,5 +1,14 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "expand-region")
(add-pkg-in-pkg-dir "rg")
(add-pkg-in-pkg-dir "Emacs-wgrep")
(add-pkg-in-pkg-dir "avy")
(add-pkg-in-pkg-dir "mwim")
(add-pkg-in-pkg-dir "symbol-overlay")
(defconst creature/prefix-key "M-m"
"Prefix key for custom keybindings.")
+3
View File
@@ -1,5 +1,8 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "markdown-mode")
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist
+3
View File
@@ -1,5 +1,8 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "emms")
(autoload 'emms-all "emms-setup" "" t)
(autoload 'emms-default-players "" t)
+8
View File
@@ -1,5 +1,13 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "org-pomodoro")
(add-pkg-in-pkg-dir "alert")
(add-pkg-in-pkg-dir "gntp")
(add-pkg-in-pkg-dir "ox-hugo")
(add-pkg-in-pkg-dir "tomelr")
;; customize mode for src lang
(defconst creature/org-src-lang-modes
(if (bound-and-true-p creature/treesit-available)
+57
View File
@@ -0,0 +1,57 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(defconst creature/pkg-dir
(expand-file-name
"../site-lisp"
(file-name-directory(or load-file-name buffer-file-name)))
"Package directory.")
(require 'cl-lib)
(require 'subr-x)
(defun add-dir-and-subdirs-to-load-path (dir)
"Add directory and its subdirectoris to `load-path'.
Detect whether there are any loadable module in DIR, if so, add DIR to `load-path'.
Do this recursively for subdirectories of DIR."
(unless (file-directory-p dir)
(error "%s is not a directory" dir))
(let ((subdirs nil)
(files nil)
(temp-filepath nil)
;; (loadable-suffixes (get-load-suffixes))
(load-extension (mapcar (lambda (str) (string-remove-prefix "." str)) load-suffixes))
(exclude-dirs '("." ".."
"dist" "node_modules" "__pycache__" "test"
"RCS" "CVS" "rcs" "cvs" ".git" ".github")))
(dolist (filename (directory-files dir))
(setq temp-filepath (file-name-concat dir filename))
(if (file-directory-p temp-filepath)
(unless (member filename exclude-dirs)
(add-to-list 'subdirs temp-filepath t))
(when (file-regular-p temp-filepath)
(add-to-list 'files temp-filepath t))))
(when (cl-some (lambda (file)
(member (file-name-extension file) load-extension))
files)
(add-to-list 'load-path dir t))
(mapc #'add-dir-and-subdirs-to-load-path subdirs)))
(defun add-pkg-in-pkg-dir (pkg)
"Add PKG located in `creature/pkg-dir' to `load-path'."
(add-dir-and-subdirs-to-load-path (expand-file-name pkg creature/pkg-dir)))
(add-to-list 'load-path creature/pkg-dir t)
;; add basic packages
(add-pkg-in-pkg-dir "lazy-load")
;; builtin maybe exist
;; "compat" "transient"
(dolist (pkg '("compat" "transient"))
(unless (locate-library pkg)
(add-pkg-in-pkg-dir)))
(provide 'init-package)
+4
View File
@@ -1,5 +1,9 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "plantuml-mode")
(add-pkg-in-pkg-dir "dash")
(autoload 'plantuml-mode "plantuml-mode" "" t)
(add-to-list 'auto-mode-alist '("\\.\\(plantuml\\|pum\\|plu\\)\\'" . plantuml-mode))
+9
View File
@@ -1,5 +1,14 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "prettier")
(add-pkg-in-pkg-dir "iter2")
(add-pkg-in-pkg-dir "nvm")
(add-pkg-in-pkg-dir "s")
(add-pkg-in-pkg-dir "dash")
(add-pkg-in-pkg-dir "f")
(require 'init-editorconfig)
(autoload 'prettier-mode "prettier" "" t)
(defvar-local creature/formatter nil
+5
View File
@@ -1,5 +1,10 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "emacs-rime")
(add-pkg-in-pkg-dir "dash")
(add-pkg-in-pkg-dir "posframe")
(require 'lazy-load)
(require 'rime)
+4
View File
@@ -1,5 +1,9 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "sdcv")
(add-pkg-in-pkg-dir "posframe")
(require 'lazy-load)
+4
View File
@@ -1,5 +1,9 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "rainbow-delimiters")
(add-pkg-in-pkg-dir "rainbow-identifiers")
;; Pulse
(defvar creature/pulse-enable t
"Whether enable pulse for scroll and switch window.")
+14
View File
@@ -1,5 +1,19 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "marginalia")
(add-pkg-in-pkg-dir "vertico")
(add-pkg-in-pkg-dir "corfu")
(add-pkg-in-pkg-dir "orderless")
(add-pkg-in-pkg-dir "corfu-doc")
(add-pkg-in-pkg-dir "cape")
(add-pkg-in-pkg-dir "consult")
(add-pkg-in-pkg-dir "emacs-corfu-terminal")
(add-pkg-in-pkg-dir "emacs-popon")
(add-pkg-in-pkg-dir "emacs-corfu-doc-terminal")
(add-pkg-in-pkg-dir "embark")
(require 'marginalia)
(marginalia-mode 1)
+4
View File
@@ -1,5 +1,9 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(unless (locate-library "which-key")
(add-pkg-in-pkg-dir "emacs-which-key"))
(require 'init-keybindings)
(require 'which-key)
+5
View File
@@ -1,5 +1,10 @@
;; -*- coding: utf-8; lexical-binding: t; -*-
(require 'init-package)
(add-pkg-in-pkg-dir "yasnippet")
(add-pkg-in-pkg-dir "yasnippet-snippets")
(add-pkg-in-pkg-dir "auto-yasnippet")
(require 'lazy-load)
(require 'yasnippet)
(require 'yasnippet-snippets)