               (define-key deft-mode-map (kbd "<C-return>") #'deft-new-file)
               (define-key deft-mode-map (kbd "<C-backspace>") #'deft-filter-clear))))
 
+;; polyglot language server interface
+(use-package eglot
+  :general
+  (:keymaps 'eglot-mode-map "M-RET"  #'eglot-code-actions)
+  :hook ((c-mode . eglot-ensure)
+         (c++-mode . eglot-ensure))
+  :init
+  (setq eglot-ignored-server-capabilites '( :hoverProvider :documentHighlightProvider)
+        eglot-events-buffer-size 0)     ;; events are verbose, so disable
+  :config
+  ;; project-find-function which uses projectile methods to find
+  ;; the projectile project associated with a directory.
+  ;; If projectile not loaded, or directory is not in a project,
+  ;; hopefully returns nil.
+  (defun me:project-finder (dir)
+    (if (boundp 'projectile-project-root-cache)
+        (let ((root (projectile-project-root dir)))
+          (and root (cons 'transient root)))))
+  (add-to-list 'project-find-functions #'me:project-finder)
+
+  ;; augment the eglot-initialization-options defined by eglot-cquery
+  ;; Store cache in ~/.cache/emacs/cquery-cache.d/<hash-of-project-path>
+  ;; Other options are straightforward
+  (cl-defmethod eglot-initialization-options :around ((server eglot-cquery))
+    (let* ((root (expand-file-name (car (project-roots (eglot--project server)))))
+           (root-hashed (replace-regexp-in-string "\/" "!" (directory-file-name root) t t nil 1))
+           (cache-path (expand-file-name "cquery-cache.d" me:emacs-cache-directory))
+           (cache (expand-file-name root-hashed cache-path)))
+      (append (list :cacheDirectory (file-name-as-directory cache)
+                    :index '(:comments 2)
+                    :threads 2
+                    :cacheFormat "msgpack")
+              (cl-call-next-method))))
+  (add-to-list 'eglot-server-programs '((c++-mode c-mode) eglot-cquery "~/extern/cquery-dev/build/release/bin/cquery")))
+
 (use-package company
   :general
     ("s-d"        #'company-complete)

  (add-hook 'c-mode-hook #'counsel-gtags-mode)
  (add-hook 'c++-mode-hook #'counsel-gtags-mode)
  :config)

(use-package flycheck
  :init

           '(dired-mode
             finder-mode
             image-dired-thumbnail-mode
             cquery-tree-mode
             paradox-menu-mode))
    (add-to-list 'evil-emacs-state-modes mode))

