Skip to content

Commit

Permalink
lsp-buf: add new client for protocol buffers using buf CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki committed Oct 7, 2024
1 parent 9575fd2 commit 2666363
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion clients/lsp-bufls.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
(require 'lsp-mode)
(require 'lsp-go)

;; Buf Language Server
(defgroup lsp-bufls nil
"Configuration options for lsp-bufls."
"Configuration options for Buf Language Server."
:group 'lsp-mode
:link '(url-lint "https://github.com/bufbuild/buf-language-server")
:package-version '(lsp-mode . "9.0.0"))
Expand Down Expand Up @@ -63,6 +64,41 @@
:priority 0
:server-id 'bufls))

;; Buf CLI
(defgroup lsp-buf nil
"Configuration options for buf CLI."
:group 'lsp-mode
:link '(url-lint "https://github.com/bufbuild/buf")
:package-version '(lsp-mode . "9.0.0"))

(defcustom lsp-buf-args `("beta" "lsp")
"Arguments to pass to buf CLI."
:type '(repeat string)
:group 'lsp-buf
:package-version '(lsp-mode . "9.0.0"))

(defcustom lsp-buf-path "buf"
"Command to run buf CLI."
:type 'string
:group 'lsp-buf
:package-version '(lsp-mode . "9.0.0"))

(defun lsp-buf--stdio-command ()
"Return the command and args to start buf CLI LSP server."
(let ((args (list lsp-buf-path)))
(when (and (listp lsp-buf-args)
(> (length lsp-buf-args) 0))
(setq args (append args lsp-buf-args)))
args))

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
#'lsp-buf--stdio-command)
:activation-fn (lsp-activate-on "protobuf")
:language-id "protobuf"
:priority -1
:server-id 'buf))

(lsp-consistency-check lsp-bufls)

(provide 'lsp-bufls)
Expand Down

0 comments on commit 2666363

Please sign in to comment.