mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-22 02:59:49 +01:00
fix: re-work formatting code
This commit is contained in:
parent
859da274b6
commit
b0e0b6448d
1 changed files with 14 additions and 13 deletions
|
@ -36,20 +36,21 @@ in {
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Enable formatting
|
-- Enable formatting
|
||||||
format_callback = function(client, bufnr)
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
||||||
group = augroup,
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = function()
|
|
||||||
if vim.g.formatsave then
|
|
||||||
if client.supports_method("textDocument/formatting") then
|
|
||||||
local params = require'vim.lsp.util'.make_formatting_params({})
|
|
||||||
client.request('textDocument/formatting', params, nil, bufnr)
|
|
||||||
|
|
||||||
end
|
format_callback = function(client, bufnr)
|
||||||
end
|
if vim.g.formatsave and client.supports_method("textDocument/formatting") then
|
||||||
end
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
})
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = augroup,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.buf.format({
|
||||||
|
bufnr = bufnr
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
default_on_attach = function(client, bufnr)
|
default_on_attach = function(client, bufnr)
|
||||||
|
|
Loading…
Reference in a new issue