Giter Site home page Giter Site logo

Comments (3)

To1ne avatar To1ne commented on June 14, 2024

I could, if you explain CEDET to me...

from emacs-clang-complete-async.

sgoericke avatar sgoericke commented on June 14, 2024

I managed to get ac-clang-complete-(async) to play at least with the ede-cpp-root-project stuff from CEDET. While i still use CEDET/semantic for browsing in my code i disabled it's completion features because ac-clang-complete works much better (not only faster but also accurate :-)).

Here's my configuration snippet. Note that i'm not a real good elisp-hacker so if you have hints to improve then let me know...

(when (file-directory-p "~/lisp/emacs-clang-complete-async")
  (add-to-list 'load-path "~/lisp/emacs-clang-complete-async")

  (require 'auto-complete-clang-async)
  (require 'ede)

  (when (file-exists-p "~/.emacs.d/clang-complete")
    (setq ac-clang-complete-executable "~/.emacs.d/clang-complete"))
  (when (and (string= ac-clang-complete-executable "")
             (file-exists-p "~/bin/clang-complete"))
    (setq ac-clang-complete-executable "~/bin/clang-complete" "/"))
  (when (file-directory-p "~/bin/llvm-3.3-svn/lib")
    (setenv "LD_LIBRARY_PATH" (expand-file-name "~/bin/llvm-3.3-svn/lib" "/")))


  (cond ((string-equal system-name "darkstar")
         (setq ac-cc-mode-system-includes '("/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1"
                                            "/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/x86_64-unknown-linux-gnu"
                                            "/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../include/c++/4.8.1/backward"
                                            "/usr/local/include"
                                            "/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include"
                                            "/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include-fixed"
                                            "/usr/include")))

        ((string-equal system-name "hostname-at-work")
         (setq ac-cc-mode-system-includes '("/usr/include/c++/4.4"
                                            "/usr/include/c++/4.4/x86_64-linux-gnu"
                                            "/usr/include/c++/4.4/backward"
                                            "/usr/local/include"
                                            "/usr/lib/gcc/x86_64-linux-gnu/4.4.5/include"
                                            "/usr/lib/gcc/x86_64-linux-gnu/4.4.5/include-fixed"
                                            "/usr/include")))
        (t nil))

  (defmethod ede-include-path ((this ede-cpp-root-project))
    "Get the system include path used by ede-project."
    (oref this include-path))

  (defvar ac-cc-mode-setup-cflags-hook nil
    "This hooks are run after the ede and system-includes are set")

  (defun ac-cc-mode-setup-from-ede-project ()
    "Setup ac-clang-completion based on ede-cpp-root-project"
    (ac-config-default)

    (when (ede-current-project)
      (let ((prj (ede-current-project))
            (root (ede-project-root-directory (ede-current-project)))
            (cxxflags))

        ;;---------------------------------------------------------------------------------------------------------------
        ;; first: parse the ede :spp-table.
        ;; second: parse the ede :include dirs
        ;; third: parse the ede :system-include dirs
        ;; finally: add the ac-cc-mode-system-includes
        ;;---------------------------------------------------------------------------------------------------------------
        (setq cxxflags (append
                        (mapcar (lambda (def) (let ((sym (car def))
                                                    (val (cdr def)))
                                                (cond ((and (stringp val)
                                                            (not (zerop (length val))))
                                                       (format "-D%s=\"%s\"" sym val))
                                                      ((numberp val)
                                                       (format "-D%s=%s" sym (number-to-string val)))
                                                      (t
                                                       (concat "-D" sym)))))
                                (ede-preprocessor-map prj))
                        (mapcar (lambda (dir) (format "-I%s%s" root (substring dir 1 nil)))
                                (ede-include-path prj))
                        (mapcar (lambda (dir) (format "-I%s" dir))
                                (ede-system-include-path prj))
                        (mapcar (lambda (dir) (format "-I%s" dir)) ac-cc-mode-system-includes)))


        (setq ac-clang-cflags cxxflags))

      (setq ac-sources '(ac-source-clang-async))

      (run-hooks 'ac-cc-mode-setup-hook)
      (ac-clang-launch-completion-process)

      (local-set-key (kbd "C-<tab>") 'ac-complete-clang-async)))

  (add-hook 'c-mode-common-hook 'ac-cc-mode-setup-from-ede-project)
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)
)

Sample project.el:

(ede-cpp-root-project "your-proj"
                      :name "your-proj"
                      :file "~/projects/your-proj/Makefile"
                      :include-path '("/build"
                                      "/first/include"
                                      "/second/include")
                      :system-include-path '("/usr/include/boost")
                      :spp-table '(("DEBUG" . "")
                                   ("SYMBOL" . "")
                                   ("ZERO" . 0)
                                   ("ONE" . 1)
                                   ("PROJECT_NAME" . "your-proj")
                                   ("PROJECT_VERSION" . "1.0.0")))

(defun project-add-clang-cflags ()
  (setq ac-clang-cflags (append '("-std=c++11" "-Wall" "-Wextra" "-pedantic" "-D_REENTRANT") ac-clang-cflags)))
(add-hook 'ac-cc-mode-setup-cflags-hook 'project-add-clang-cflags)

from emacs-clang-complete-async.

maindoor avatar maindoor commented on June 14, 2024

The ac-clang-cflags setup you have here is unique from what I have. Can you ac-complete the library ?

from emacs-clang-complete-async.

Related Issues (20)

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.