redguardtoo / emacs.d

Fast and robust Emacs setup.
http://blog.binchen.org
GNU General Public License v3.0
2.39k stars 619 forks source link

How to disable tag auto update on c/cpp code change? #1008

Closed phye closed 1 year ago

phye commented 1 year ago

Auto updating tags in large project is quite slow and will block editing, hence I need to disable it.

PS1: I've searched several hooks but did not find anything special, not sure what black magic is behind it.

PS2: Setting counsel-etags-stop-auto-update-tags to nil will prevent manual generating tags as well (via counsel-etags-update-tags-force), hence I cannot use it.

redguardtoo commented 1 year ago

Not sure what's your set up per ctags.

I'm using counsel-etags which still need some manual setup to enable tags auto-update, https://github.com/redguardtoo/counsel-etags#auto-update-tags-file

My manual set up is in ~/.custom.el which is not part of this emacs configuration.

phye commented 1 year ago

I didn't add counsel-etags-virtual-update-tags to after-save-hook. Maybe it's not triggered after buffer save, sometimes when emacs trys to complete things, it just blocks at updating tags.

redguardtoo commented 1 year ago

Try profiling.

Looks block has nothing to do with counsel-etags.

phye commented 1 year ago

Sure. Will keep updated on getting profiling result.

phye commented 1 year ago

Confirmed that blocking usually happens whent emacs trying to complete cpp code (after three characters being inserted). Here's the profiling report:

image
redguardtoo commented 1 year ago

If you need use tags for code completion. try company-ctags which is much faster.

You can also remove company-capf from company-backends or setup company-capf further.

phye commented 1 year ago

Thanks! Will try company-ctags

phye commented 1 year ago

Confirmed that after removing company-semantic and company-clang (which requires proper include header setup which is complicated since I have different include path for searching headers for different projects) from company-backends and using company-ctags, blocking disappears.

BTW, do you know if there're any company backends which can parse header search path automatically from CMakelists.txt (hence requires no manual -I configuration) and use company-clang as the real completion engine? Completing with clang is definitely the best IMHO, however I really dislikes the way to configure header search path...

redguardtoo commented 1 year ago

You can use some lsp client like lsp-mode or elgot. They will setup company-mode and do many other things. If you use lsp, you don't need ctags based solution.

I use a package eacl which can complete lines by grepping whole project. eacl is generic tool which could completes #include statement in C/C++ if the statement already exists somewhere.

phye commented 1 year ago

Thanks! I was using lsp-mode for golang at the moment, perhaps will give lsp-mode a try.

redguardtoo commented 1 year ago

When you use lsp-mode, you still can give eacl a try. Some senior C/C++ developer found it very useful in big projects.

phye commented 1 year ago

Sure!