From f91b345bbb98ab33065e9c88f07ee26eac55d5c9 Mon Sep 17 00:00:00 2001 From: Adnios <2780199647@qq.com> Date: Wed, 14 Apr 2021 16:36:47 +0800 Subject: Use the file path as root_dir when ccls does not find root_dir --- lua/lspconfig/ccls.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lua/lspconfig/ccls.lua') diff --git a/lua/lspconfig/ccls.lua b/lua/lspconfig/ccls.lua index 190ffffc..fd4a4326 100644 --- a/lua/lspconfig/ccls.lua +++ b/lua/lspconfig/ccls.lua @@ -5,7 +5,9 @@ configs.ccls = { default_config = { cmd = {"ccls"}; filetypes = {"c", "cpp", "objc", "objcpp"}; - root_dir = util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"); + root_dir = function(fname) + return util.root_pattern("compile_commands.json", "compile_flags.txt", ".git")(fname) or util.path.dirname(fname) + end; }; docs = { description = [[ @@ -35,7 +37,7 @@ lspconfig.ccls.setup { ]]; default_config = { - root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git")]]; + root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]]; }; }; } -- cgit v1.2.3-70-g09d2