From b49f4c3717422b7fc49ac622e179e23458c55805 Mon Sep 17 00:00:00 2001 From: LuoZhongYao Date: Fri, 26 Mar 2021 15:14:20 +0800 Subject: Use the file path as root_dir when cmake does not find root_dir --- lua/lspconfig/cmake.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/lspconfig/cmake.lua b/lua/lspconfig/cmake.lua index 9dbcf717..42e83329 100644 --- a/lua/lspconfig/cmake.lua +++ b/lua/lspconfig/cmake.lua @@ -5,7 +5,9 @@ configs.cmake = { default_config = { cmd = {"cmake-language-server"}; filetypes = {"cmake"}; - root_dir = util.root_pattern(".git", "compile_commands.json", "build"); + root_dir = function(fname) + return util.root_pattern(".git", "compile_commands.json", "build")(fname) or util.path.dirname(fname) + end; init_options = { buildDirectory = "build", } @@ -17,7 +19,7 @@ https://github.com/regen100/cmake-language-server CMake LSP Implementation ]]; default_config = { - root_dir = [[root_pattern(".git", "compile_commands.json", "build")]]; + root_dir = [[root_pattern(".git", "compile_commands.json", "build") or dirname]]; }; }; }; -- cgit v1.2.3-70-g09d2