lsp-mode新接口lsp.el

我认为 lsp-mode 的问题不在于是否“开箱即用”,再复杂的配置,抄一份不就得了,天下配置一大抄不是吗。

真正需要改进的是可靠度,不要在使用过程中掉链子,以及可读性更高的错误提示。

还有测试的方便性,不仅有助于开发者编写测试用例,更有利于用户报错。比如使用 jedi 的时侯,普通用户很容易用一段代码复现错误。

1 个赞

哦?能说得具体点么?禁用 font-lock LSP 的性能就提高了?

It seems an issue of ccls, while not lsp?

截图是禁用 font-lock 前(右)后(左)对比?

If overlays have good performance ((setq ccls-sem-highlight-method 'overlay)) i’d be excited to try disabling font-lock.

Another area worth exploring is how to improve when/how to request textDocument/codeLens. I may take some inspiration from flymake.

$ccls/publishSemanticHighlight transfers less data compared with $cquery/publishSemanticHighlighting:

{"jsonrpc":"2.0","method":"$ccls/publishSemanticHighlight","params":{"uri":"file:///home/ray/musl/src/string/bcmp.c",
"symbols":[{"id":118,"parentKind":0,"kind":12,"storage":0,"ranges":[{"L":66,"R":70}],"lsRanges":[]},
{"id":18602,"parentKind":12,"kind":253,"storage":0,"ranges":[{"L":99,"R":101},{"L":134,"R":136}],"lsRanges":[]},
{"id":18601,"parentKind":12,"kind":253,"storage":0,"ranges":[{"L":110,"R":111},{"L":138,"R":139}],"lsRanges":[]},
{"id":0,"parentKind":0,"kind":252,"storage":0,"ranges":[{"L":103,"R":109}],"lsRanges":[]},
{"id":6315,"parentKind":1,"kind":255,"storage":0,"ranges":[{"L":8,"R":19}],"lsRanges":[]},
{"id":18600,"parentKind":12,"kind":253,"storage":0,"ranges":[{"L":83,"R":85},{"L":130,"R":132}],"lsRanges":[]},
{"id":94,"parentKind":0,"kind":12,"storage":0,"ranges":[{"L":123,"R":129}],"lsRanges":[]}]}}

Instead of {"L":99,"R":101}, cquery uses interface Range which is rather long.

1 个赞

求问怎么解决的? 哪个文档?

谢谢, 单独配置搞定了,
但是spacemacs

(c-c++ :variables
            c-c++-adopt-subprojects t
            c-c++-default-mode-for-headers 'c++-mode
            c-c++-backend 'lsp-ccls
            c-c++-enable-clang-support t)           

无解吗?

1 个赞

自己写个私有层

之前写过个lsp的…… 这一升级就lsp-*-enable都没了, 所以不太愿意写了= =!

解决方案只是一条替换语句, 但是找到失效的原因, 或者说找到这个页面却google了不少时间.

You need to check every commit until you find the change about the function

thx, I have never used it, and I’ll have a try.

btw, why you speak English on emacs-china site?

你应该搞个签名解释,不然每个人都会问一次

现在的 lsp.el 如何判断项目根目录?

以前是这样:

(defconst lsp-javascript-typescript--get-root
  (lsp-make-traverser #'(lambda (dir)
                          (directory-files dir nil "package.json"))))
                                                    ^^^^^^^^^^^^^

https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-clients.el 中没看到有类似的操作。

现在的 lsp.el 如何判断项目根目录?

修改了一樓。

project root用 lsp--suggest-project-root 查詢, (projectile-project-root)(project-current) 。如果 (setq lsp-auto-guess-root t) 可以避免進入新project時的menu

btw, why you speak English on emacs- china site?

I think the name only suggests that Chinese is the mainstream language in the forum. Other languages are not precluded.

(c-c++ :variables c-c+±adopt-subprojects t c-c+±default-mode-for-headers 'c+±mode c-c+±backend 'lsp-ccls c-c+±enable-clang-support t)

Some forwarding variables are not very necessary.

https://github.com/emacs-lsp/lsp-mode/issues/542 [Poll] lsp-mode - minimal or batteries included

Please share your opinions

2 个赞

果然是有竞争,才会进步。如果没有eglot,lspmode的作者怕是不会这么快积极更新了。

並不是作者變得積極更新,而是維護者發生了變更。

我希望lsp-mode用plist代替hash table (gethash等)

有個問題,如何disable flymake-cc?

flymake默认是关闭的呀,你看看是谁开启的

这算lsp开启的,我是说flymake不会自己启动,这个意思。

(define-derived-mode c-mode prog-mode "C"
...
  (add-hook 'flymake-diagnostic-functions 'flymake-cc nil t)
  (c-run-mode-hooks 'c-mode-common-hook))

flymake啓動是想要的,但不想要flymake-cc

暫時在mode-hook裏加

(setq flymake-diagnostic-functions (list 'lsp--flymake-backend))))
1 个赞