有人遇到过这个问题吗,开启lsp-mode后git-timemachine显示的提交信息会被lsp的错误信息覆盖,主要是在Go项目里,使用git-timemachine后总是会提示
LSP :: no token.File for file:xxxxxxxx
另外,lsp有什么办法自动关闭长时间未使用的lsp进程吗?我两天前打开的某个项目,这两天都没再开过,今天一看该项目的lsp进程一直都在。。。
有人遇到过这个问题吗,开启lsp-mode后git-timemachine显示的提交信息会被lsp的错误信息覆盖,主要是在Go项目里,使用git-timemachine后总是会提示
LSP :: no token.File for file:xxxxxxxx
另外,lsp有什么办法自动关闭长时间未使用的lsp进程吗?我两天前打开的某个项目,这两天都没再开过,今天一看该项目的lsp进程一直都在。。。
项目的文件全部关了server才会关,接下来不碰的项目可以手动projectile-kill-buffers
一下
换个角度,在git-machine里关闭lsp-mode是不是就可以了呢?
最终还是翻源码找到了解决办法
(defun maple/lsp--init-if-visible(func &rest args)
(unless (bound-and-true-p git-timemachine-mode) (apply func args)))
(advice-add 'lsp--init-if-visible :around 'maple/lsp--init-if-visible)
我的比较简单粗暴
(add-hook 'prog-mode-hook
(lambda ()
(unless (string-prefix-p "timemachine:" (buffer-name)))
(lsp-deferred)))
你这样只会在第一次打开的时候检查,如果在已经打开的buffer里使用git-timemachine就会失效的
你确定试过了吗?
大半夜看到你的回复,我还以为中午的时候测错了,又爬起来测了一遍,确实是不成功的,随便打开一个golang项目里的文件,使用git-timemachine,会提示
LSP :: successfully parsed but no token.File for file: xxxxxxx
我这里是可以的,用的是prog-mode-hook。在git-timemachine 的buffer里不会启动 lsp-mode.