Replies: 6 comments 24 replies
-
This would be really cool. To me, having an LSP server instantly legitimizes a language, +10! I've never implemented an LSP server before but I'm interested in trying to tackle something like this. I've started researching to see what it takes |
Beta Was this translation helpful? Give feedback.
-
Thanks for the idea! Info in case it helps... cppfront's linear structure is this, where each file depends only on the one immediately above it: common.h
io.h Cpp1/Cpp2 source file i/o
lex.h Cpp2 tokenizer
parse.h Cpp2 parser
reflect.h2 Cpp2 reflection API (with cpp2regex.h)
sema.h Cpp2 semantic analysis
to_cpp1.h Cpp2->Cpp1 lowering
cppfront.cpp Driver Each subset is intended to be standalone and reusable, so:
If you see that it "almost" works and you need something more that's not there, and it's super easy to add (especially if it's a lightweight PR, since code is appreciated) it could fit in #1287's Priority 1. Disclaimer: I don't currently have capacity to do larger-scale refactoring/reorganization or invasive changes though. HTH! |
Beta Was this translation helpful? Give feedback.
-
I cobbled this together today I had to (or rather, wanted to) add a flag to cppfront to output its error results as json, just so it was easier to parse the error reports without too much fuss. It's probably bad... but perhaps I'll open a PR |
Beta Was this translation helpful? Give feedback.
-
I've been working on this language server for a little bit now, and have managed to implement Figured I'd paste it here in case anyone wants to check it out. It's all currently in typescript, I've been using it as a test-bed to inform the types of info I need out of cppfront. |
Beta Was this translation helpful? Give feedback.
-
How do you see interactions between Cpp1 LSP (MS C/C++ or clangd) and Cpp2 LSP? However, if I start a rename operation in my Cpp1 LSP, it would suggest renaming the callers in the preprocessed code, not the Cpp2 code. As such, after the rename, everything seems to be working until the generated file gets regenerated. At which point, your build is broken. Vice versa, I see auto-complete in Cpp2 only usable if it can give suggestions of functions defined in pure Cpp1. A rename started from Cpp2 code that is used in Cpp1 code has the exact same problem. Note: this problem holds for all C++ successors, though Cpp2 seems to be the first to reach this point. Actually, it holds for all C++ code generators, for example lex/yacc. For any successor, you expect that over some time it covers sufficient code that this problem can no longer be ignored. In order to solve this, you either need 1 LSP that understands both Cpp1 and Cpp2 or you should find a good way to have them collaborate. Semantic code rewrites (like clang-tidy) might even result in a harder problem to solve. Having multiple successors in a single codebase will even be more challenging. |
Beta Was this translation helpful? Give feedback.
-
A new update. All of the basic cpp2 diagnostics themselves are working, and I've just managed today to augment them with the standard c++ compiler errors now too. Although the diagnostics from the c++ compiler are a little off... At this point, we need a better mapping between the generated c++ code and the cpp2 code in order to show more accurate error locations/reports. A big bulk of the work is taken care of automatically thanks to the |
Beta Was this translation helpful? Give feedback.
-
Is there already a way to get a working LSP to provide at least minimal completion hints for a cpp2 file?
I thought maybe running cppfront on the buffer content and then sending that to clangd..
Or even better is someone already cooking a cppfront in clang?
Beta Was this translation helpful? Give feedback.
All reactions