Bicep LSP doesn't report formatting provider
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Bicep version**
bicep-lsp 0.37.4
**Describe the bug**
On LspAttach in neovim, my configuration checks for capabilities and sets things up as appropriate. With the check to `client.server_capabilities.documentFormattingProvider` for the bicep lsp, it is a falsy value and hence I don't setup formatting. But if I skip this if check, the server will format when called on save...and I can see in the code there is a formatting provider.
So not sure what to diagnose next...and why the bicep lsp isn't reporting the capability.
**To Reproduce**
```lua
if client.server_capabilities.documentFormattingProvider then
vim.api.nvim_create_autocmd('BufWritePre', {
group = lsp_group,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr, async = false, id = client.id, timeout_ms = 1000 })
end
})
else
print('LSP client ' .. client.name .. ' does not support document formatting')
end
```
I've also tried `client:supports_method('textDocument/formatting') ` as the if check, but with the same result
**Additional context**
Server capabilities printed into debug for inspection
```
{ server_capabilities = { codeLensProvider = vim.empty_dict(), completionProvider = { allCommitCharacters = {}, resolveProvider = true, triggerCharacters = { ":", " ", ".", "/", "'", "@", "{", "#", "?" } }, documentHighlightProvider = vim.empty_dict(), documentLinkProvider = { resolveProvider = true }, documentSymbolProvider = vim.empty_dict(), executeCommandProvider = { commands = { "decompileSave", "decompile", "deploy/waitForCompletion", "getDeploymentScope", "getDeploymentParameters", "deploy/start", "decompileForPaste", "generateParams", "createConfigFile", "bicep.Telemetry", "buildParams", "forceModulesRestore", "decompileParams", "bicep.EditLinterRule", "build" } }, experimental = vim.empty_dict(), referencesProvider = vim.empty_dict(), semanticTokensProvider = { full = { delta = true }, legend = { tokenModifiers = { "documentation", "declaration", "definition", "static", "async", "abstract", "deprecated", "readonly", "modification", "defaultLibrary" }, tokenTypes = { "comment", "keyword", "string", "number", "regexp", "operator", "namespace", "type", "struct", "class", "interface", "enum", "typeParameter", "function", "method", "property", "macro", "variable", "parameter", "label", "modifier", "event", "enumMember", "decorator" } }, range = true }, signatureHelpProvider = { retriggerCharacters = {}, triggerCharacters = { "(", ",", ")", "<", ">" } }, textDocumentSync = { change = 1, openClose = true, save = { includeText = true } }, workspace = { fileOperations = vim.empty_dict(), workspaceFolders = { changeNotifications = true, supported = true } } } }
```
Contributor guide
Research direction
Start with the LspAttach configuration and the bicep-lsp 0.37.4 server_capabilities output in the issue, then reproduce the formatting capability check in Neovim. Trace whether the server advertises textDocument/formatting during initialization; done means the capability check reports formatting support when formatting is available, with a regression test if the repository provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- neovim
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100