mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Emacs
parent
0f74f1812f
commit
b1f1e8df75
14
Debugging.md
14
Debugging.md
@ -6,9 +6,7 @@ First of all, use a `--variant=debug` [[Build]]. It is compiled with `-O0 -g` wh
|
||||
|
||||
### Dump LSP requests/responses
|
||||
|
||||
`--record=/tmp/ccls`: You can find stdin/stdout (LSP requests/responses) in `/tmp/cquery.{in,out}`
|
||||
|
||||
Alternatively, enable logs and pass the `--log-all-to-stderr` option to the ccls executable (`bin/cquery --log-file=/tmp/cq.log --log-all-to-stderr`). You can find stderr output in:
|
||||
Alternatively, enable logs and pass the `--log-all-to-stderr` option to the ccls executable (`bin/ccls --log-file=/tmp/cq.log --log-all-to-stderr`). You can find stderr output in:
|
||||
|
||||
* LanguageClient-neovim: `/tmp/LanguageServer.log` (default)
|
||||
* Emacs lsp-mode: `*lsp-ccls stderr*` buffer. They will also go to `*message*` buffer if `(setq lsp-print-io t)`
|
||||
@ -35,21 +33,21 @@ nn ,al :LanguageClientStart<cr>
|
||||
rm -r /tmp/ccls && CQUERY_TRACEME=1 nvim a.cc +'normal ,al'
|
||||
```
|
||||
|
||||
The Neovim buffer will hang there because `CCLS_TRACEME=1` causes the bin/cquery process to SIGTSTP itself. In another shell, `gdb -p $(pgrep -fn bin/cquery)`
|
||||
The Neovim buffer will hang there because `CCLS_TRACEME=1` causes the `ccls` process to SIGTSTP itself. In another shell, `gdb -p $(pgrep -fn debug/ccls)`
|
||||
|
||||
### Poor man's breakpoint
|
||||
|
||||
Insert an infinite loop `volatile static int z=0;while(!z);` somewhere and ccls will stop there. Attach to the cquery process with `gdb -p $(pgrep -fn cquery)`. Set some breakpoints, use `print` commands, and execute `p z=1` for continuing.
|
||||
Insert an infinite loop `volatile static int z=0;while(!z);` somewhere and ccls will stop there. Attach to the ccls process with `gdb -p $(pgrep -fn ccls)`. Set some breakpoints, use `print` commands, and execute `p z=1` for continuing.
|
||||
|
||||
When setting breakpoints, if several threads may stop on the same breakpoint (e.g. concurrent indexer threads),
|
||||
execute `set scheduler-locking on`.
|
||||
|
||||
### Using a debugger
|
||||
|
||||
Cache files are deleted to avoid possible issues related to stale cache. `CCLS_TRACEME=1` causes the cquery process to stop at the start of `main()`. You may attach to the process with:
|
||||
Cache files are deleted to avoid possible issues related to stale cache. `CCLS_TRACEME=1` causes the ccls process to stop at the start of `main()`. You may attach to the process with:
|
||||
|
||||
* `gdb -p $(pgrep -fn ccls)`. Invoke `signal SIGCONT` if you want cquery to continue running after detaching of gdb.
|
||||
* `lldb -p $(pgrep -fn ccls)`. Invoke `pro sig SIGCONT` when the process resumes (with a `c` command) if you want cquery to continue running after detaching.
|
||||
* `gdb -p $(pgrep -fn ccls)`. Invoke `signal SIGCONT` if you want ccls to continue running after detaching of gdb.
|
||||
* `lldb -p $(pgrep -fn ccls)`. Invoke `pro sig SIGCONT` when the process resumes (with a `c` command) if you want ccls to continue running after detaching.
|
||||
|
||||
### libclang or indexer callback issues
|
||||
|
||||
|
27
Emacs.md
27
Emacs.md
@ -15,8 +15,7 @@ The only required configuration is `ccls-executable`. Others have good defaults.
|
||||
`xref-find-definitions` (default: `M-.`) / highlighting of the symbol at point / type signature in echo area should work out-of-box. Read on for customization and more features.
|
||||
|
||||
```elisp
|
||||
(setq ccls-executable "/path/to/ccls/build/release/bin/ccls")
|
||||
;; ;; Arch Linux aur/ccls-git aur/ccls
|
||||
(setq ccls-executable "/path/to/ccls/release/ccls")
|
||||
;; (setq ccls-executable "/usr/bin/ccls")
|
||||
|
||||
;; ;; Log file
|
||||
@ -24,12 +23,20 @@ The only required configuration is `ccls-executable`. Others have good defaults.
|
||||
;; ;; Cache directory, both relative and absolute paths are supported
|
||||
;; (setq ccls-cache-dir ".ccls_cached_index")
|
||||
;; ;; Initialization options
|
||||
;; (setq ccls-extra-init-params '(:cacheFormat "msgpack"))
|
||||
;; (setq ccls-extra-init-params '(:completion (:detailedLabel t)))
|
||||
```
|
||||
|
||||
You may leave `ccls-executable` unchanged (default: `ccls`) and create a shell wrapper named `ccls` and put it into your `PATH`:
|
||||
```zsh
|
||||
#!/bin/zsh
|
||||
#export CCLS_TRACEME=1 # if you want to debug ccls, stop it right after main() is called
|
||||
#export LD_LIBRARY_PATH=~/Dev/llvm/release/lib # if you link against shared library libLLVM.so, not statically
|
||||
exec ~/Dev/Util/ccls/release/ccls --log-file=/tmp/ccls.log "$@"
|
||||
```
|
||||
|
||||
#### Projects with subprojects
|
||||
|
||||
For each source file that has turned on `lsp-ccls-enable`, variable `MaskRay-roots`, projectile, `compile_commands.json` are consulted to locate the project root and the associated lsp-mode workspace. If your project has subprojects, `(projectile-project-root)` may think files in the subproject belong to the child workspace, which is not desired. `(setq MaskRay-roots '("~/my-root-project" ))` to override projectile roots.
|
||||
For each source file that has turned on `lsp-ccls-enable`, projectile is consulted to locate the project root and the associated lsp-mode workspace. If your project has subprojects, `(projectile-project-root)` may think files in the subproject belong to the child workspace, which is not desired. `touch .ccls-root` in the root directory to override projectile roots.
|
||||
|
||||
If you do not mind files in subprojects are treated as part of the whole project in projectile:
|
||||
|
||||
@ -54,6 +61,8 @@ To turn on ccls for all C/C++ modes:
|
||||
;; Also see lsp-project-whitelist lsp-project-blacklist ccls-root-matchers
|
||||
```
|
||||
|
||||
MaskRay's doom-emacs configuration: <https://github.com/MaskRay/Config/blob/master/home/.config/doom/modules/private/my-cc/config.el>
|
||||
|
||||
### Diagnostics
|
||||
|
||||
* `M-x lsp-capabilities` LSP workspace is initialized correctly
|
||||
@ -62,13 +71,15 @@ To turn on ccls for all C/C++ modes:
|
||||
|
||||
The buffer `*lsp-ccls stderr*` and `--log-file=/tmp/cq.log` contain logs.
|
||||
|
||||
Also refer to [[Debugging]].
|
||||
|
||||
## [[Initialization options]]
|
||||
|
||||
Initialization options are defined in [config.h](https://github.com/MaskRay/ccls/blob/master/src/config.h), but you need to customize them in S-exp.
|
||||
Use `t` for true, `:json-false` for false, `:json-null` for null.
|
||||
|
||||
```elisp
|
||||
(setq ccls-extra-init-params '(:index (:comments 2) :cacheFormat "msgpack" :completion (:detailedLabel t)))
|
||||
(setq ccls-extra-init-params '(:index (:comments 2) :completion (:detailedLabel t)))
|
||||
```
|
||||
|
||||
### Find definitions/references
|
||||
@ -120,7 +131,7 @@ Aside from definitions/references/workspace symbol, ccls provides some LSP exten
|
||||
```elisp
|
||||
(ccls-xref-find-custom "$ccls/base")
|
||||
(ccls-xref-find-custom "$ccls/callers")
|
||||
(ccls-xref-find-custom "$ccls/derived")
|
||||
; Use lsp-goto-implementation or lsp-ui-peek-find-implementation for derived types/functions
|
||||
(ccls-xref-find-custom "$ccls/vars")
|
||||
|
||||
;; Alternatively, use lsp-ui-peek interface
|
||||
@ -151,7 +162,7 @@ Install [company-lsp](https://github.com/tigersoldier/company-lsp) and add `comp
|
||||
|
||||
Type `#i"` (or `#include "`) for quote-style includes and `#i<` (or `#include <`) for system headers.
|
||||
|
||||
See https://github.com/MaskRay/ccls/pull/391#issuecomment-362872732 for an alternative view (contextual parent as detail, signature as label)
|
||||
See https://github.com/cquery-project/cquery/pull/391#issuecomment-362872732 for an alternative view (contextual parent as detail, signature as label)
|
||||
```elisp
|
||||
(setq ccls-extra-init-params '(:completion (:detailedLabel t)))
|
||||
```
|
||||
@ -182,7 +193,7 @@ ccls-sem-macro-colors
|
||||
ccls-sem-member-face ;; defaults to t :slant italic
|
||||
|
||||
;; To customize faces used
|
||||
(face-spec-set 'cquery-sem-member-face
|
||||
(face-spec-set 'ccls-sem-member-face
|
||||
'((t :slant "normal"))
|
||||
'face-defface-spec)
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user