manateelazycat / lsp-bridge

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

Unusually slow indexing of lsp bridge` under clangd wrapper header file #1068

Closed harisonkhlil closed 1 day ago

harisonkhlil commented 5 days ago

emacs -Q: 下表现:

Screen Recording 2024-10-09 at 15 41 34_converted

;;; debug.el --- Debugging -*- lexical-binding: t; -*-

(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/lsp-bridge")

(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/yasnippet")
(add-to-list 'load-path "~/.config/emacs/.local/straight/repos/markdown-mode")

(require 'yasnippet)
(yas-global-mode 1)

(require 'lsp-bridge)
(global-lsp-bridge-mode)
Index:
  StandardLibrary: Yes
CompileFlags:
  Add:
    - -std=c++2b
    - -I/opt/homebrew/opt/fmt/include
  Compiler: clang++

在没有 compile_commands.json 的情况下每一个空文件索引补全都非常缓慢,比如视频演示的 <fmt/core.h> 内容是:

// This file is only provided for compatibility and may be removed in future
// versions. Use fmt/base.h if you don't need fmt::format and fmt/format.h
// otherwise.

#include "format.h"

通过使用 lsp mode 和 eglot 都没有这个问题,能够迅速反应,按照常理来说应该不是性能问题,应该是 lsp bridge 与 clangd 的交互有关。

lsp log 如下 lsp.log

manateelazycat commented 1 day ago

一直有报错

I[15:35:24.943] Built preamble of size 18305440 for file /Users/JunFeng/project/smalltools/test.cpp version 0 in 0.63 seconds
I[15:35:24.943] Indexing c++23 standard library in the context of /Users/JunFeng/project/smalltools/test.cpp
I[15:35:24.965] --> textDocument/publishDiagnostics
I[15:35:24.965] Failed to find compilation database for /Users/JunFeng/project/smalltools/test.cpp

你应该提供 compile_commands.json, 并在你的项目中执行 git init 命令, 要不是 lsp-bridge 是针对 test.cpp 这个文件提供补全, 而不是 smalltools 这个目录