From 9696d8daf58528edc03dc4472f6b8d4f4f2ab8be Mon Sep 17 00:00:00 2001 From: Alexandru Geană <1569265+abgeana@users.noreply.github.com> Date: Mon, 25 Apr 2022 23:22:43 +0200 Subject: fix(ccls): .git as fallback when detecting project root (#1860) --- lua/lspconfig/server_configurations/ccls.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/ccls.lua b/lua/lspconfig/server_configurations/ccls.lua index dd642db2..27c0fd44 100644 --- a/lua/lspconfig/server_configurations/ccls.lua +++ b/lua/lspconfig/server_configurations/ccls.lua @@ -1,10 +1,17 @@ local util = require 'lspconfig.util' +local root_files = { + 'compile_commands.json', + '.ccls', +} + return { default_config = { cmd = { 'ccls' }, filetypes = { 'c', 'cpp', 'objc', 'objcpp' }, - root_dir = util.root_pattern('compile_commands.json', '.ccls', '.git'), + root_dir = function(fname) + return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) + end, offset_encoding = 'utf-32', -- ccls does not support sending a null root directory single_file_support = false, @@ -37,7 +44,9 @@ lspconfig.ccls.setup { ]], default_config = { - root_dir = [[root_pattern("compile_commands.json", ".ccls", ".git")]], + root_dir = function(fname) + return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) + end, }, }, } -- cgit v1.2.3-70-g09d2