From: Stefan Bund Date: Tue, 25 Apr 2017 16:44:50 +0000 (+0200) Subject: add rags and company modules X-Git-Url: http://g0dil.de/git?p=emacs-init.git;a=commitdiff_plain;h=cd696dc0f7021e5e9efd94978d7109455aeda457 add rags and company modules --- diff --git a/.gitmodules b/.gitmodules index feca0b8..b4d7649 100644 --- a/.gitmodules +++ b/.gitmodules @@ -27,3 +27,9 @@ url = git://g0dil.de/emacsstuff.git [submodule "dtrt-indent"] path = dtrt-indent url = https://github.com/jscheid/dtrt-indent.git +[submodule "rtags"] + path = rtags + url = https://github.com/Andersbakken/rtags.git +[submodule "company-mode"] + path = company-mode + url = https://github.com/company-mode/company-mode.git diff --git a/README b/README index 2767b68..3db29a4 100644 --- a/README +++ b/README @@ -1,7 +1,13 @@ -The following packages are required: - - dash-el +Install the required ubuntu packages (see UBUNTU-PACKAGES) Create directory ~/.emacs.d/autosave + +The rtags tools have to be compiled: + + $ cd rtags + $ cmake . + $ make + +To use rtags, the rtags daemon must be started and compilation databases added \ No newline at end of file diff --git a/UBUNTU-PACKAGES b/UBUNTU-PACKAGES index 626636a..087d70a 100644 --- a/UBUNTU-PACKAGES +++ b/UBUNTU-PACKAGES @@ -2,3 +2,4 @@ dash-el pymacs python-ropemacs pyflakes +libclang-dev \ No newline at end of file diff --git a/company-mode b/company-mode new file mode 160000 index 0000000..1fe2634 --- /dev/null +++ b/company-mode @@ -0,0 +1 @@ +Subproject commit 1fe263493fc3cb3551c55bb3441fd9d7eb0c0a96 diff --git a/rtags b/rtags new file mode 160000 index 0000000..18c6aa5 --- /dev/null +++ b/rtags @@ -0,0 +1 @@ +Subproject commit 18c6aa5b00451abf9dd34df60cb5b35e7d0866a6 diff --git a/setup/company.el b/setup/company.el new file mode 100644 index 0000000..a0d0a41 --- /dev/null +++ b/setup/company.el @@ -0,0 +1,9 @@ +(let ((dir (concat (file-name-directory + (directory-file-name + (file-name-directory (or load-file-name + (when (boundp 'bytecomp-filename) bytecomp-filename) + buffer-file-name)))) + (file-name-as-directory "company-mode")))) + (add-to-list 'load-path dir)) + +(require 'company) diff --git a/setup/rtags.el b/setup/rtags.el new file mode 100644 index 0000000..0d47656 --- /dev/null +++ b/setup/rtags.el @@ -0,0 +1,54 @@ +(let ((base (file-name-directory + (directory-file-name + (file-name-directory (or load-file-name + (when (boundp 'bytecomp-filename) bytecomp-filename) + buffer-file-name)))))) + (add-to-list 'load-path (concat base + (file-name-as-directory "rtags") + (file-name-as-directory "src"))) + (add-to-list 'load-path (concat base + (file-name-as-directory "elpa") + (file-name-as-directory "company-0.9.2"))) + + (setq rtags-path (concat base + (file-name-as-directory "rtags") + (file-name-as-directory "bin")))) + +(require 'rtags) + +;; ;; ensure that we use only rtags checking +;; ;; https://github.com/Andersbakken/rtags#optional-1 +;; (defun setup-flycheck-rtags () +;; (interactive) +;; (flycheck-select-checker 'rtags) +;; ;; RTags creates more accurate overlays. +;; (setq-local flycheck-highlighting-mode nil) +;; (setq-local flycheck-check-syntax-automatically nil)) + +;; only run this if rtags is installed +(when (require 'rtags nil :noerror) + ;; make sure you have company-mode installed + (require 'company) + (define-key c-mode-base-map (kbd "\C-c.") + (function rtags-find-symbol-at-point)) + (define-key c-mode-base-map (kbd "\C-c,") + (function rtags-find-references-at-point)) + ;; disable prelude's use of C-c r, as this is the rtags keyboard prefix + ;; (define-key prelude-mode-map (kbd "C-c r") nil) + ;; install standard rtags keybindings. Do M-. on the symbol below to + ;; jump to definition and see the keybindings. + (rtags-enable-standard-keybindings) + ;; comment this out if you don't have or don't use helm + (setq rtags-use-helm t) + ;; company completion setup + (setq rtags-autostart-diagnostics t) + (rtags-diagnostics) + (setq rtags-completions-enabled t) + (push 'company-rtags company-backends) + (global-company-mode) + (define-key c-mode-base-map (kbd "") (function company-complete)) + ;; use rtags flycheck mode -- clang warnings shown inline + ;; (require 'flycheck-rtags) + ;; c-mode-common-hook is also called by c++-mode + ;; (add-hook 'c-mode-common-hook #'setup-flycheck-rtags) + )