debian-dots

dotfiles (does the obvious)
git clone [email protected]:dracuxan/debian-dots.git
Log | Files | Refs | README | LICENSE

none-ls.lua (796B)


      1 local vim = vim
      2 local null_ls = require("null-ls")
      3 local formatting = null_ls.builtins.formatting -- to setup formatters
      4 
      5 local sources = {
      6 	formatting.prettierd,
      7 	formatting.shfmt.with({ args = { "-i", "4" } }),
      8 	formatting.terraform_fmt,
      9 	formatting.nixfmt,
     10 	formatting.black,
     11 }
     12 
     13 local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
     14 null_ls.setup({
     15 	sources = sources,
     16 	on_attach = function(client, bufnr)
     17 		if client.supports_method("textDocument/formatting") then
     18 			vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
     19 			vim.api.nvim_create_autocmd("BufWritePre", {
     20 				group = augroup,
     21 				buffer = bufnr,
     22 				callback = function()
     23 					if vim.bo.filetype == "oil" then
     24 						return
     25 					end
     26 					vim.lsp.buf.format({ async = false })
     27 				end,
     28 			})
     29 		end
     30 	end,
     31 })