Skip to content

Commit 1bec655

Browse files
authored
Add new client for Buf/Protocol Buffers (#4580)
* lsp-buf: add new client for protocol buffers using buf CLI * docs: add new entry for protocol buffers * Update CHANGELOG * lsp-buf: change priorities
1 parent 7980be1 commit 1bec655

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* If asm-lsp is installed, lsp-asm won't try to download it to cache store
2121
* Fix lsp-unzip on windows when unzip was found on the PATH
2222
* Fix zls wrong bin path
23+
* Add support for buf CLI ([[https://github.com/bufbuild/buf/releases/tag/v1.43.0][beta]])
2324

2425
** 9.0.0
2526
* Add language server config for QML (Qt Modeling Language) using qmlls.

clients/lsp-bufls.el

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
(require 'lsp-mode)
3232
(require 'lsp-go)
3333

34+
;; Buf Language Server
3435
(defgroup lsp-bufls nil
35-
"Configuration options for lsp-bufls."
36+
"Configuration options for Buf Language Server."
3637
:group 'lsp-mode
3738
:link '(url-lint "https://github.com/bufbuild/buf-language-server")
3839
:package-version '(lsp-mode . "9.0.0"))
@@ -60,9 +61,44 @@
6061
#'lsp-bufls-server--stdio-command)
6162
:activation-fn (lsp-activate-on "protobuf")
6263
:language-id "protobuf"
63-
:priority 0
64+
:priority -1
6465
:server-id 'bufls))
6566

67+
;; Buf CLI
68+
(defgroup lsp-buf nil
69+
"Configuration options for buf CLI."
70+
:group 'lsp-mode
71+
:link '(url-lint "https://github.com/bufbuild/buf")
72+
:package-version '(lsp-mode . "9.0.0"))
73+
74+
(defcustom lsp-buf-args `("beta" "lsp")
75+
"Arguments to pass to buf CLI."
76+
:type '(repeat string)
77+
:group 'lsp-buf
78+
:package-version '(lsp-mode . "9.0.0"))
79+
80+
(defcustom lsp-buf-path "buf"
81+
"Command to run buf CLI."
82+
:type 'string
83+
:group 'lsp-buf
84+
:package-version '(lsp-mode . "9.0.0"))
85+
86+
(defun lsp-buf--stdio-command ()
87+
"Return the command and args to start buf CLI LSP server."
88+
(let ((args (list lsp-buf-path)))
89+
(when (and (listp lsp-buf-args)
90+
(> (length lsp-buf-args) 0))
91+
(setq args (append args lsp-buf-args)))
92+
args))
93+
94+
(lsp-register-client
95+
(make-lsp-client :new-connection (lsp-stdio-connection
96+
#'lsp-buf--stdio-command)
97+
:activation-fn (lsp-activate-on "protobuf")
98+
:language-id "protobuf"
99+
:priority 0
100+
:server-id 'buf))
101+
66102
(lsp-consistency-check lsp-bufls)
67103

68104
(provide 'lsp-bufls)

docs/lsp-clients.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@
8989
"lsp-install-server": "beancount-ls",
9090
"debugger": "Not available"
9191
},
92+
{
93+
"name": "buf",
94+
"full-name": "buf CLI (Beta)",
95+
"server-name": "buf",
96+
"server-url": "https://github.com/bufbuild/buf",
97+
"installation": "npm install -g @bufbuild/buf",
98+
"installation-url": "https://buf.build/docs/installation",
99+
"debugger": "Not available"
100+
},
92101
{
93102
"name": "bufls",
94103
"full-name": "buf-language-server",

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ nav:
5555
- AWK: page/lsp-awk.md
5656
- Bash: page/lsp-bash.md
5757
- Beancount: page/lsp-beancount.md
58-
- Buf/Protocol Buffers: page/lsp-bufls.md
58+
- Buf/Protocol Buffers (Buf CLI): page/lsp-buf.md
59+
- Buf/Protocol Buffers (Buf Language Server): page/lsp-bufls.md
5960
- Camel: page/lsp-camel.md
6061
- C++ (ccls): page/lsp-ccls.md
6162
- C++ (clangd): page/lsp-clangd.md

0 commit comments

Comments
 (0)