-
Notifications
You must be signed in to change notification settings - Fork 266
Visual Studio Code
Install the ccls extension from the marketplace here. The source code is located at https://github.com/MaskRay/vscode-ccls.
If you run into issues, you can view debug output by running the
(F1
) View: Toggle Output
command and opening the ccls
output section.
To load vscode-ccls without installing:
code vscode-ccls
- Press F5
To tell the extension where to find ccls, either add ccls to your PATH
or set "ccls.launch.command" in User Settings to the absolute path pointing to ccls.
{
"ccls.launch.command": "/path/to/ccls/Release/ccls",
"ccls.cacheDirectory": "/tmp/.ccls-cache/"
}
If for whatever reason you cannot generate a compile_commands.json
file, you
can add the flags to the ccls.clang.extraArgs
configuration
option.
The Visual Studio Code ccls extension supports semantic highlighting. To enable, put into settings.conf (or workspace configuration):
"ccls.highlighting.enabled.types": true,
"ccls.highlighting.enabled.freeStandingFunctions": true,
"ccls.highlighting.enabled.memberFunctions": true,
"ccls.highlighting.enabled.freeStandingVariables": true,
"ccls.highlighting.enabled.memberVariables": true,
"ccls.highlighting.enabled.namespaces": true,
"ccls.highlighting.enabled.macros": true,
"ccls.highlighting.enabled.enums": true,
"ccls.highlighting.enabled.typeAliases": true,
"ccls.highlighting.enabled.enumConstants": true,
"ccls.highlighting.enabled.staticMemberFunctions": true,
"ccls.highlighting.enabled.parameters": true,
"ccls.highlighting.enabled.templateParameters": true,
"ccls.highlighting.enabled.staticMemberVariables": true,
"ccls.highlighting.enabled.globalVariables": true,
You could set custom lookup using keybindings. Use command palette (ctrl + shift + p
by default) -> Open keyboard shortcuts file
// functions called by current selected function, up to 3rd level.
{"key":"<ctrl-shift-alt-c>","command":"ccls.call","args":{"callee":true,"levels":3}}
// functions that call this function. This is what "Show Cross References" shows by default
{"key":"<your-shortcuts>","command":"ccls.call"}
// see inheritance instead of base
{"key":"<your-shortcuts>","command":"ccls.base","args":{"derived":true,"levels":2}}
// nested classes / types in a namespace (kind: 2)
{"key":"<your-shortcuts>","command":"ccls.member","args":{"kind":2}}
// member functions / functions in a namespace(kind 3)
{"key":"<your-shortcuts>","command":"ccls.member","args":{"kind":3}}
For VSCodeVim users, here's how to set arguments in User Settings (settings.json
)
"vim.normalModeKeyBindingsNonRecursive": [
{
"before":["<leader>","t"],
"commands":[{"command":"ccls.call","args":{"levels":2,"callee":true}}]
}
]
So you could hit <space>-t
to see callees up to 3rd level if you set <leader>
to <space>
The command is ccls.navigate
, which need an argument direction
. ("D" => first child declaration "L" => previous declaration "R" => next declaration "U" => parent declaration)
"vim.normalModeKeyBindingsNonRecursive": [
{"before":["<leader>","j"],"commands":[{"command":"ccls.navigate","args":{"direction":"R"}}]},
{"before":["<leader>","k"],"commands":[{"command":"ccls.navigate","args":{"direction":"L"}}]},
{"before":["<leader>","h"],"commands":[{"command":"ccls.navigate","args":{"direction":"U"}}]},
{"before":["<leader>","l"],"commands":[{"command":"ccls.navigate","args":{"direction":"D"}}]}
]