A Emacs Lisp library for implementing clients for servers using Microsoft's Language Server Protocol.
The library is designed to integrate with existing Emacs IDE frameworks (completion-at-point, xref (beginning with Emacs 25.1), flycheck, etc).
This package is still under development, and is not recommended for daily use.
Clone this repository to a suitable path, and add
(add-to-list 'load-path "<path to emacs-lsp>")
(with-eval-after-load 'lsp-mode
(require 'lsp-flycheck))
(require 'lsp-mode)
(lsp-define-stdio-client
;; This can be a symbol of your choosing. It will be used as a the
;; prefix for a dynamically generated function "-enable"; in this
;; case: lsp-prog-major-mode-enable
lsp-prog-major-mode
"language-id"
;; This will be used to report a project's root directory to the LSP
;; server.
#'default-directory
;; This is the command to start the LSP server. It may either be a
;; string containing the path of the command, or a list wherein the
;; car is a string containing the path of the command, and the cdr
;; are arguments to that command.
'("/my/lsp/server" "and" "args"))
;; Here we'll add the function that was dynamically generated by the
;; call to lsp-define-stdio-client to the major-mode hook of the
;; language we want to run it under.
;;
;; This function will turn lsp-mode on and call the command given to
;; start the LSP server.
(add-hook 'prog-major-mode #'lsp-prog-major-mode-enable)
to your .emacs, where prog-major-mode
is the hook variable for a supported
programming language major mode.
Support for programming languages is provided by the following packages:
See API docs
Completion is provided with the native completion-at-point
(C-M-i),
and should therefore work with any other completion backend.
Hover support is provided with eldoc
, which should be enabled automatically.
Use M - . (xref-find-definition
)
to find the definition for the symbol under point.
Use M - ? (xref-find-references
)
to find the references to the symbol under point.