ccls 0.20181225 release

圣诞发布新版https://github.com/MaskRay/ccls/releases/tag/0.20181225

  • workspace/didChangeWatchedFiles works (tested on VSCode and coc.nvim) and file deletion will remove index symbols
  • .ccls enhancement #171 added new directives %compile_commands.json %h %hpp %objective-c %objective-cpp
  • -v=1 dumps command line options of files for parsing
  • fuzzy_match: when the completion filter begins with a letter, builtin macros prefixed with an underscore will not be returned
  • Support textDocument/declaration and LocationLink[] return types.
  • Properly handle "exit" #159
  • Support signatureHelp.signatureInformationparameterInformation.labelOffsetSupport cf. https://github.com/Microsoft/language-server-protocol/issues/640
  • codeAction: fixed an incompatibility issue with VSCode

Completion

  • More precise diagnostics/completion: an included file that has been changed does not need to be saved to take effect.
  • Decreased Content-Length: from 32K to 25K for some cases
  • On clang < 8, fixed #include < completion for -I dir
  • Macros are categorized as Text, instead of Interface
  • Refactor and rename (clang_complete.cc -> sema_manager.cc)
  • C++17 deduction guide #173

Others

  • Support multiple -init=: "initializationOptions" from client are applied first, then -init=. Scalar options will be overridden while arrays will get concatenated

重点是

  • 更加精确的diagnostics/completion(针对#include中的依赖unsaved buffers),之前cquery/ccls的做法都不好
  • 档案删除、重命名:之前这两个专案都不会清理掉删除的档案 #170
  • #159 是之前LSP exit触发exit(0)(中断一个正在写cache的indexer thread下次可能读不出来,但非常罕见)
  • 补全的其他大大小小改进
  • 如果一个textDocument的索引未被加载,request (textDocument/documentHighlight textDocument/hover等)会报告not indexed,显示在echo area,比较恼人。我在pipeline.cc引入了一个backlog解决这一问题,详见https://github.com/MaskRay/ccls/pull/176。code lens可以用(add-hook 'lsp-after-open-hook #'ccls-code-lens-mode)而不需要(run-at-time 0.5 nil #'ccls-code-lens-mode)
  • 增强.cclscompile_commands.json的协作,详见Paul Smith的分析https://github.com/MaskRay/ccls/issues/115#issuecomment-449455357

其他

  • ccls/wiki/Emacs拆分成wiki/lsp-modewiki/egot,后者还比较简陋(欢迎贡献)
  • eglot支援workspace/didChangeWatchedFiles,lsp-mode尚未
  • 我给lsp-mode加了LocationLink支援,targetSelectRange可以指向名字,而targetRange指向轮廓。mouse hover时可以有可视效果(对于Emacs用途不大)
  • xref.el的xref-file-location并非表示interface Range的良好选择,因为仅能表示点(line column),不能表示区间。lsp-ui-peek里需要区间信息highlight文本,无法良好地用xref表达,在lsp-ui-peek里的实现有点恶心(希望有人能改好)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    ;; xref.el
    (defclass xref-file-location (xref-location)
    ((file :type string :initarg :file)
    (line :type fixnum :initarg :line :reader xref-location-line)
    (column :type fixnum :initarg :column :reader xref-file-location-column))
    :documentation "A file location is a file/line/column triple.
    Line numbers start from 1 and columns from 0.")

    ;; lsp-ui-peek.el
    (-if-let (uri (gethash "uri" x))
    (-let (((&hash "start" (&hash "line" "character")) (gethash "range" x)))
    (lsp-ui-peek--goto-xref `(:file ,(lsp--uri-to-path uri) :line ,line :column ,character)))
    (-let (((&hash "start" (&hash "line" "character")) (or (gethash "targetSelectionRange" x) (gethash "targetRange" x))))
    (lsp-ui-peek--goto-xref `(:file ,(lsp--uri-to-path (gethash "targetUri" x)) :line ,line :column ,character))))

  • 非常希望看到有人能把lsp-mode的hash tables+string keys ((gethash "range" xx))都改成plists + keyword keys ((plist-get xx :range)),这样会让我感觉还是有希望的……
  • code lens我另外也在等待eglot的处理:https://github.com/joaotavora/eglot/pull/71,lsp-mode中的issue是https://github.com/emacs-lsp/lsp-mode/issues/361