The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Null-ls.lua
By Guest on 27th August 2023 11:39:17 AM | Syntax: TEXT | Views: 124



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
  2. local null_ls = require("null-ls")
  3.  
  4. local formatting = null_ls.builtins.formatting
  5. local diagnostics = null_ls.builtins.diagnostics
  6.  
  7. local opts = {
  8.   debug=true,
  9.   sources = {
  10.     formatting.csharpier,
  11.     formatting.prettier.with({ filetypes = { "html", "markdown", "css", "javascript" }}),
  12.     -- python
  13.     formatting.black,
  14.     diagnostics.pylint,
  15.     diagnostics.mypy,
  16.   },
  17.   -- auto format on save
  18.   on_attach = function (client, bufnr)
  19.     if client.supports_method("textDocument/formatting") then
  20.       vim.api.nvim_clear_autocmds({
  21.         group = augroup,
  22.         buffer = bufnr,
  23.       })
  24.       vim.api.nvim_create_autocmd("BufWritePre", {
  25.         group = augroup,
  26.         buffer = bufnr,
  27.         callback = function ()
  28.           vim.lsp.buf.format({ bufnr = bufnr })
  29.         end
  30.       })
  31.     end
  32.   end
  33. }
  34. return opts





null-ls lua