 (add-to-list 'cff-source-regexps '("\\.m$" . (lambda (base) (concat base ".m"))))
 (add-to-list 'cff-source-regexps '("\\.mm$" . (lambda (base) (concat base ".mm"))))
 
-(defun my-goto-symbol ()
-  (interactive)
-  (save-buffer)
-  (deactivate-mark)
-  (xref-push-marker-stack)
-  (or (and use-rtags
-           (rtags-is-indexed)
-           (rtags-find-symbol-at-point))
-      (dumb-jump-go)))
-
-(with-eval-after-load 'cc-mode
-  (fset 'c-indent-region 'clang-format-region)
-  (bind-keys :map c-mode-base-map
-             ("<C-tab>" . company-complete)
-             ("M-." . my-goto-symbol)
-             ("M-," . xref-pop-marker-stack)
-             ("C-M-\\" . clang-format-region)
-             ("C-i" . clang-format)
-             ("C-." . my-imenu)
-             ("M-o" . cff-find-other-file))
-  (when use-rtags
-    (bind-key "M-?" 'rtags-display-summary c-mode-base-map)))
+(require 'cquery)
+(setq cquery-executable (expand-file-name "~/cquery/build/release/bin/cquery"))   ;; https://github.com/cquery-project/cquery/wiki/Getting-started
+(setq cquery-extra-init-params '(:index (:comments 2) :cacheFormat "msgpack"))
+(setq cquery-sem-highlight-method nil)   ;; 'font-lock)
+
+(require 'lsp-mode)
+(setq lsp-highlight-symbol-at-point nil
+      lsp-enable-flycheck nil
+      lsp-enable-indentation nil
+      lsp-enable-eldoc nil)
+
+(add-hook 'c-mode-hook #'lsp-cquery-enable)
+(add-hook 'c++-mode-hook #'lsp-cquery-enable)
+
+(require 'lsp-imenu)
+(add-hook 'lsp-after-open-hook 'lsp-enable-imenu)
+
+(fset 'c-indent-region 'clang-format-region)
+
+(bind-keys :map c-mode-base-map
+           ("<C-tab>" . company-complete)
+           ("C-M-\\" . clang-format-region)
+           ("C-i" . clang-format)
+           ("C-." . helm-imenu)
+           ("M-o" . cff-find-other-file))
 
 (setq inf-clojure-program '("localhost" . 9999))   ;; "planck"
 (add-hook 'clojure-mode-hook 'inf-clojure-minor-mode)

                    nil
                    :background "gray85")   ;; terminal

(when use-rtags
  (set-face-attribute 'rtags-skippedline nil :background "gray70")
  (set-face-attribute 'rtags-warnline nil :background "#ccccff")
  (set-face-attribute 'rtags-errline nil :background "#eeb0b0"))

(set-face-attribute 'js2-external-variable
                    nil
                    :foreground "red")

(setq compile-command "ninja")

(defun my-c-mode-common-hook ()
  (setq-local fill-column 90))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

