Sarcasm / irony-mode

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

autocompletion #213

Open norbertklar opened 9 years ago

norbertklar commented 9 years ago

Hello!

I found difficult to set up irony-mode. Code completion working, but I don't get completion "bubble", like in cedet. Pressing TAB not working either, I need to write "irony-completion-at-point-async" command to see the suggestions.

norbertklar commented 9 years ago

okey, I got the following setup(i found somewhere is github):

;; =============
;; irony-mode
;; =============
(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
;; =============
;; company mode
;; =============
(add-hook 'c++-mode-hook 'company-mode)
(add-hook 'c-mode-hook 'company-mode)
;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
(define-key irony-mode-map [remap completion-at-point]
  'irony-completion-at-point-async)
(define-key irony-mode-map [remap complete-symbol]
  'irony-completion-at-point-async))
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
(eval-after-load 'company
'(add-to-list 'company-backends 'company-irony))
;; (optional) adds CC special commands to `company-begin-commands' in order to
;; trigger completion at interesting places, such as after scope operator
;;     std::|
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands)
;; =============
;; flycheck-mode
;; =============
(add-hook 'c++-mode-hook 'flycheck-mode)
(add-hook 'c-mode-hook 'flycheck-mode)
(eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
;; =============
;; eldoc-mode
;; =============
(add-hook 'irony-mode-hook 'irony-eldoc)
;; ==========================================
;; (optional) bind TAB for indent-or-complete
;; ==========================================
(defun irony--check-expansion ()
(save-excursion
  (if (looking-at "\\_>") t
    (backward-char 1)
    (if (looking-at "\\.") t
      (backward-char 1)
      (if (looking-at "->") t nil)))))
(defun irony--indent-or-complete ()
"Indent or Complete"
(interactive)
(cond ((and (not (use-region-p))
            (irony--check-expansion))
       (message "complete")
       (company-complete-common))
      (t
       (message "indent")
       (call-interactively 'c-indent-line-or-region))))
(defun irony-mode-keys ()
"Modify keymaps used by `irony-mode'."
(local-set-key (kbd "TAB") 'irony--indent-or-complete)
(local-set-key [tab] 'irony--indent-or-complete))
(add-hook 'c-mode-common-hook 'irony-mode-keys)

Autocompletion working nicely, but sometimes I got this message: screenshot_2015-07-13_11-45-47

Sarcasm commented 9 years ago

Your error seems to come from yasnippet. Could you show your yasnippet configuration?

About the cedet completion bubble, could you show what it looks like?

For completion-at-point, I'm working on something that would make it easy to do a synchronous version that will integrate seamlessly with completion at point.

For indent or complete I believe this is purely a company mode issue, I think, this is on the wishlist: https://github.com/company-mode/company-mode/issues/94

norbertklar commented 9 years ago

Hehe, I forgot to include yasnippet in my config. Sorry about that. Can you tell me, why autocomplete on dot is slow, compared to IDEs, like Code::Blocks(anyway irony-mode still faster than CEDET, so thanks for that)?

Sarcasm commented 9 years ago

I don't know anything about code blocks sorry. If it's like qtcreator then maybe the parser takes some shortcoming and is able to perform better, or maybe your irony mode project isn't configured properly. Also some improvements can be made to irony mode to reduce the time it takes to transfer the completion list or such