Skip to content

Commit

Permalink
Make .projectile customizable
Browse files Browse the repository at this point in the history
Introduces a variable, `projectile-dirconfig-file` specifying the name of the
file used by Projectile to explicitly mark project roots. The default is
“.projectile”.

One use case for this is if you group project-local configs in an XDG-style
location. E.g., setting it to “.config/projectile”.
  • Loading branch information
sellout committed Nov 12, 2022
1 parent 433d10d commit 28964f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [#1591](https://github.com/bbatsov/projectile/issues/1591): Add `project.el` integration that will make Projectile the default provider for project lookup.
* Add new command `projectile-find-references` (bound to `C-c C-p ?` and `C-c C-p s x`).
* [#1737](https://github.com/bbatsov/projectile/pull/1737): Add helpers for `dir-local-variables` for 3rd party use. Functions `projectile-add-dir-local-variable` and `projectile-delete-dir-local-variable` wrap their built-in counterparts. They always use `.dir-locals.el` from the root of the current Projectile project.
* Add a new defcustom (`projectile-dirconfig-file`) controlling the name of the file used as Projectile’s root marker and configuration file.

### Bug fixed

Expand Down
16 changes: 12 additions & 4 deletions projectile.el
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,17 @@ algorithm."
:group 'projectile
:type '(repeat function))

(defcustom projectile-dirconfig-file
".projectile"
"The file which serves both as a project marker and configuration file.
This should _not_ be set via .dir-locals.el."
:group 'projectile
:type 'file
:package-version '(projectile . "2.7.0"))

(defcustom projectile-dirconfig-comment-prefix
nil
"Projectile config file (.projectile) comment start marker.
"`projectile-dirconfig-file` comment start marker.
If specified, starting a line in a project's .projectile file with this
character marks that line as a comment instead of a pattern.
Similar to '#' in .gitignore files."
Expand Down Expand Up @@ -1200,8 +1208,8 @@ Return the first (topmost) matched directory or nil if not found."
(or list projectile-project-root-files)))))

(defun projectile-root-marked (dir)
"Identify a project root in DIR by search for a .projectile file."
(projectile-root-bottom-up dir '(".projectile")))
"Identify a project root in DIR by search for `projectile-dirconfig-file`."
(projectile-root-bottom-up dir (list projectile-dirconfig-file)))

(defun projectile-root-bottom-up (dir &optional list)
"Identify a project root in DIR by bottom-up search for files in LIST.
Expand Down Expand Up @@ -1950,7 +1958,7 @@ Unignored files/directories are not included."

(defun projectile-dirconfig-file ()
"Return the absolute path to the project's dirconfig file."
(expand-file-name ".projectile" (projectile-project-root)))
(expand-file-name projectile-dirconfig-file (projectile-project-root)))

(defun projectile-parse-dirconfig-file ()
"Parse project ignore file and return directories to ignore and keep.
Expand Down

0 comments on commit 28964f2

Please sign in to comment.