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

irony-mode with company-irony in c source files #268

Open hailiyouyu opened 8 years ago

hailiyouyu commented 8 years ago

I set up irony-mode with company-irony in emacs and it works well with C++. But when I type in c files, it has no hints about any functions.

My settings of irony-mode and company-irony is:

(require 'irony)
(require 'company-irony)
(require 'company-irony-c-headers)

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

(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))

(eval-after-load 'company
  '(add-to-list 'company-backends '(company-irony-c-headers company-irony)))

My situation is the same with issue #246, and I have tried this command:

~/.emacs.d/irony/bin/irony-server complete /tmp/issue-246.c 5 1 <<'EOF' | grep printf
EOF

It outputs:

execute: Command{action=Command::Complete, file='/tmp/ac.c', dir='', line=5, column=1, flags=[], unsavedFiles.count=0, opt=off}

My OS environment: Mac OS X 10.11.2, Emacs 24.5.1, and I use

brew install llvm --with-clang

to install clang-3.6.2 I don't understand that why it works with C++ and not with C. Any advice is welcome.

Hailiyouyu

hailiyouyu commented 8 years ago

when I try this, I get some output:

.emacs.d/irony/bin/irony-server complete /tmp/ac.c 5 1 <<'EOF' | grep int
EOF

execute: Command{action=Command::Complete, file='/tmp/ac.c', dir='', line=5, column=1, flags=[], unsavedFiles.count=0, opt=off}
("int" 50 "" "" "int" 3 (""))

I tried turn on company-irony mode manually in Emacs, It shows some keywords like char, const, double, enum and some internal macros like amd64, APPLE, clang, clang_major__ etc.

It seems that irony-company can find the c library. But when I use company-mode only, completion is OK.