vscode + ccls settings

  • cmake project, generate compile_command.json:
    • -DCMAKE_EXPORT_COMPILE_COMMANDS=on
  • vscode install ccls extension
  • Generate symbol cache:
#!/bin/bash

compile_cmd_dir="`pwd`/build/Debug"   # where compile_command.json locate
cache_dir=".ccls-cache"
threads=20
blacklist='["thirdparty-src", "notused-src"]'


json=$(cat <<-END
{
    "compilationDatabaseCommand":"",
    "compilationDatabaseDirectory":"$compile_cmd_dir",
    "cache":{"directory":"$cache_dir","format":"binary","hierarchicalPath":false,"retainInMemory":2},
    "index":{
        "blacklist":$blacklist,
        "initialBlacklist":$blacklist,
        "threads":$threads
    },
    "request":{"timeout":5000},"session":{"maxNum":10}
}
END
)

ccls -index . -init="$json"
  • vscode ccls extension settings
        "ccls.index.blacklist": [],
        "ccls.index.initialBlacklist": [],
        "ccls.index.threads": 20,
        "ccls.misc.compilationDatabaseDirectory": "${workspaceFolder}/build/Debug",  // where compile_commands.json locates
        "ccls.cache.directory": ".ccls-cache",  // cache file dir
        "ccls.launch.command": "ccls",

你可能感兴趣的:(c/c++,vscode,ide,编辑器)