ccls 0.20181225

發佈新版 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. Added constraints to ParameterInformation.label break possible use cases · Issue #640 · microsoft/language-server-protocol · GitHub
  • 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.ccsema_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

重點是

其他

  • 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裏的實現有點噁心(希望有人能改好)
;; 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))))

另外話說大家怎麼看textDocument/signatureHelptextDocument/hover的配合?對於foo(object|),光標處hover和signatureHelp都有返回信息。兩者都會顯示在echo area(hover有部分信息可以用lsp-ui-doc顯示),發生爭搶,目前lsp-mode的處理方式是顯示signatureHelp,但我覺得顯示hover更合理一點。

我以前的方案是僅在evil-insert-state時用signatureHelp。另外一個理由是signatureHelp的計算代價很大(在clang裏和實現completion一樣,開銷遠比從index裏獲取hover大),在normal-state頻繁移動point不必要浪費CPU cycles

6 个赞

wiki/eglot

textDocument/signatureHelptextDocument/hover

hover 只在函数名的时候起作用

signatureHelp 只在函数参数的时候起作用

我可能沒說清楚,amend了一下。發了一個PR試圖修復以前的行爲:https://github.com/emacs-lsp/lsp-mode/pull/579

prefer hover, don’t enable signatureHelp by default (可以考慮加到evil-insert-state的hook裏)

大神你好呀,想请教个问题,我在windows 用msys2编译1225这个版本,我以c++-mode创建.h后缀的文件,ccls没有补全,而之前1111版本可以,之后我把后缀改成.hh后,1225版本又可以补全了,但是我想用.h后缀 = = 请问这个该如何处理呀 :kissing:

Thanks for your suggestion, It seems .h is no longer recognized as c++ files in the latest version of ccls

I found a way to turn things around, just change %clang to clang++ in .ccls file and everything is back on track again :kissing_closed_eyes:

1 个赞

:grin:

.h is C header by default. -xc++ -xc++-header if you want to parse it as C++

touch .ccls (empty)

Since many people use it as C++ header files, https://github.com/maskray/ccls/blob/master/src/project.cc#L222

std::vector<const char *> GetFallback(const std::string path) {
  std::vector<const char *> argv{"%clang"};
  if (sys::path::extension(path) == ".h")
    argv.push_back("-xobjective-c++-header");
  argv.push_back(Intern(path));
  return argv;
}

.ccls

Parse .h as C++ header:

%clang
%h -xc++-header

Thanks a lot, it works like a charm :kissing_heart:

不知道大伙有没有可以定制 Chrome 浏览器的方案?

比如,把所有繁体字以简体字呈现在我的浏览器上?

好想了解这个 changelog,但是看到繁体字就有点眩晕。