diff --git a/lazyvim/.config/nvim/lazyvim.json b/lazyvim/.config/nvim/lazyvim.json index b65078c..52e4551 100644 --- a/lazyvim/.config/nvim/lazyvim.json +++ b/lazyvim/.config/nvim/lazyvim.json @@ -1,6 +1,8 @@ { "extras": [ "lazyvim.plugins.extras.dap.core", + "lazyvim.plugins.extras.editor.dial", + "lazyvim.plugins.extras.editor.fzf", "lazyvim.plugins.extras.editor.refactoring", "lazyvim.plugins.extras.editor.telescope", "lazyvim.plugins.extras.lang.clangd", @@ -12,6 +14,7 @@ "lazyvim.plugins.extras.lang.toml", "lazyvim.plugins.extras.lang.yaml", "lazyvim.plugins.extras.lang.zig", + "lazyvim.plugins.extras.lsp.none-ls", "lazyvim.plugins.extras.ui.alpha" ], "install_version": 7, diff --git a/lazyvim/.config/nvim/lua/plugins/format.lua b/lazyvim/.config/nvim/lua/plugins/format.lua new file mode 100644 index 0000000..792fcce --- /dev/null +++ b/lazyvim/.config/nvim/lua/plugins/format.lua @@ -0,0 +1,57 @@ +return { + "nvimtools/none-ls.nvim", + config = function() + local null_ls = require("null-ls") + + null_ls.setup({ + sources = { + -- C + null_ls.builtins.formatting.clang_format.with({ + extra_args = { + "--style={BasedOnStyle: LLVM, IndentWidth: 8, TabWith: 8, UseTab: Always, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, AllowShortLoopsOnASingleLine: false, AllowShortFunctionsOnASingleLine: InlineOnly, ColumnLimit: 80, AlignConsecutiveDeclarations: false, AlignConsecutiveAssignments: false, AlignEscapedNewlines: Left, AlignOperands: false, IndentCaseLabels: false, SpaceBeforeParens: ControlStatements }", + }, + }), + + -- Go + null_ls.builtins.formatting.goimports, + + -- Zig + null_ls.builtins.formatting.zigfmt, + + -- Lua + null_ls.builtins.formatting.stylua.with({ + extra_args = { + "--indent-type", + "Spaces", + "--indent-width", + "4", + "--column-width", + "100", + }, + }), + + -- Python + null_ls.builtins.formatting.black.with({ + extra_args = { "--line-length", "79" }, + }), + + -- Shell + null_ls.builtins.formatting.shfmt.with({ + extra_args = { "-i", "2", "-ci", "-bn", "-sr", "-p" }, + }), + }, + + -- Auto-format on save + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ async = false }) + end, + }) + end + end, + }) + end, +}