重新生成 项目 cache

  • 调用函数 M-x projectile-invalidate-cache

忽略文件问题

https://docs.projectile.mx/projectile/2.2/projects.html#ignoring-files

  • 使用 .projectile 配置
  • 或者 设置变量

    • projectile-globally-ignored-files
    • projectile-globally-ignored-directiories

.projectile 文件配置

只包含的文件夹 "+"

  • 注意

    • "+" 后面只能跟目录
    • 对文件使用无效
1
2
+/src/foo
+/tests/foo

忽略的文件 或者 文件夹 "-"

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 文件夹
-/log
-/tmp
-/vendor
-/public/uploads


# 文件
-tmp
-*.rb
-*.yml
-models
  • 注意

    • 不指定路径,就是通配

      • 即,哪个路径下都匹配

对忽略配置的例外情况 "!"

  • 添加,不可被忽略的文件或文件夹

    1
    2
    
      !/src/foo
      !*.yml
  • 注意

    • 如果使用了 "+"

      • "!": 设置无效

        • 必须是,"+" 包含的文件夹中的内容,才可以

注意

  • 谨慎使用通配符

    • eg:

      1
      2
      3
      4
      
      -/gradle
      -/.gradle
      
      !*.gradle
      • 因为 "*.gradle" 也包含 .gradle

        • 导致上面的 "-/.gradle" 无效
  • 配置无效时

    • 可以检查是不是,滥用通配符导致的

我的配置

  • java

    • 对于 gradle 项目

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      
      -*.java~
      -/.idea
      -/.meghanada
      -/.settings
      -/bin
      -/build
      -/gradle
      
      -.classpath
      -.project
      -*~
      -gradlew*
      
      
      !build.gradle
      !settings.gradle
  • python

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    
      -/build
      -/dist
      -/.git
      -/.idea
      -/temp
      -/.venv
    
      -*~
      -__pycache__
      -.pytest_cache
      -.projectile
      -*#
    • 这里,除掉首行, "#" 不表示注释

      • 因此,不需要对 "#" 转义

basic command

commandmeaning
s-p ffind file
s-p pswitch between projects
s-p s ggrep to the whole project
s-p rreplace a string in all the project
s-p muse this command like a prefix
to execute all other command
s-p Tlist Test files
s-p dlist directories in the project
s-p llist all files in a directory
(not all necessary)
s-p bswitch buffers of this project
s-p aswitch between "files" with
same name but different extensions
s-p Rgenerate TAGS
s-p jfind project's TAGS
s-p kkill all buffers of the same project
s-p Ddired at project root
s-p C-hhelp of projectile

支持的 project 类型

  1. 存储在变量 projectile-project-types
  2. projectile 会缓存项目类型

    • 如果想要让 projectile 发现 project-type 发生改变,需要清除 cache
    • M-x projectile-invalidate-cache