GithubHelp home page GithubHelp logo

classicvalues / auto-complete-clang Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brianjcj/auto-complete-clang

0.0 1.0 0.0 272 KB

auto complete source for clang. AC+Clang+Yasnippet!

Emacs Lisp 100.00%

auto-complete-clang's Introduction

Introduction

The AC sources for Clang. Combine the power of AC, Clang and Yasnippet.

if you don’t have Yasnippet, I recommend you install one. if you don’t want to install Yasnippet, you can try snippet.el instead. if you don’t install any of them, this script will still work for you any way.

Install

Here is my configurations for AC and auto-complete-clang for your reference.

(add-to-list 'load-path (concat myoptdir "AC"))
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories (concat myoptdir "AC/ac-dict"))

(require 'auto-complete-clang)

(setq ac-auto-start nil)
(setq ac-quick-help-delay 0.5)
;; (ac-set-trigger-key "TAB")
;; (define-key ac-mode-map  [(control tab)] 'auto-complete)
(define-key ac-mode-map  [(control tab)] 'auto-complete)
(defun my-ac-config ()
  (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
  (add-hook 'emacs-lisp-mode-hook 'ac-emacs-lisp-mode-setup)
  ;; (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
  (add-hook 'ruby-mode-hook 'ac-ruby-mode-setup)
  (add-hook 'css-mode-hook 'ac-css-mode-setup)
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)
  (global-auto-complete-mode t))
(defun my-ac-cc-mode-setup ()
  (setq ac-sources (append '(ac-source-clang ac-source-yasnippet) ac-sources)))
(add-hook 'c-mode-common-hook 'my-ac-cc-mode-setup)
;; ac-source-gtags
(my-ac-config)

Screenshot

Refer to the screenshot folder.

Note

  • Now clang is able to parse codes from standard output. Saving the file before parsing is no longer necessary. So the default value of ac-clang-auto-save is now changed to nil. If you still use the old version of clang and this may not work for you. In this case, you can change the ac-clang-auto-save back to t.

Troubleshooting

  • clang fails to find the standard inlcude files?

    It is because clang’s include file search path is not correct. Here is the solution:

    • find out the include file search pathes of your g++:
      echo "" | g++ -v -x c++ -E -
              

      you wil get something like this:

      #include "..." search starts here:
      #include <...> search starts here:
       /usr/include/c++/4.6
       /usr/include/c++/4.6/x86_64-linux-gnu/.
       /usr/include/c++/4.6/backward
       /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include
       /usr/local/include
       /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed
       /usr/include/x86_64-linux-gnu
       /usr/include
      End of search list.
              
    • setting the ac-clang-flags to include these default include pathes. e.g.,
      (setq ac-clang-flags
            (mapcar (lambda (item)(concat "-I" item))
                    (split-string
                     "
       /usr/include/c++/4.6
       /usr/include/c++/4.6/x86_64-linux-gnu/.
       /usr/include/c++/4.6/backward
       /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include
       /usr/local/include
       /usr/lib/gcc/x86_64-linux-gnu/4.6.1/include-fixed
       /usr/include/x86_64-linux-gnu
       /usr/include
      "
                     )))
              

    You can put it into your .emacs file.

    Then code completion works just fine!

auto-complete-clang's People

Contributors

brianjcj avatar sindikat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.