Skip to content

Commit 9bafffa

Browse files
feat(buf_ls): buf-config filetype #4384
The next release of `buf` will include LSP features that include support for buf config files. This follows the approach that other LSPs follow for specifying custom filetypes (a comment + adding that custom filetype to filetypes).
1 parent c588db3 commit 9bafffa

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lsp/buf_ls.lua

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,31 @@
44
--- buf lsp included in the cli itself
55
---
66
--- buf lsp is a Protobuf language server compatible with Buf modules and workspaces
7+
---
8+
--- buf lsp also supports Buf configuration files. The `buf-config` filetype is not
9+
--- detected automatically; register it manually (see below) or override the filetypes:
10+
---
11+
--- ```lua
12+
--- vim.filetype.add({
13+
--- filename = {
14+
--- ['buf.yaml'] = 'buf-config',
15+
--- ['buf.gen.yaml'] = 'buf-config',
16+
--- ['buf.policy.yaml'] = 'buf-config',
17+
--- ['buf.lock'] = 'buf-config',
18+
--- },
19+
--- })
20+
--- ```
21+
---
22+
--- Optionally, tell treesitter to treat buf config files as YAML for syntax highlighting:
23+
---
24+
--- ```lua
25+
--- vim.treesitter.language.register('yaml', 'buf-config')
26+
--- ```
727

828
---@type vim.lsp.Config
929
return {
1030
cmd = { 'buf', 'lsp', 'serve', '--log-format=text' },
11-
filetypes = { 'proto' },
31+
filetypes = { 'proto', 'buf-config' },
1232
root_markers = { 'buf.yaml', '.git' },
1333
reuse_client = function(client, config)
1434
-- `buf lsp serve` is meant to be used with multiple workspaces.

0 commit comments

Comments
 (0)