manateelazycat / lsp-bridge

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

能否加一个加载完成的通知 #1100

Open C-Entropy opened 1 week ago

C-Entropy commented 1 week ago

如题,在用于rust补全时,在lsp-bridge启动后还需要和rust-analyzer进行通信。 对一些依赖比较多的项目这个时间会比较久,通信内容也比较多。 如以打开bevy,的examples/games/alien_cake_addict.rs为例, *lsp-bridge*的行数在14761行左右,加载时间在4-5秒左右。 能否在加载完成的时候做一些提示呢?

manateelazycat commented 1 week ago

你是不是把 lsp-bridge-enable-log 选项打开了? 我刚刚测试了 alien_cake_addict.rs, 打开很快呀, 瞬间就打开了

manateelazycat commented 1 week ago

我看到有几处进度:

--- [22:02:35.169733] Recv $/progress notification from 'rust-analyzer' for project bevy { "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Fetching", "value": { "kind": "end" } } }

--- [22:02:35.400579] Recv $/progress notification from 'rust-analyzer' for project bevy { "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Building CrateGraph", "value": { "kind": "end" } } }

--- [22:02:35.614140] Recv $/progress notification from 'rust-analyzer' for project bevy { "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Loading proc-macros", "value": { "kind": "end" } } }

Eval in Emacs: (lsp-bridge--record-work-done-progress '"[LSP-Bridge] 577/577") { "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Roots Scanned", "value": { "kind": "end", "message": "577/577" } } }

{ "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Building build-artifacts", "value": { "kind": "end" } } }

{ "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Building CrateGraph", "value": { "kind": "end" } } }

Eval in Emacs: (lsp-bridge--record-work-done-progress '"[LSP-Bridge] 577/577") { "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Roots Scanned", "value": { "kind": "end", "message": "577/577" } } }

{ "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Loading proc-macros", "value": { "kind": "end" } } }

{ "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rust-analyzer/flycheck/0", "value": { "kind": "end" } } }

{ "jsonrpc": "2.0", "method": "$/progress", "params": { "token": "rustAnalyzer/Indexing", "value": { "kind": "end" } } }

你期望在哪个 end 信息提醒呢? rustAnalyzer/indexing?

C-Entropy commented 1 week ago

打开文件是很快的,但是打开文件后有大量的通讯,到可以正式使用lsp-bridge的功能大概有4-5s。

alien_cake_addict.rsdescribe-variable lsp-bridge-enable-loglsp-bridge-enable-debug 都是nil

*lsp-bridge*里大部分log是长这样的:

--- [22:15:22.825870] Recv window/workDoneProgress/create request (3) from 'rust-analyzer' for project bevy

--- [22:15:22.825971] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.826221] Send response to server request 2 to 'rust-analyzer' for project bevy

--- [22:15:22.826325] Send response to server request 3 to 'rust-analyzer' for project bevy

--- [22:15:22.826529] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.826610] Recv window/workDoneProgress/create request (4) from 'rust-analyzer' for project bevy

--- [22:15:22.826686] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.826857] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.827043] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828455] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828581] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828705] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828831] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828958] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829103] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829227] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829347] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829470] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829590] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829708] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829831] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829951] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.830238] Send response to server request 4 to 'rust-analyzer' for project bevy

--- [22:15:22.875665] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.875785] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.875904] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.878925] Recv $/progress notification from 'rust-analyzer' for project bevy

另外还发现了一些error

这个应该是库本身的问题

--- [22:15:23.919668] Recv $/progress notification from 'rust-analyzer' for project bevy
2024-11-04T14:15:23.923946Z ERROR cyclic deps: bevy_math(Idx::<CrateData>(352)) -> bevy_math(Idx::<CrateData>(352)), alternative path: bevy_math(Idx::<CrateData>(352))

这个错误的触发机制还需要研究,有时候不会出现

--- [22:15:24.099826] Traceback (most recent call last):
  File "/home/nil/.emacs.d/git/lsp-bridge/core/lspserver.py", line 860, in handle_register_capability_message
    self.monitor_workspace_files(workspace_watch_files)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.emacs.d/git/lsp-bridge/core/lspserver.py", line 910, in monitor_workspace_files
    self.workspace_file_watcher.schedule(self.workspace_file_watch_handler, target_dir, recursive=False)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/api.py", line 312, in schedule
    emitter.start()
    ~~~~~~~~~~~~~^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/utils/__init__.py", line 75, in start
    self.on_thread_start()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify.py", line 119, in on_thread_start
    self._inotify = InotifyBuffer(path, recursive=self.watch.is_recursive, event_mask=event_mask)
                    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify_buffer.py", line 30, in __init__
    self._inotify = Inotify(path, recursive=recursive, event_mask=event_mask)
                    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify_c.py", line 149, in __init__
    Inotify._raise_error()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify_c.py", line 421, in _raise_error
    raise OSError(errno.EMFILE, "inotify instance limit reached")
