Fix issues of Projectile for better project management
Contents
Customize project detection
We may like to control whether a folder should be guessed as a project
root. Sometimes you may see a folder annoyingly being added to project
list, e.g., HOME, Dropbox root. This is mostly likely due to default set
of a long list for projectile-project-root-files
. For better control,
it is good to reset it. You may find the policy in the well-written
Projectile
Docs.
|
|
Exclude user-specified projects/folders/files in Projectile
Excluding projects
To ignore folders that should never be listed as projects, simply set
projectile-ignored-projects
. For example,
|
|
Ignoring folders/files in Projectile search
However, in projectile-find-file
or projectile-find-dir
, it does NOT
obey the rule. For example, it triggers annoying search of your home
folder, which usually takes long time and freezes your Emacs. Moreover,
you may not like certain folders or files to be listed when you use
projectile
to locate files or folders.
Since projetile-indexing-method
is default set to alien
, both
projectile-globally-ignored-directories
and
projectile-globally-ignored-files
will not be used. However, choosing
native
indexing method compromises speed performance considerably,
especially for large projects.
Suppose we prefer alien
for best performance, there is a way to get
both satisfied. The idea is to set projectile-generic-command
that is
used for alien
type indexing. Assume we use ripgrep
(terminal
command rg
), we can add arguments to rg
to ignore folders/files as
you prefer,
-
ignoring folder by option
--glob
with folders read fromprojectile-globally-ignored-directories
that you set; -
ignoring files by option
--ignore-file
. However, this option specifies a file that lists all files to be ignored. The easy way is to create a global file (e.g., in~/.emacs.d/
) and list there all files that you like to put toprojectile-globally-ignored-files
. For example, we set a file name~/.emacs.d/rg_ignore
.
The whole setup as an example is given below:
|
|
Author oracleyue
LastMod 2021-03-05