; start package.el with emacs
(require 'package)
; add MELPA to repository list
(add-to-list 'package-archives '("melpa" . "http://elpa.emacs-china.org/melpa/"))
; initialize package.el
(package-initialize)
;;(when (not package-archive-contents)
;; (package-refresh-contents))
;;(unless (package-installed-p 'use-package)
;; (package-install 'use-package))
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
; start auto-complete with emacs
(require 'auto-complete)
; do default config for auto-complete
(require 'auto-complete-config)
(ac-config-default)
; start yasnippet with emacs
(require 'yasnippet)
(yas-global-mode 1)
; let's define a function which initializes auto-complete-c-headers and gets called for c/c++ hooks
(defun my:ac-c-header-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(setq achead:include-directories
(append '("/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../include/c++/6.3.0"
"/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../include/c++/6.3.0/x86_64-pc-linux-gnu"
"/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward"
"/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include"
"/usr/local/include"
"/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include-fixed"
"/usr/include")
achead:include-directories))
;(add-to-list 'achead:include-directories '"/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../include/c++/6.3.0
;/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../include/c++/6.3.0/x86_64-pc-linux-gnu
;/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
;/usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include
;/usr/local/include
; /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/include-fixed
; /usr/include
;")
)
; now let's call this function from c/c++ hooks
(add-hook 'c++-mode-hook 'my:ac-c-header-init)
(add-hook 'c-mode-hook 'my:ac-c-header-init)
; Fix iedit bug in Mac
(define-key global-map (kbd "C-c ;") 'iedit-mode)
; start flymake-google-cpplint-load
; let's define a function for flymake initialization
(defun my:flymake-google-init ()
(require 'flymake-google-cpplint)
(custom-set-variables
'(flymake-google-cpplint-command "/usr/local/bin/cpplint"))
(flymake-google-cpplint-load)
)
(add-hook 'c-mode-hook 'my:flymake-google-init)
(add-hook 'c++-mode-hook 'my:flymake-google-init)
; start google-c-style with emacs
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)
(add-hook 'c-mode-common-hook 'google-make-newline-indent)
; turn on Semantic
(semantic-mode 1)
; let's define a function which adds semantic as a suggestion backend to auto complete
; and hook this function to c-mode-common-hook
(defun my:add-semantic-to-autocomplete()
(add-to-list 'ac-sources 'ac-source-semantic)
)
(add-hook 'c-mode-common-hook 'my:add-semantic-to-autocomplete)
; turn on ede mode
(global-ede-mode 1)
; create a project for our program.
;(ede-cpp-root-project "my project" :file "/home/ganhengtong/practise/reverse_list/reverse_list.cpp"
; :include-path '("/../include"))
; you can use system-include-path for setting up the system header file locations.
; turn on automatic reparsing of open buffers in semantic
(global-semantic-idle-scheduler-mode 1)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
(quote
(yasnippet use-package google-c-style auto-complete))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;(require 'sr-speedbar)
;(setq speedbar-show-unknown-files t)
;(setq sr-speedbar-width 30)
;(setq sr-speedbar-right-side nil)
;(global-set-key (kbd "") (lambda()
; (interactive)
; (set-frame-width (selected-frame) 150)
; (sr-speedbar-toggle)))
(global-linum-mode 'linum-mode)
660

被折叠的 条评论
为什么被折叠?



