当前位置: 首页 > 工具软件 > ccls > 使用案例 >

vscode + ccls settings

匡玉堂
2023-12-01
  • 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",

 类似资料: