Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
906 stars 99 forks source link

Auto completion after including a new header file from standard library #485

Closed sehnsucht13 closed 6 years ago

sehnsucht13 commented 6 years ago

Hi there. Just wanted to say thank you very much for all of your hard work on the package! To preface this, I tried to look throught previous issues and did not see anything about this so I apologize if this is a rookie mistake.

So far, autocompletion has been working very well with local libraries and header files that were housed in the same folder as my project but recently I have ran into an issue when it comes to autocompleting standard library functions. For example, if I import something like string.h or assert.h then there will not be any autocompletion until I restart the server or close and reopen the file(or rather kill the buffer). Is there anything I can do to fix this or any way to start indexing the buffer for the new functions to be included in auto completion? If it matters, I am running manjaro linux and clang and libclang are installed. Also, just ahead of time I would like to apologize if there is something obvious that I have missed. I have recently started learning c and c++.

Thanks a lot ahead of time!

3246251196 commented 6 years ago

There are a lot of these sorts of questions - where a restart of the server would be useful. Though it should not be advocated, I am always in favour of hacking my configuration to my liking without exerting the effort to correctly fix things.

My solution for this sort of issue is to have a background timer that restarts the server every so often. This solves a number of issues and would also solve yours.

Look into something like emacs' run-with-timer function and consider calling irony-server-kill followed by irony-parse-buffer.

3246251196 commented 6 years ago

I forgot to mention that irony-parse-buffer is a public and interactive function I put into irony.el so I could do this sort of thing:

(defun irony-parse-buffer ()
  "Parse the current buffer."
  (interactive)
  (irony--run-task-asynchronously (irony--parse-task)
                                  (lambda (result) ())))
sehnsucht13 commented 6 years ago

Thank you very much for the info! I will definetely set up something similar to what you have.