76 lines
2.9 KiB
EmacsLisp
Executable File
76 lines
2.9 KiB
EmacsLisp
Executable File
;;; syd-projects.el -*- lexical-binding: t; -*-
|
|
|
|
(require 'syd-constants)
|
|
|
|
(with-eval-after-load 'project ; Built-in
|
|
;; Stay out of my config directory!
|
|
(setq project-list-file (file-name-concat syd-cache-dir "known-projects"))
|
|
;; For each command in `project-switch-commands' will assign it the key found
|
|
;; in `project-prefix-map'. We emulate that behaviour but for our own
|
|
;; `syd-leader-project-map'.
|
|
(let* ((project-key
|
|
(lambda (f)
|
|
(key-description
|
|
(where-is-internal
|
|
f
|
|
;; If the keymap is not wrapped in a list,
|
|
;; `where-is-internal' will also search the
|
|
;; global ;; keymaps
|
|
(list syd-leader-project-map)
|
|
;; First result only.
|
|
t))))
|
|
(switch-cmd (lambda (command name &optional key)
|
|
(append (list command name)
|
|
(list (or key (funcall project-key command)))))))
|
|
(add-to-list 'project-switch-commands
|
|
(funcall switch-cmd #'syd-project-root-find-file "Browse"))))
|
|
|
|
;; Projection provides a Projectile-like project management library atop
|
|
;; Emacs built-in project.el. It's more lightweight, while still featureful.
|
|
(use-package projection
|
|
;; Enable the `projection-hook' feature.
|
|
:hook (after-init . global-projection-hook-mode)
|
|
;; Require projections immediately after project.el.
|
|
:config
|
|
(with-eval-after-load 'project
|
|
(require 'projection)))
|
|
|
|
;; Allow interactively selecting available compilation targets from the
|
|
;; current project type.
|
|
(use-package projection-multi
|
|
:after projection)
|
|
|
|
;; Embark integration for projection-multi.
|
|
(use-package projection-multi-embark
|
|
:after (embark projection-multi)
|
|
;; Add the projection set-command bindings to
|
|
;; `compile-multi-embark-command-map'.
|
|
:config (projection-multi-embark-setup-command-map))
|
|
|
|
(use-package skeletor
|
|
:commands (skeletor-create-project-at skeletor-create-project)
|
|
:custom ((skeletor-project-directory (expand-file-name "~/src"))
|
|
(skeletor-completing-read-function #'completing-read))
|
|
:general (:keymaps 'syd-leader-project-map
|
|
"n" #'skeletor-create-project
|
|
"N" #'skeletor-create-project-at)
|
|
:config
|
|
(skeletor-define-template "clj-nix"
|
|
:substitutions
|
|
'(("__PROJECT-OWNER__" . (lambda ()
|
|
(read-no-blanks-input "Project owner: "))))
|
|
:before-git
|
|
(lambda (dir)
|
|
;; Use underscores instead of hyphens in clj file names.
|
|
(let ((default-directory (file-name-concat dir "src")))
|
|
(dolist (f (directory-files "." nil "-" t))
|
|
(rename-file
|
|
f
|
|
(string-replace "-" "_" f))))
|
|
;; REVIEW: Is it safe to make this be async? We require that the command
|
|
;; has finished before Git initialises.
|
|
(skeletor-shell-command "nix run github:jlesquembre/clj-nix#deps-lock"
|
|
dir))))
|
|
|
|
(provide 'syd-projects)
|