From 8d706cb5bb681a2a06492ded4dd81faf6c5249e5 Mon Sep 17 00:00:00 2001 From: chooyy Date: Wed, 24 Jun 2026 14:12:54 +0800 Subject: workaround for clangd drive letter casing issue --- xmake/plugins/project/clang/compile_commands.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index e38c1cef1..db759f54c 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -210,12 +210,16 @@ function _make_arguments(jsonfile, arguments, opt) end -- make body + local projectdir = os.projectdir() + if is_host("windows") then -- workaround for drive letter casing issue, can be removed when cland resolves https://github.com/clangd/vscode-clangd/pull/747 + projectdir = projectdir:gsub("^([A-Z]):", function(d) return d:lower() .. ":" end) + end jsonfile:printf( [[%s{ "directory": "%s", "arguments": ["%s"], "file": "%s" -}]], (_g.firstline and "" or ",\n"), _escape_path(os.projectdir()), table.concat(arguments_escape, "\", \""), _escape_path(sourcefile)) +}]], (_g.firstline and "" or ",\n"), _escape_path(projectdir), table.concat(arguments_escape, "\", \""), _escape_path(sourcefile)) -- clear first line marks _g.firstline = false -- cgit v1.3.1 From 78efcedd2be459d02cd7758badd0dcca8b77e053 Mon Sep 17 00:00:00 2001 From: chooyy Date: Wed, 24 Jun 2026 14:28:23 +0800 Subject: update --- xmake/plugins/project/clang/compile_commands.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index db759f54c..d4b2b738f 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -211,8 +211,8 @@ function _make_arguments(jsonfile, arguments, opt) -- make body local projectdir = os.projectdir() - if is_host("windows") then -- workaround for drive letter casing issue, can be removed when cland resolves https://github.com/clangd/vscode-clangd/pull/747 - projectdir = projectdir:gsub("^([A-Z]):", function(d) return d:lower() .. ":" end) + if is_host("windows") then -- workaround for drive letter casing issue, can be removed when clangd resolves https://github.com/clangd/vscode-clangd/pull/747 + projectdir = projectdir:gsub("^[A-Z]:", string.lower) end jsonfile:printf( [[%s{ -- cgit v1.3.1 From 54cbd34ef9d50ad191f1daa4f9ca1c7fbcd4e4fb Mon Sep 17 00:00:00 2001 From: chooyy Date: Wed, 24 Jun 2026 15:48:44 +0800 Subject: workaround only for clangd --- xmake/plugins/project/clang/compile_commands.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index d4b2b738f..295b1f355 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -211,7 +211,9 @@ function _make_arguments(jsonfile, arguments, opt) -- make body local projectdir = os.projectdir() - if is_host("windows") then -- workaround for drive letter casing issue, can be removed when clangd resolves https://github.com/clangd/vscode-clangd/pull/747 + -- workaround for drive letter casing issue, can be removed when clangd resolves https://github.com/clangd/vscode-clangd/pull/747 + local lsp = _get_lsp() + if is_host("windows") and (lsp == nil or lsp == "clangd") then projectdir = projectdir:gsub("^[A-Z]:", string.lower) end jsonfile:printf( -- cgit v1.3.1 From 4aab79c8e91e7ed2c0cf1ae033b6de1a212ea431 Mon Sep 17 00:00:00 2001 From: choyy <68107073+choyy@users.noreply.github.com> Date: Wed, 24 Jun 2026 21:52:27 +0800 Subject: Remove duplicate variable 'lsp' --- xmake/plugins/project/clang/compile_commands.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 295b1f355..2f25194cc 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -212,7 +212,6 @@ function _make_arguments(jsonfile, arguments, opt) -- make body local projectdir = os.projectdir() -- workaround for drive letter casing issue, can be removed when clangd resolves https://github.com/clangd/vscode-clangd/pull/747 - local lsp = _get_lsp() if is_host("windows") and (lsp == nil or lsp == "clangd") then projectdir = projectdir:gsub("^[A-Z]:", string.lower) end -- cgit v1.3.1