如何快速跳转vue项目中include的文件

相对路径跳,而不是项目内跳,问题简单了很多。

搜了下 Emacs 其实对这类问题有个解决方案 find-file-at-point。

现在找文件一般就是用 project-find-file (28 内置)或 counsel-git 来找了,也很快。

2 个赞

内置的遇到node_module目录就会卡死,哈哈哈哈

M-x find-file-in-project-at-point

如果是相对路径,先试着直接打开文件,路径可以含有环境变量. 找不到文件就在project root中搜索文件.有没有文件拓展名都没有关系. 搜索使用了命令行find, 默认使用路径匹配(可改为文件名匹配).

例如 "./components/HelloWorld.vue"的搜索逻辑是搜索所有路径中包含有 “components /HelloWorld.vue"的文件.

如果选中部分文本,使用选中的文本搜索.

该插件使用emacs内置api, completing-read,所以可以和helm,ivy, consult等插件结合使用.

目前这种相对路径的 embark 这种方式基本满足我的需求了,其他需要搜索project内的文件,我直接用 project-find-file了,emacs内置的 project.el,不用安装第三方插件,可以集成 fd

使用 project.el + fd, 然后 exclude掉 node_modules , .git 等目录,速度贼快

下期短视频可以展示下如何集成 project.el + fd :grinning_face_with_smiling_eyes:

后续会集成到我的21天视频中

1 个赞

我现在 snails 就是这样用的, fd速度太快了。

我按你的方法配置 project.el + fd 确实快,在 Windows 系统也能用,不用依赖 find。Windows 下的 find 会和系统的 find.exe 冲突。

不过 project.el 如果用在我的个人 Emacs 配置项目下执行 C-x p f 就会卡死,因为我配置是 git submodule,总共有90个子模块。大佬知道什么原因吗? 最后会抱着个错误:

process-file: Variable binding depth exceeds max-specpdl-size

macOS Emacs 29
这是我的个人配置:GitHub - Eason0210/emacs.d: I have been moved to new configuration: https://github.com/Eason0210/.emacs.d

PS:给 Emacs 报了这个BUG: bug#55396: 29.0.50; project-find-file don't work on a project with many

这个我记得和 tramp 一起用有问题,抄完我又删掉了

我上面说的问题在 emacs -q 下都能重现,应该是 project.el 的bug。这个问题只是出现在这种子模块较多的项目。

切回 projectile,在同样的项目下执行 projectile-find-file ,只要等待1s钟左右,就可以正常打开。

这里有说怎么定位 max-specpdl-size 的问题,可以试试

我很少用 tramp,爱莫能助了。。。

谢谢。暂时切到 straight.el 了,没这个问题。Borg 把仓库搞的太大,造成 magit 启动也慢,在 Windows 下更是没法用。。

PS: straight.el 也有坑,看来不同的包管理方案都各有优缺。我还是用回 Borg 吧

project.el 的project-find-file搭配Minibuffer History, 可以直接跳转的啊, project-find-file记录了当前cursor的文件名

看了 LSP 的协议 Specification

不知道这个是不是用于处理这种情况的。

这个问题终于解决了。原来是使用 Borg 在安装 Corfu 插件时在 .gitsubmodules 里面加了两个load-path 引起的。

[submodule "corfu"]
	load-path = .
	load-path = extensions
	no-byte-compile = extensions/corfu-history.el
	no-byte-compile = extensions/corfu-indexed.el
	no-byte-compile = extensions/corfu-quick.el
	path = lib/corfu
	url = [email protected]:minad/corfu.git
	branch = main

目前的临时解决方案:
设置 project-vc-merge-submodules 为 nil,不过这样就不会去查找子模块了。

好像是 tramp 不会处理颜色, 在 fd 的 output 中关掉颜色就行了

-c never

这个 bug 已经在 Emacs 29 中修复,Borg 用户建议更新到最新的 Emacs 29.
这个bug 是因为 project--git-submodules函数错误地将 .gitsubmodule 下的 load-path 当成了 path 来解析。不需要加 load-path 安装插件的 Borg 用户不受影响。