nvim-config/lua/plugins/none-ls.lua

32 lines
1.1 KiB
Lua
Raw Normal View History

2024-04-30 10:24:23 +00:00
return {
"nvimtools/none-ls.nvim",
config=function()
local null_ls = require("null-ls")
2024-05-16 22:11:48 +00:00
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
2024-04-30 10:24:23 +00:00
null_ls.setup({
sources = {
2024-05-16 22:11:48 +00:00
null_ls.builtins.formatting.stylua, -- THIS SUCKS ASS
2024-04-30 10:24:23 +00:00
null_ls.builtins.formatting.black,
2024-05-16 22:11:48 +00:00
null_ls.builtins.diagnostics.mypy,
--null_ls.builtins.diagnostics.ruff,
},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
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
2024-04-30 10:24:23 +00:00
})
vim.keymap.set("n", "<leader>f", vim.lsp.buf.format, {})
end
}