manateelazycat / lsp-bridge

A blazingly fast LSP client for Emacs
GNU General Public License v3.0
1.46k stars 214 forks source link

Semantics token error when using multi-lang server #1074

Closed fuyu0425 closed 1 month ago

fuyu0425 commented 1 month ago

Errors when using basedpyright_ruff, not when using only basedpyright

Looks like it hardcodes self.file_action.single_server

--- [20:20:14.298409] Recv textDocument/semanticTokens/full response (40867) from 'basedpyright' for project mu4e_utils.py
Error when processing response 40867
Traceback (most recent call last):
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/__init__.py", line 38, in handle_response
    self.process_response(response)
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/semantic_tokens.py", line 46, in process_response
    self.update_tokens(self.tokens)
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/semantic_tokens.py", line 62, in update_tokens
    faces_index = self.get_faces_index(tokens[index + 3], tokens[index + 4])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/semantic_tokens.py", line 74, in get_faces_index
    type_name = self.file_action.single_server.semantic_tokens_provider["legend"]["tokenTypes"][type_index]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'semantic_tokens_provider'
manateelazycat commented 1 month ago

我的 basedpyright 不提供 semantic 的 provider , 我暂时无法测试。

我盲修了一个补丁 https://github.com/manateelazycat/lsp-bridge/commit/5fa2ef56aae9d5bbcc388248aed0c35246216e7c 你更新看看, 能否解决这个问题?

fuyu0425 commented 1 month ago

https://github.com/manateelazycat/lsp-bridge/blob/5fa2ef56aae9d5bbcc388248aed0c35246216e7c/core/lspserver.py#L752 原本 single server 会自动 set semantic_tokens_provider returned by basedpyright

新的 error

--- [22:03:45.251833] Recv textDocument/semanticTokens/full response (38673) from 'basedpyright' for project mu4e_utils.py
Error when processing response 38673
Traceback (most recent call last):
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/__init__.py", line 38, in handle_response
    self.process_response(response)
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/semantic_tokens.py", line 46, in process_response
    self.update_tokens(self.tokens)
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/semantic_tokens.py", line 62, in update_tokens
    faces_index = self.get_faces_index(tokens[index + 3], tokens[index + 4])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fuyu0425/.spacemacs.d/site-lisp/lsp-bridge/core/handler/semantic_tokens.py", line 75, in get_faces_index
    type_name = lsp_server.semantic_tokens_provider["legend"]["tokenTypes"][type_index]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'semantic_tokens_provider'
manateelazycat commented 1 month ago

再更新一下吧

fuyu0425 commented 1 month ago

可以了 感谢 🙏🏻