forked from FG42/FG42
Create the a generic fn to let lisp modules override the language server behaviour
This commit is contained in:
parent
a8f94e667f
commit
01e9fbdf46
|
@ -23,7 +23,8 @@
|
|||
;;; Code:
|
||||
(eval-when-compile
|
||||
(require 'fpkg)
|
||||
(require 'fg42/config))
|
||||
(require 'fg42/config)
|
||||
(require 'cl-lib))
|
||||
|
||||
|
||||
;; Language Servers and friends
|
||||
|
@ -32,6 +33,7 @@
|
|||
shipped with Emacs."
|
||||
:commands eglot-ensure)
|
||||
|
||||
|
||||
(use! eldoc-box
|
||||
"View eldoc stuff in a frame."
|
||||
:commands eldoc-box-hover-mode
|
||||
|
@ -43,6 +45,20 @@ shipped with Emacs."
|
|||
:init (setq markdown-command "multimarkdown"))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(cl-defgeneric fg42/setup-lang-server-for (mode)
|
||||
"Setup a language server for the given MODE.
|
||||
Other Nix modules can specialize this function to alter
|
||||
the default behaviour. For example for C++:
|
||||
|
||||
\(cl-defmethod fg42/setup-lang-server-for ((mode (eql c-ts-mode)))
|
||||
;; Do whatever you want here
|
||||
)
|
||||
|
||||
The default implementation sets up Eglot."
|
||||
(eglot-ensure))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun fg42/ensure-lang-server ()
|
||||
"Setup the appropriate language server for the current buffer.
|
||||
|
@ -50,16 +66,14 @@ This function is supposed to be run using a hook.
|
|||
|
||||
For example:
|
||||
|
||||
(add-hook 'foo-mode-hook #'fg42/enruse-lang-server)
|
||||
\(add-hook 'foo-mode-hook #'fg42/enruse-lang-server)
|
||||
|
||||
or via `use!' `:hook'."
|
||||
(interactive)
|
||||
;; TODO: Configure LSP here as an alternative here by looking at
|
||||
;; the configs in `fg42/config'
|
||||
|
||||
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
|
||||
(eglot-ensure))
|
||||
|
||||
(fg42/setup-lang-server-for major-mode))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Reference in New Issue