fixing lsp for Windows

For a long time, clangd on Windows is not quite usable without Visual Studio. It’s time for a fix!

cannot find <iostream>

First we need to fix the compile_commands.json . from the experience of project soda_clang, I quickly added the GCC include directories to the compilation database.

too many errors, stopping now

The MinGW header files contains many symbol Clangd didn’t recognize; I created a virtual directory, removing the symbols, and copying things over.

The compile db need also be changed to point to the new virtual directory.

There is always formatting problem

Boringly looking up clang-format doc, and find a somewhat consistant style. then use a script to format all files automatically on every build.

(There is also another app, Clang Format Editor, stated that it can detect style from code. but it’s not usable. the styles are all error!)

Cmake arguments are cubersome and hard to remember

I switched to cmake presets. (also use a script to generate the user presets.)

Also I created simple Makefile s to simple build. (thanks to makefiletutorial)

Need debugging

The gdb shipped with scoop does not support python scripts, so stdc++ classes (string, vector…) cannot be displayed… I switched to TDM-GCC.

Also there is CodeLLDB extension for help (LLVM’s lldb-dap was not usable.)

So.. I built clang-format, clang, but not lldb. so I ended up installing llvm from scoop again.

Also after uninstall gcc from PATH go compiler will throw an error. You need to pass the CC and CXX locations to go.

(also TDM-GCC’s include paths are different from scoop gcc. need to change the compile db again.)

Also TDM-GCC is using static libstdc++ so the -lstdc++ flag in cgo was not needed; and include it will cause error.

the end?

I was considering create a standalone tool (using Go) but don’t know where to start, and my knowledge about Golang isn’t enough.

After all that there are still minor issues (in the libstdc++ headers) but I decide to ignore them.