diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-24 20:35:27 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-01-24 20:35:27 +0900 |
| commit | c80a54e42b52ce297f0f2f71af23c562832025c7 (patch) | |
| tree | dcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.config/NvChad/lua/custom/configs/null-ls.lua | |
init
Diffstat (limited to 'ar/.config/NvChad/lua/custom/configs/null-ls.lua')
| -rw-r--r-- | ar/.config/NvChad/lua/custom/configs/null-ls.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/ar/.config/NvChad/lua/custom/configs/null-ls.lua b/ar/.config/NvChad/lua/custom/configs/null-ls.lua new file mode 100644 index 0000000..d703736 --- /dev/null +++ b/ar/.config/NvChad/lua/custom/configs/null-ls.lua @@ -0,0 +1,45 @@ +local null_ls = require "null-ls" +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local b = null_ls.builtins + +local sources = { + -- cpp + b.formatting.clang_format, + + -- Lua + b.formatting.stylua, + + -- python + b.code_actions.refactoring, + b.diagnostics.mypy, + b.diagnostics.ruff, + b.diagnostics.vulture, + b.formatting.black, + -- b.formatting.pyflyby, + -- b.formatting.reorder_python_imports, + + -- webdev stuff + b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast! + b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes +} + +null_ls.setup { + debug = true, + sources = sources, + 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, +} |
