(require 'common-lsp)
(require 'util-tree-sitter)

;; To generate a compilation database for the language server, run:
;;   intercept-build13 --append make
;;
;; Output: compile_commands.json

(defun use-clangd ()
  "Configure eglot to use clangd."
  (eglot-ensure)
  (defclass my/eglot-c (eglot-lsp-server) ()
    :documentation
    "Own eglot server class.")

  (add-to-list 'eglot-server-programs
               '(cc-mode . (my/eglot-c "clangd13")))

  (tree-sitter-hl-mode)
  )

(use-package cc-mode
  ;; c-mode c++-mode objc-mode java-mode idl-mode pike-mode awk-mode
  :commands (c-mode c++-mode)
  :pin manual
  :hook (
         (c-mode . use-clangd)
         (c++-mode . use-clangd)
         )
  )

(provide 'lang-c)
