company-lsp + cquery 补全问题

最近从ycmd切换到了cquery,现在对于自动补全有些疑问:

  1. company-lsp能否向ycmd一样支持模糊匹配?
  2. 感觉上company-lsp在其他文件定义的函数的补全展开上有一些问题,有时参数不正确,有时不能正确列出所有可能的展开项,这可能是什么原因导致的?(由于某种原因,我使用的是.cquery而不是compile_commands.json
(setq company-transformers nil company-lsp-async t company-lsp-cache-candidates nil)

Thx,之前应该是由于某种原因导致未能正常启用company-lsp,当时实际上用的是company-clang,鼓捣了一天现在正常了,但是我也不知道具体是哪一步操作修复的问题 :flushed:

现在我是抄的你的配置: :stuck_out_tongue_winking_eye:

  (use-package company-lsp
    :defer t
    :init
    (setq company-quickhelp-delay 0)
    ;; Language servers have better idea filtering and sorting,
    ;; don't filter results on the client side.
    (setq company-transformers nil
          company-lsp-async t
          company-lsp-cache-candidates nil)
    (spacemacs|add-company-backends :backends company-lsp :modes c-mode-common)
)

还有几个问题:

  1. 我在加入了lsp-uipeak配置:
  (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
  (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)

之后,被peak覆盖过的区域会出现括号匹配错误的高亮配色,感觉和某个包有冲突了。PS:我现在用的是spacemacs下的solarized-light的配色。

  1. 在加载了配置(setq company-lsp-cache-candidates nil)之后,自动补全反而不正常,会弹出一个与输入完全不匹配的列表;然而不加载这个配置时,自动补全需要先输入2个字符弹出一个不正确的列表,再输入第3个字符才能弹出正确的补全列表。

不知道。我不用 remap

我之前想加 spacemacs/jump-to-reference 的,沒理…… https://github.com/syl20bnr/spacemacs/pull/9911

(defun my-xref/find-definitions ()
  (interactive)
  (if lsp-mode (lsp-ui-peek-find-definitions) (spacemacs/jump-to-definition)))

(defun my-xref/find-references ()
  (interactive)
  (if lsp-mode (lsp-ui-peek-find-references) (spacemacs/jump-to-reference)))

  (define-key evil-motion-state-map (kbd "M-,") #'my-xref/find-references)
  (define-key evil-motion-state-map (kbd "C-j") #'my-xref/find-definitions)

company-minimum-prefix-length ? 但感覺這個對 C-M-i 手動觸發也生效,不知道有什麼更好的

第二个问题在我这感觉是个类似bug之类的东西,苦于不会录屏,可能不太容易描述清楚,主要体现在2点:

  1. 配置(setq company-lsp-cache-candidates nil)之后,无论如何都不能弹出正确的补全列表,但是C-M-i列出的补全项相对来说“比较”正确;如果不配置这一项,需要先输入几个字符弹出一次错误的补全列表,再多输入一个字符才能把列表刷新正确。这个问题与company-minimum-prefix-length应该没什么关系。。
  2. 对于有参数的函数补全,只能补全到左括号,并输出一条信息:Search failed. This means there is unmatched expression somewhere or we are at the beginning/end of file.但是在补全列表里面可以看到正确的参数解析,在C-M-i中只能看到左括号。

Linux 可以用 byzanz-record 錄 .gif

不知道 company-lsp-cache-candidates 幹了什麼

Search failed. This means there is unmatched expression somewhere or we are at the beginning/end of file 愚蠢的smartparens問題,它不知道現在在補全狀態,在echo area輸出消息中斷company。我現在用這個 workaround

  (with-eval-after-load 'smartparens
    (assq-delete-all :unmatched-expression sp-message-alist))

基本上我目前遇到的问题都在下面这个图上了:test

另外Search failed. This means there is unmatched expression somewhere or we are at the beginning/end of file的的问题应该不是由smartparens造成的,我把这个包exclude了依然会出现问题,只是不打印这个错误而已。

PS:有个奇怪的现象是我两台电脑用的一样的配置,但是效果却不一样,截图上这台lsp-ui是好的,company是有问题的,另一台company是好的,lsp-ui是有问题的。

更新一下状态:

  1. company candidates不正常的问题测试发现,能够正确提示的cquery是周日git下来的,如图不正常的则是周二git下来的。不知道更新了什么导致的,我用蹩脚的英语提交了一个issue。:sweat_smile:
  2. 有参数的函数补全被截断在两个版本都存在,不知道是什么地方导致的,但是应该不是smartparens造成的。

你的问题解决了么?遇到和你一样的问题。。悲剧中