Add autoformating on save for rust
This commit is contained in:
parent
4b66d3bbcb
commit
a0167322fc
1 changed files with 11 additions and 1 deletions
|
|
@ -13,8 +13,18 @@ return {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server = {
|
server = {
|
||||||
on_attach = function(_, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
vim.lsp.inlay_hint.enable(bufnr, true)
|
vim.lsp.inlay_hint.enable(bufnr, true)
|
||||||
|
|
||||||
|
if client.server_capabilities.documentFormattingProvider then
|
||||||
|
vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = 0 })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue