(use-package eglot
  :pin gnu
  :commands (eglot eglot-ensure)
  :bind (:map eglot-mode-map
              ;; M-.
              ;; ([remap xref-find-definitions] . lsp-ui-peek-find-definitions)
              ;; M-?
              ;; ([remap xref-find-references] . lsp-ui-peek-find-references)
              ("C-c C-a" . eglot-code-actions)
              ;; C-M-.
              ([remap xref-find-apropos] . #'consult-eglot-symbols)
              )
  :hook (
         (eglot-managed-mode . (lambda ()
                                 (when (eglot-managed-p)
                                   (corfu-mode +1)
                                   )
                                 ))
         )
  :config
  (fset #'jsonrpc--log-event #'ignore) ;; Disable logging LSP traffic for performance boost
  (set-face-attribute 'eglot-highlight-symbol-face nil :background "#0291a1" :foreground "black")
  (set-face-attribute 'eglot-mode-line nil :inherit 'mode-line :bold nil)


  :custom
  (eglot-autoshutdown t "Shut down server when last buffer is killed.")
  (eglot-sync-connect 0 "Don't block on language server starting.")
  (eglot-send-changes-idle-time 0.1)
  )

(use-package consult-eglot
  :commands (consult-eglot-symbols)
  )

(provide 'common-lsp)