(require 'package) (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) (not (gnutls-available-p)))) (proto (if no-ssl "http" "https"))) (when no-ssl (warn "\ Your version of Emacs does not support SSL connections, which is unsafe because it allows man-in-the-middle attacks. There are two things you can do about this warning: 1. Install an Emacs version that does support SSL and be safe. 2. Remove this warning from your init file so you won't see it again.")) ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t) (add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t) (when (< emacs-major-version 24) ;; For important compatibility libraries like cl-lib (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))))) (package-initialize) (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. '(custom-enabled-themes (quote (tango-dark))) '(inhibit-startup-screen t) '(package-selected-packages (quote (rtags helm-gtags flycheck company)))) (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 'rtags) (require 'company) (require 'helm-rtags) (require 'flycheck-rtags) (require 'company-rtags) ;;Helm-rtags (setq rtags-display-result-backend 'helm) ;;Code completition (setq rtags-completions-enabled t) (push 'company-rtags company-backends) (global-company-mode) (define-key c-mode-base-map (kbd "") (function company-complete)) (add-hook 'c-mode-hook 'rtags-start-process-unless-running) (add-hook 'c++-mode-hook 'rtags-start-process-unless-running) (add-hook 'objc-mode-hook 'rtags-start-process-unless-running) ;;Rtags-flycheck (setq rtags-autostart-diagnostics t) (defun my-flycheck-rtags-setup () (flycheck-select-checker 'rtags) (setq-local flycheck-highlighting-mode nil) ;; RTags creates more accurate overlays. (setq-local flycheck-check-syntax-automatically nil)) (add-hook 'c-mode-hook #'my-flycheck-rtags-setup) (add-hook 'c++-mode-hook #'my-flycheck-rtags-setup) (add-hook 'objc-mode-hook #'my-flycheck-rtags-setup) ;;Rtags (defun use-rtags (&optional useFileManager) (and (rtags-executable-find "rc") (cond ((not (gtags-get-rootpath)) t) ((and (not (eq major-mode 'c++-mode)) (not (eq major-mode 'c-mode))) (rtags-has-filemanager)) (useFileManager (rtags-has-filemanager)) (t (rtags-is-indexed))))) (defun tags-find-symbol-at-point (&optional prefix) (interactive "P") (if (and (not (rtags-find-symbol-at-point prefix)) rtags-last-request-not-indexed) (gtags-find-tag))) (defun tags-find-references-at-point (&optional prefix) (interactive "P") (if (and (not (rtags-find-references-at-point prefix)) rtags-last-request-not-indexed) (gtags-find-rtag))) (defun tags-find-symbol () (interactive) (call-interactively (if (use-rtags) 'rtags-find-symbol 'gtags-find-symbol))) (defun tags-find-references () (interactive) (call-interactively (if (use-rtags) 'rtags-find-references 'gtags-find-rtag))) (defun tags-find-file () (interactive) (call-interactively (if (use-rtags t) 'rtags-find-file 'gtags-find-file))) (defun tags-imenu () (interactive) (call-interactively (if (use-rtags t) 'rtags-imenu 'idomenu))) (define-key global-map (kbd "M-.") (function tags-find-symbol-at-point)) (define-key global-map (kbd "M-,") (function tags-find-references-at-point)) (define-key global-map (kbd "M-;") (function tags-find-file)) (define-key global-map (kbd "C-.") (function tags-find-symbol)) (define-key global-map (kbd "C-,") (function tags-find-references)) (define-key global-map (kbd "C-<") (function rtags-find-virtuals-at-point)) (define-key global-map (kbd "M-i") (function tags-imenu))