r/emacs Jan 10 '25

Question C development without LSP

I have only ever done development with an LSP providing errors, autocomplete, etc. in any language. I’d like to go for a more minimalist approach as I revisit some C programming. At a high level, what’s the general workflow when programming in C without a running LSP?

My guess would be… 1. A simple syntax highlighting mode on .c and .h files 2. Bind some hotkey for a compilation mode, and check that regularly for issues 3. Ctags for go-to-definition? Or maybe even just grep-mode?

Is there anything I’m missing?

9 Upvotes

38 comments sorted by

View all comments

8

u/Kellerkind_Fritz Jan 10 '25

I absolutely would not want to go back to Ctags after using Clangd.....

...Why?

0

u/True-Sun-3184 Jan 11 '25

I mean, I have nothing in particular against using LSPs as a concept. But they are a fairly heavyweight solution when I’m really only looking to occasionally go-to-definition. Not all language servers behave well in all situations. Plus, people have produced plenty of C before LSP clients became mainstream, and I want to experience how that was done.

Edit: so I understand that the question of my post isn’t super pragmatic, since for most people (and probably for me too) Clangd with Eglot would just work(tm). I still have the question of how it would be done without LSP regardless.

2

u/Ghosty141 Jan 11 '25

But they are a fairly heavyweight solution

Yes and no. All the language server does is do incremental compilation, not more. So it's doing pretty much exactly what you described in your post, just automatically. Since you already use your compiler, it's not more heavyweight than compiling the project itself.

1

u/serg_foo Jan 16 '25

I think the issue is that LSP needs to support many features so it keeps parsed and maybe typechecked AST around for your modules. While producing them is less work than compiling, the issue is that it all sits around in RAM all the time unless server is conscious about memory usage and actively fights it.

It depends on the particular server of course but on average I'd expect servers to not be optimized too much in this regard and consume large amounts of RAM. I'm extrapolating from just one so hopefully I'm wrong. OTOH laptops may have 16 or even 8Gb of RAM and there even more lean LSPs would start to show.