;;;; C, C++ Development ;; Rtags (defvar rtags-completions-enabled) (setq rtags-completions-enabled nil) (defun my-flycheck-irony-setup () "Setup irony checker." (require 'flycheck-irony) (flycheck-select-checker 'irony)) (add-hook 'c-mode-hook #'my-flycheck-irony-setup) (add-hook 'c++-mode-hook #'my-flycheck-irony-setup) (add-hook 'objc-mode-hook #'my-flycheck-irony-setup) ;; completion (add-hook 'irony-mode-hook #'irony-cdb-autosetup-compile-options) (use-package flycheck-clang-analyzer :after flycheck-irony :config (flycheck-clang-analyzer-setup)) ;; show docs at point ;; (require 'xah-lookup) ;; Uncomment the below line to use eww (Emacs Web Wowser) ;; (setq xah-lookup-browser-function 'eww) (autoload 'xah-lookup-word-on-internet "xah-lookup") (use-package xah-lookup :defer t) (defvar xah-lookup-browser-function) (defun xah-lookup-cppreference (&optional word) "Lookup definition of current WORD or text selection in URL." (interactive) (xah-lookup-word-on-internet word ;; Use � as a placeholder in the query URL. "http://en.cppreference.com/mwiki/index.php?search=�" xah-lookup-browser-function)) ;; (require 'cc-mode) ;; Add shortcut for c++-mode ;; Another example with http://www.boost.org (defun xah-lookup-boost (&optional word) "Lookup definition of current WORD or text selection in URL." (interactive) (xah-lookup-word-on-internet word "https://cse.google.com/cse?cx=011577717147771266991:jigzgqluebe&q=�" xah-lookup-browser-function)) (defvar c++-mode-map) (defvar c-mode-map) (defun xah-c++-setup () "Setup xah-lookups for c++-mode." (require 'cc-mode) (define-key c++-mode-map (kbd "C-c b") #'xah-lookup-boost) (define-key c++-mode-map (kbd "C-c d") #'xah-lookup-cppreference)) (add-hook 'c++-mode-hook #'xah-c++-setup) (declare-function rtags-eldoc "ext:rtags") (defun my-cc-mode-hook () "My hook for c & c++ modes." (require 'cc-mode) (local-set-key (kbd "C-c C-t") #'rtags-symbol-type) (local-set-key (kbd "C-c C-d") #'rtags-print-symbol-info) (local-set-key (kbd "M-.") (lambda () (interactive) (xref-push-marker-stack) (rtags-find-symbol-at-point))) (local-set-key (kbd "M-?") (lambda () (interactive) (xref-push-marker-stack) (rtags-find-references-at-point))) (local-set-key (kbd "C-'") #'company-irony-c-headers) (rtags-start-process-unless-running) (setq-local eldoc-documentation-function #'rtags-eldoc) (eldoc-mode +1) (irony-mode) (add-to-list 'company-backends '(company-irony company-irony-c-headers))) (add-hook 'c++-mode-hook #'my-cc-mode-hook) (add-hook 'c-mode-hook #'my-cc-mode-hook) ;; Semantic ;; (require 'cc-mode) ;; (require 'semantic) ;; (global-semanticdb-minor-mode 1) ;; (global-semantic-idle-scheduler-mode 1) ;; (semantic-mode 1) ;; (global-set-key (kbd "C-c C-j") 'semantic-ia-fast-jump) ;; (global-semantic-idle-summary-mode 1) (use-package cmake-ide :defer 2 :config (cmake-ide-setup)) ;; Add cmake listfile names to the mode list. (setq auto-mode-alist (append '(("CMakeLists\\.txt\\'" . cmake-mode)) '(("\\.cmake\\'" . cmake-mode)) auto-mode-alist)) (defun my-cmake-font-lock () "Activate font lock for cmake." (require 'cmake-font-lock) (cmake-font-lock-activate)) (add-hook 'cmake-mode-hook #'my-cmake-font-lock) (defvar company-c-headers-path-user) (defun company-set-c-headers-user-path () "Set path for selected directory with project headers." (interactive) (let ((dir (expand-file-name (read-directory-name "Select project directory:" default-directory)))) (setq company-c-headers-path-user (list (concat dir "/include")))))