mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(clangd): rewrite the root_dir function for the breaking changes of nvim 0.11
This commit is contained in:
parent
ec5981dfb1
commit
0ce049e235
1 changed files with 21 additions and 12 deletions
|
|
@ -60,7 +60,8 @@ return {
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
|
{ "<leader>ch", "<cmd>ClangdSwitchSourceHeader<cr>", desc = "Switch Source/Header (C/C++)" },
|
||||||
},
|
},
|
||||||
root_dir = function(fname)
|
root_dir = function(bufnr, ondir)
|
||||||
|
local root_directory = function(fname)
|
||||||
return require("lspconfig.util").root_pattern(
|
return require("lspconfig.util").root_pattern(
|
||||||
"Makefile",
|
"Makefile",
|
||||||
"configure.ac",
|
"configure.ac",
|
||||||
|
|
@ -69,9 +70,17 @@ return {
|
||||||
"meson.build",
|
"meson.build",
|
||||||
"meson_options.txt",
|
"meson_options.txt",
|
||||||
"build.ninja"
|
"build.ninja"
|
||||||
)(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")(
|
)(fname) or require("lspconfig.util").root_pattern(
|
||||||
fname
|
"compile_commands.json",
|
||||||
) or require("lspconfig.util").find_git_ancestor(fname)
|
"compile_flags.txt"
|
||||||
|
)(fname) or require("lspconfig.util").find_git_ancestor(fname)
|
||||||
|
end
|
||||||
|
if type(bufnr) == "string" then
|
||||||
|
return root_directory(bufnr)
|
||||||
|
else
|
||||||
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
|
ondir(root_directory(fname))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
capabilities = {
|
capabilities = {
|
||||||
offsetEncoding = { "utf-16" },
|
offsetEncoding = { "utf-16" },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue