I use company
for completion, and it's fast and efficient in OCaml, Tuareg, and Merlin.
However, it is very slow in my C project. For example, it takes more than 10 seconds when it suggests completions for structure, during which I cannot do anything in Emacs.
An example of structure I use in my project :
typedef struct {
char name[D_NAME_MAXLEN]; /**< name of the disk */
uint32_t size; /**< size of the disk */
uint32_t npart; /**< number of partitions */
uint32_t part[D_PARTMAX]; /**< parition sizes */
} d_stat;
Then I have a d_stat pointer caled d_stat and after typing typing dstat->
it stops for a looong long time, even sometimes it bugs...
Same thing with the macros, I have some macros :
OPT_SIZE
OPT_LONG_SIZE
OPT_FORCE
OPT_LONG_FORCE
OPT_NAME
OPT_LONG_NAME
etc...
And when I type OPT_ it stops like above.
How can I speed up company
completion when it gets this slow? Right now, it is not usable.
I'm using (global-company-mode)
in my init file.
tree of the project looks like :
syscp
├── bin
│ ├── disk.tfs
│ ├── libll.so
│ ├── libtfs.so
│ ├── tfs_analyze
│ ├── tfs_create
│ ├── tfs_format
│ └── tfs_partition
├── dev
│ └── device.tfs
├── disk.tfs
├── doc
│ └── config
├── ld
├── lib
│ ├── block0.h
│ ├── block.c
│ ├── block.h
│ ├── error.c
│ ├── error.h
│ ├── ll.c
│ ├── ll.h
│ ├── tfs.c
│ ├── tfs.h
│ ├── utils.c
│ └── utils.h
├── Makefile
├── obj
│ ├── block.o
│ ├── error.o
│ ├── libblock.o
│ ├── liberror.o
│ ├── libll.o
│ ├── libtfs.o
│ ├── ll.o
│ └── utils.o
├── README
├── setup.sh
└── src
├── default.h
├── tfs_analyze.c
├── tfs_create.c
├── tfs_format.c
└── tfs_partition.c
7 directories, 39 files
company-clang
(you do use Clang, right? see by typingM-x company-diag
) is inherently only suitable for small-ish projects, because it calls Clang for every completion, and each time it scans all dependencies of the current file. You can use some third-party daemon-based backend for improved performance, such asirony-mode
orrtags
.