aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/server_configurations/clangd.lua30
-rw-r--r--lua/lspconfig/server_configurations/cmake.lua5
2 files changed, 26 insertions, 9 deletions
diff --git a/lua/lspconfig/server_configurations/clangd.lua b/lua/lspconfig/server_configurations/clangd.lua
index be9e5629..4e0f2d7f 100644
--- a/lua/lspconfig/server_configurations/clangd.lua
+++ b/lua/lspconfig/server_configurations/clangd.lua
@@ -21,7 +21,14 @@ local function switch_source_header(bufnr)
end
end
-local root_pattern = util.root_pattern('compile_commands.json', 'compile_flags.txt', '.git')
+local root_files = {
+ '.clangd',
+ '.clang-tidy',
+ '.clang-format',
+ 'compile_commands.json',
+ 'compile_flags.txt',
+ 'configure.ac', -- AutoTools
+}
local default_capabilities = vim.tbl_deep_extend(
'force',
@@ -41,8 +48,7 @@ return {
cmd = { 'clangd' },
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
root_dir = function(fname)
- local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
- return root_pattern(filename)
+ return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname)
end,
single_file_support = true,
capabilities = default_capabilities,
@@ -59,14 +65,22 @@ return {
description = [[
https://clangd.llvm.org/installation.html
-**NOTE:** Clang >= 9 is recommended! See [this issue for more](https://github.com/neovim/nvim-lsp/issues/23).
+**NOTE:** Clang >= 11 is recommended! See [this issue for more](https://github.com/neovim/nvim-lsp/issues/23).
-clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified
-as compile_commands.json or, for simpler projects, a compile_flags.txt.
-For details on how to automatically generate one using CMake look [here](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). Alternatively, you can use [Bear](https://github.com/rizsotto/Bear).
+clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson
]],
default_config = {
- root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]],
+ root_dir = [[
+ root_pattern(
+ '.clangd',
+ '.clang-tidy',
+ '.clang-format',
+ 'compile_commands.json',
+ 'compile_flags.txt',
+ 'configure.ac',
+ '.git'
+ )
+ ]],
capabilities = [[default capabilities, with offsetEncoding utf-8]],
},
},
diff --git a/lua/lspconfig/server_configurations/cmake.lua b/lua/lspconfig/server_configurations/cmake.lua
index 3591c03c..a82263fb 100644
--- a/lua/lspconfig/server_configurations/cmake.lua
+++ b/lua/lspconfig/server_configurations/cmake.lua
@@ -1,10 +1,13 @@
local util = require 'lspconfig.util'
+local root_files = { 'CMakeLists.txt', 'cmake' }
return {
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(unpack(root_files))(fname) or util.find_git_ancestor(fname)
+ end,
single_file_support = true,
init_options = {
buildDirectory = 'build',