Open MarcelRobitaille opened 1 year ago
Hi, I think I'm seeing this same issue.
[LSP] Format request failed, no matching language servers.
(triggered using the <leader>fm
shortcut).lspconfig
(via default NVChad setup):
require("lspconfig").lua_ls.setup {
on_attach = M.on_attach,
capabilities = M.capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
workspace = {
library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
[vim.fn.stdpath "data" .. "/lazy/extensions/nvchad_types"] = true,
[vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
},
maxPreload = 100000,
preloadFileSize = 10000,
},
},
},
}
According to the Mason output for the plugin, it's installed and the Lua.format.enable
property is using the default of true
.
LspInfo:
Press q or <Esc> to close this window. Press <Tab> to view server doc.
Language client log: /Users/alewis/.local/state/nvim/lsp.log
Detected filetype: lua
1 client(s) attached to this buffer:
Client: lua_ls (id: 1, bufnr: [1])
filetypes: lua
autostart: true
root directory: /Users/alewis/Library/CloudStorage/Sync/shared/.config/nvim/lua/
cmd: /Users/alewis/.local/share/nvim/mason/bin/lua-language-server
Configured servers list: lua_ls, html, cssls, tsserver, vuels
I'm sorry, but I don't know. Neither I nor sumneko are Neovim users. However, I can provide some suggestions. The format of lua_ls is dynamically registered and it requires client support for this capability. On the other hand, check if any other plugins are blocking the formatting ability of lua_ls. You can try setting up a fresh Neovim instance to see if there are any issues.
No problem. I'll try to carve out some time to strip my config back to see whether there is another plugin/lsp that might be causing the issue and I'll report back here.
i'm also facing the same problem on my macos (intel) monterey, using neovim (I made sure to install the lua-language-server using Mason, and configured the lua_ls LSP on_attach), but the formatter does not seem to be responding
I've gotten it to work on NvChad. Setup: Neovim Nightly, NvChad 2.0
NvChad specifically disables LSP Server formatting on it's default implementation of on_attach
:
file: plugins/configs/lspconfig.lua
M.on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
utils.load_mappings("lspconfig", { buffer = bufnr })
if client.server_capabilities.signatureHelpProvider then
require("nvchad.signature").setup(client)
end
if not utils.load_config().ui.lsp_semantic_tokens and client.supports_method "textDocument/semanticTokens" then
client.server_capabilities.semanticTokensProvider = nil
end
end
These Two Lines:
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
When you modify them after the fact, enables lua_ls formatting:
...
lspconfig.lua_ls.setup {
on_attach = function(client, bufnr)
config.on_attach(client, bufnr)
client.server_capabilities.documentFormattingProvider = true
client.server_capabilities.documentRangeFormattingProvider = true
end,
capabilities = config.capabilities,
filetypes = { "lua" },
settings = {
Lua = {
format = {
defaultConfig = {
indent_style = "space",
indent_size = "4",
},
},
...
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Formatting
Expected Behaviour
The document gets formatted.
Actual Behaviour
I get
[LSP] Format request failed, no matching language servers.
logged. Formatters for other lsps are working.:LspInfo
shows lua_ls is running.Reproduction steps
lua-language-server
3.6.22 via nixlspconfig
:Additional Notes
:LspInfo
:Log File