GithubHelp home page GithubHelp logo

classicvalues / emacs-clang-complete-async Goto Github PK

View Code? Open in Web Editor NEW

This project forked from golevka/emacs-clang-complete-async

0.0 0.0 0.0 4.5 MB

An emacs plugin to complete C and C++ code using libclang

Emacs Lisp 53.49% C 46.51%

emacs-clang-complete-async's Introduction

Introduction

emacs-clang-complete-async is an emacs extension to complete C and C++ code, it uses libclang to parse the source code on the fly and provides completion candidates to auto-complete (http://cx4a.org/software/auto-complete).

https://github.com/Golevka/emacs-clang-complete-async/raw/master/screenshots/showcase.png

This extension is not implemented in pure elisp, it is made up of a client part (auto-complete-clang-async.el, written in elisp) and a server part (clang-complete binary, written in C), they work cooperately in asynchonous client-server fashion.

Experimental Feature - On the fly syntax checking

An experimental feature is added to this branch — running ac-clang-syntax-check to highlight errornous lines in your souce code.

https://github.com/Golevka/emacs-clang-complete-async/raw/master/screenshots/syntax_check.png

Setup

Compile the server part (clang-complete binary) first, by executing make. The build process uses llvm-config to determine the location of libclang and the appropriate compile flags to use. If llvm-config is not in your path or has a different name, you can pass make an LLVM_CONFIG argument, e.g. make LLVM_CONFIG=llvm-config-3.4.

Copy auto-complete-clang-async.el and the previously compiled clang-complete executable to ~/.emacs.d/, and add the following code to your .emacs file.

(require 'auto-complete-clang-async)

(defun ac-cc-mode-setup ()
  (setq ac-clang-complete-executable "~/.emacs.d/clang-complete")
  (setq ac-sources '(ac-source-clang-async))
  (ac-clang-launch-completion-process)
)

(defun my-ac-config ()
  (add-hook 'c-mode-common-hook 'ac-cc-mode-setup)
  (add-hook 'auto-complete-mode-hook 'ac-common-setup)
  (global-auto-complete-mode t))

(my-ac-config)

Now emacs-clang-complete-async will show completion candidates automatically when you type as usual in C or C++ mode.

Usage

This extension fades in emacs C/C++ mode and provides candidates automatically while you typing code, if you want to add parameters to clang (libclang, actually), such as -Ipath, just call ac-clang-set-cflags interactively or set the value of ac-clang-flags in .emacs or .dir-locals.el, maybe you need an explicit call to ac-clang-update-cmdlineargs to make changes to cflags take effect, which is a niggling part of it T T

Note

Most code of auto-complete-clang-async.el is taken from brainjcj’s auto-complete-clang.el, The only difference between this one and bj’s ac-clang-complete is: This one interacts with a process geared with libclang to retrieve completion candidates instead of calling clang process, which is way slower, and the asynchonous nature of our C-S based working model won’t block the editor while parsing source code and resolving completion candidates, which provides a “smooth” coding experience.

emacs-clang-complete-async's People

Contributors

golevka avatar joonhwan avatar maxc01 avatar nicolamontecchio avatar to1ne avatar toojays avatar wentasah avatar yaruopooner avatar yasuyk 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.