OSError: [Errno 24] inotify instance limit reached

打开文件后什么都不操作等待加载完成的提示是这个:

--- [22:22:06.034205] Recv window/showMessage notification from 'rust-analyzer' for project bevy

--- [22:22:06.034422] Recv textDocument/signatureHelp response (48766) from 'rust-analyzer' for project bevy

--- [22:22:06.034890] Recv textDocument/publishDiagnostics notification from 'rust-analyzer' for project bevy

--- [22:22:06.035117] Record diagnostics from 'rust-analyzer' for file alien_cake_addict.rs

--- [22:22:12.934116] Recv textDocument/publishDiagnostics notification from 'rust-analyzer' for project bevy

--- [22:22:12.934253] Record diagnostics from 'rust-analyzer' for file alien_cake_addict.rs

在不操作情况下到加载完成的log见附件 lsp-bridge.txt

manateelazycat commented 1 week ago

打开文件是很快的,但是打开文件后有大量的通讯,到可以正式使用lsp-bridge的功能大概有4-5s。

alien_cake_addict.rsdescribe-variable lsp-bridge-enable-loglsp-bridge-enable-debug 都是nil

*lsp-bridge*里大部分log是长这样的:

--- [22:15:22.825870] Recv window/workDoneProgress/create request (3) from 'rust-analyzer' for project bevy

--- [22:15:22.825971] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.826221] Send response to server request 2 to 'rust-analyzer' for project bevy

--- [22:15:22.826325] Send response to server request 3 to 'rust-analyzer' for project bevy

--- [22:15:22.826529] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.826610] Recv window/workDoneProgress/create request (4) from 'rust-analyzer' for project bevy

--- [22:15:22.826686] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.826857] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.827043] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828455] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828581] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828705] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828831] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.828958] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829103] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829227] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829347] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829470] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829590] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829708] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829831] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.829951] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.830238] Send response to server request 4 to 'rust-analyzer' for project bevy

--- [22:15:22.875665] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.875785] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.875904] Recv $/progress notification from 'rust-analyzer' for project bevy

--- [22:15:22.878925] Recv $/progress notification from 'rust-analyzer' for project bevy

另外还发现了一些error

这个应该是库本身的问题

--- [22:15:23.919668] Recv $/progress notification from 'rust-analyzer' for project bevy
2024-11-04T14:15:23.923946Z ERROR cyclic deps: bevy_math(Idx::<CrateData>(352)) -> bevy_math(Idx::<CrateData>(352)), alternative path: bevy_math(Idx::<CrateData>(352))

这个错误的触发机制还需要研究,有时候不会出现

--- [22:15:24.099826] Traceback (most recent call last):
  File "/home/nil/.emacs.d/git/lsp-bridge/core/lspserver.py", line 860, in handle_register_capability_message
    self.monitor_workspace_files(workspace_watch_files)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.emacs.d/git/lsp-bridge/core/lspserver.py", line 910, in monitor_workspace_files
    self.workspace_file_watcher.schedule(self.workspace_file_watch_handler, target_dir, recursive=False)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/api.py", line 312, in schedule
    emitter.start()
    ~~~~~~~~~~~~~^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/utils/__init__.py", line 75, in start
    self.on_thread_start()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify.py", line 119, in on_thread_start
    self._inotify = InotifyBuffer(path, recursive=self.watch.is_recursive, event_mask=event_mask)
                    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify_buffer.py", line 30, in __init__
    self._inotify = Inotify(path, recursive=recursive, event_mask=event_mask)
                    ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify_c.py", line 149, in __init__
    Inotify._raise_error()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/nil/.pyenv/versions/3.13.0a6/lib/python3.13/site-packages/watchdog/observers/inotify_c.py", line 421, in _raise_error
    raise OSError(errno.EMFILE, "inotify instance limit reached")
OSError: [Errno 24] inotify instance limit reached

打开文件后什么都不操作等待加载完成的提示是这个:

--- [22:22:06.034205] Recv window/showMessage notification from 'rust-analyzer' for project bevy

--- [22:22:06.034422] Recv textDocument/signatureHelp response (48766) from 'rust-analyzer' for project bevy

--- [22:22:06.034890] Recv textDocument/publishDiagnostics notification from 'rust-analyzer' for project bevy

--- [22:22:06.035117] Record diagnostics from 'rust-analyzer' for file alien_cake_addict.rs

--- [22:22:12.934116] Recv textDocument/publishDiagnostics notification from 'rust-analyzer' for project bevy

--- [22:22:12.934253] Record diagnostics from 'rust-analyzer' for file alien_cake_addict.rs

在不操作情况下到加载完成的log见附件 lsp-bridge.txt

啥系统? inotify 那个错误应该是系统设置 inotify 太少, 而项目文件太多导致的呀。

C-Entropy commented 1 week ago

系统是gentoo的,我试着开了几次文件,inotify 这个 错误只出现了一次。