use fresh vim.api autocmds

This commit is contained in:
2022-03-27 17:40:54 +03:00
parent 5b24edb775
commit 211420b3fb
2 changed files with 21 additions and 10 deletions

View File

@@ -44,17 +44,22 @@ null_ls.setup({
formatting.shfmt,
},
on_attach = function()
vim.cmd([[
augroup LspFormatting
autocmd! * <buffer>
autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()
augroup END
]])
local group = vim.api.nvim_create_augroup("NullLsLspFormatting", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*",
group = group,
callback = vim.lsp.buf.formatting_sync,
})
end,
})
-- Other formats that work weird with null_ls
vim.cmd([[autocmd BufWritePre *.svelte lua vim.lsp.buf.formatting_sync(nil, 1000)]])
local group = vim.api.nvim_create_augroup("OtherLspFormatting", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = { "*.svelte" },
group = group,
callback = vim.lsp.buf.formatting_sync,
})
local completion_trigger = "<C-space>"
if vim.fn.has("win32") == 1 then