3 ;---------------------------------------------------------------------------------------
7 (setenv "LD_LIBRARY_PATH" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/")
9 ;( add-to-list 'load-path (expand-file-name "~/.emacs.d/irony-mode/elisp/"))
11 (add-hook 'c++-mode-hook 'irony-mode)
12 (add-hook 'c-mode-hook 'irony-mode)
13 (add-hook 'objc-mode-hook 'irony-mode)
15 ;; replace the `completion-at-point' and `complete-symbol' bindings in
16 ;; irony-mode's buffers by irony-mode's function
17 (defun my-irony-mode-hook ()
18 (define-key irony-mode-map [remap completion-at-point]
19 'irony-completion-at-point-async)
20 (define-key irony-mode-map [remap complete-symbol]
21 'irony-completion-at-point-async))
22 (add-hook 'irony-mode-hook 'my-irony-mode-hook)
23 (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
26 ;---------------------------------------------------------------------------------------
27 ;; auto-complete, yasnippt, auto-complete-c-headers, iedit
29 ;; c/c++ auto-complete, yasnippet, auto-complet-c-headers
30 ;;https://www.youtube.com/watch?v=HTUE03LnaXA&list=PL-mFLc7R_MJet8ItKipCtYc7PWoS5KTfM
31 (require 'auto-complete)
32 (require 'auto-complete-config)
38 ;; auto-complete-c-headers
39 (defun my:ac-c-header-init ()
40 (require 'auto-complete-c-headers)
41 (add-to-list 'ac-sources 'ac-source-c-headers)
42 (add-to-list 'achead:include-directories "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include")
44 (add-hook 'c++-mode-hook 'my:ac-c-header-init)
45 (add-hook 'c-mode-hook 'my:ac-c-header-init)
47 ;;; iedit, fix iedit bug in Mac, C-c ; to trigger multiple cursor edit
48 (define-key global-map (kbd "C-c ;") 'iedit-mode)
51 ;; flymake-google-cpplint-load
52 ;; define a function for flymake initialization
53 ;(defun my:flymake-google-init ()
54 ; (require 'flymake-google-cpplint)
55 ; (custom-set-variables
56 ; '(flymake-google-cpplint-command "/usr/local/bin/cpplint"))
57 ; (flymake-google-cpplint-load)
59 ;(add-hook 'c-mode-hook 'my:flymake-google-init)
60 ;(add-hook 'c++-mode-hook 'my:flymake-google-init)
62 ;; start google-c-style with emacs
63 ;(require 'google-c-style)
64 ;(add-hook 'c-mode-hook 'google-set-c-style)
65 ;(add-hook 'c++-mode-hook 'google-make-newline-indent)
69 ;---------------------------------------------------------------------------------------
73 ;; let's define a function which adds semantic as a suggestion backend to auto complete
74 (defun my:add-semantic-to-autocomplete()
75 (add-to-list 'ac-sources 'ac-source-semantic)
77 (add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
81 ;(ede-cpp-root-project "my project" :file "~/demos/my_program/src/main.cpp"
82 ; :include-path '("/../my_inc"))
83 ;; you can use system-include-path for setting up the system header file locations.
85 ;; turn on automatic reparsing of open buffers in semantic
86 (global-semantic-idle-scheduler-mode 1)
87 (global-semantic-stickyfunc-mode 1)