diff --git a/Visual-Studio-Code.md b/Visual-Studio-Code.md index b137916..6d8e7d1 100644 --- a/Visual-Studio-Code.md +++ b/Visual-Studio-Code.md @@ -48,3 +48,48 @@ The Visual Studio Code ccls extension supports [semantic highlighting](https://m "ccls.highlighting.enabled.staticMemberVariables": true, "ccls.highlighting.enabled.globalVariables": true, ``` + +### Cross references + +You could set custom lookup using keybindings. Use command palette (`ctrl + shift + p` by default) -> `Open keyboard shortcuts file` + +```javascript +// functions called by current selected function, up to 3rd level. +{"key":"","command":"ccls.call","args":{"callee":true,"levels":3}} + +// functions that call this function. This is what "Show Cross References" shows by default +{"key":"","command":"ccls.call"} + +// see inheritance instead of base +{"key":"","command":"ccls.base","args":{"derived":true,"levels":2}} + +// nested classes / types in a namespace (kind: 2) +{"key":"","command":"ccls.member","args":{"kind":2}} + +// member functions / functions in a namespace(kind 3) +{"key":"","command":"ccls.member","args":{"kind":3}} +``` + +For VSCodeVim users, here's how to set arguments in User Settings (`settings.json`) +```json + "vim.normalModeKeyBindingsNonRecursive": [ + { + "before":["","t"], + "commands":[{"command":"ccls.call","args":{"levels":2,"callee":true}}] + } + ] +``` +So you could hit `-t` to see callees up to 3rd level if you set `` to `` + +### Semantic Navigation + +The command is `ccls.navigate`, which need an argument `direction`. ("D" => first child declaration "L" => previous declaration "R" => next declaration "U" => parent declaration) + +```json + "vim.normalModeKeyBindingsNonRecursive": [ + {"before":["","j"],"commands":[{"command":"ccls.navigate","args":{"direction":"R"}}]}, + {"before":["","k"],"commands":[{"command":"ccls.navigate","args":{"direction":"L"}}]}, + {"before":["","h"],"commands":[{"command":"ccls.navigate","args":{"direction":"U"}}]}, + {"before":["","l"],"commands":[{"command":"ccls.navigate","args":{"direction":"D"}}]} + ] +``` \ No newline at end of file