From 1e1d5d264a298856c34ad812cfd94f54b9b9442a Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Sun, 2 Jun 2024 19:45:00 +0200 Subject: [PATCH] Add Stylua config to nvim conf --- .../plugins/editor/debugging/debugging_go.lua | 16 +++- .../plugins/editor/editor_auto_brackets.lua | 4 +- .../plugins/editor/editor_code_snippets.lua | 13 +-- .../lua/plugins/editor/editor_debugging.lua | 96 +++++++++++++++---- .../plugins/editor/editor_language_server.lua | 63 +++++++++--- .../editor/editor_markdown_preview.lua | 7 +- .../plugins/extension/status_bar_plugin.lua | 11 ++- .config/nvim/lua/plugins/file_tree.lua | 14 ++- .config/nvim/lua/plugins/git.lua | 14 ++- .config/nvim/lua/plugins/search.lua | 45 +++++++-- .config/nvim/lua/plugins/status_bar.lua | 4 +- .config/nvim/stylua.toml | 7 ++ 12 files changed, 233 insertions(+), 61 deletions(-) create mode 100644 .config/nvim/stylua.toml diff --git a/.config/nvim/lua/plugins/editor/debugging/debugging_go.lua b/.config/nvim/lua/plugins/editor/debugging/debugging_go.lua index c305804..26163d7 100644 --- a/.config/nvim/lua/plugins/editor/debugging/debugging_go.lua +++ b/.config/nvim/lua/plugins/editor/debugging/debugging_go.lua @@ -1,7 +1,13 @@ return { - "leoluz/nvim-dap-go", - config = function() - local dir = require("utils.finder").find_project_dir("go.mod", 3, { "src", "app", "pkg" }, { "test" }, true) - require("dap-go").setup({ delve = { cwd = dir } }) - end, + "leoluz/nvim-dap-go", + config = function() + local dir = require("utils.finder").find_project_dir( + "go.mod", + 3, + { "src", "app", "pkg" }, + { "test" }, + true + ) + require("dap-go").setup({ delve = { cwd = dir } }) + end, } diff --git a/.config/nvim/lua/plugins/editor/editor_auto_brackets.lua b/.config/nvim/lua/plugins/editor/editor_auto_brackets.lua index b6147b0..e4bdf2d 100644 --- a/.config/nvim/lua/plugins/editor/editor_auto_brackets.lua +++ b/.config/nvim/lua/plugins/editor/editor_auto_brackets.lua @@ -1,6 +1,4 @@ return { "m4xshen/autoclose.nvim", - config = function() - require("autoclose").setup() - end, + config = function() require("autoclose").setup() end, } diff --git a/.config/nvim/lua/plugins/editor/editor_code_snippets.lua b/.config/nvim/lua/plugins/editor/editor_code_snippets.lua index 75dd468..9bfd8e0 100644 --- a/.config/nvim/lua/plugins/editor/editor_code_snippets.lua +++ b/.config/nvim/lua/plugins/editor/editor_code_snippets.lua @@ -40,9 +40,12 @@ return { end end, { silent = true }) - vim.keymap.set({ "i", "s" }, "", function() - luasnip.jump(-1) - end, { silent = true }) + vim.keymap.set( + { "i", "s" }, + "", + function() luasnip.jump(-1) end, + { silent = true } + ) local doc_keybindings = { [""] = cmp.mapping.scroll_docs(-4), @@ -55,9 +58,7 @@ return { -- Setup -- cmp.setup({ snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, + expand = function(args) luasnip.lsp_expand(args.body) end, }, window = { completion = cmp.config.window.bordered(), diff --git a/.config/nvim/lua/plugins/editor/editor_debugging.lua b/.config/nvim/lua/plugins/editor/editor_debugging.lua index f4615a8..f41c75b 100644 --- a/.config/nvim/lua/plugins/editor/editor_debugging.lua +++ b/.config/nvim/lua/plugins/editor/editor_debugging.lua @@ -31,43 +31,101 @@ return { }, }, }) - dap.listeners.before.attach.dapui_config = function() - dapui.open() - end - dap.listeners.before.launch.dapui_config = function() - dapui.open() - end + dap.listeners.before.attach.dapui_config = function() dapui.open() end + dap.listeners.before.launch.dapui_config = function() dapui.open() end -- Keybinding -- - vim.keymap.set("n", "dt", dapui.toggle, { desc = "Toggle Debugger UI" }) - vim.keymap.set("n", "db", dap.toggle_breakpoint, { desc = "Toggle Breakpoint" }) - vim.keymap.set("n", "dc", dap.continue, { desc = "Debugger Continue" }) - vim.keymap.set("n", "dx", dap.terminate, { desc = "Debugger Terminate" }) - vim.keymap.set("n", "ds", dap.step_over, { desc = "Debugger Step Over" }) + vim.keymap.set( + "n", + "dt", + dapui.toggle, + { desc = "Toggle Debugger UI" } + ) + vim.keymap.set( + "n", + "db", + dap.toggle_breakpoint, + { desc = "Toggle Breakpoint" } + ) + vim.keymap.set( + "n", + "dc", + dap.continue, + { desc = "Debugger Continue" } + ) + vim.keymap.set( + "n", + "dx", + dap.terminate, + { desc = "Debugger Terminate" } + ) + vim.keymap.set( + "n", + "ds", + dap.step_over, + { desc = "Debugger Step Over" } + ) -- Breakpoints -- - vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" }) - vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" }) - vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" }) + vim.api.nvim_set_hl( + 0, + "DapBreakpoint", + { ctermbg = 0, fg = "#993939", bg = "#31353f" } + ) + vim.api.nvim_set_hl( + 0, + "DapLogPoint", + { ctermbg = 0, fg = "#61afef", bg = "#31353f" } + ) + vim.api.nvim_set_hl( + 0, + "DapStopped", + { ctermbg = 0, fg = "#98c379", bg = "#31353f" } + ) vim.fn.sign_define( "DapBreakpoint", - { text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } + { + text = "", + texthl = "DapBreakpoint", + linehl = "DapBreakpoint", + numhl = "DapBreakpoint", + } ) vim.fn.sign_define( "DapBreakpointCondition", - { text = "󰣏", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } + { + text = "󰣏", + texthl = "DapBreakpoint", + linehl = "DapBreakpoint", + numhl = "DapBreakpoint", + } ) vim.fn.sign_define( "DapBreakpointRejected", - { text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } + { + text = "", + texthl = "DapBreakpoint", + linehl = "DapBreakpoint", + numhl = "DapBreakpoint", + } ) vim.fn.sign_define( "DapLogPoint", - { text = "", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" } + { + text = "", + texthl = "DapLogPoint", + linehl = "DapLogPoint", + numhl = "DapLogPoint", + } ) vim.fn.sign_define( "DapStopped", - { text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" } + { + text = "", + texthl = "DapStopped", + linehl = "DapStopped", + numhl = "DapStopped", + } ) end, }, diff --git a/.config/nvim/lua/plugins/editor/editor_language_server.lua b/.config/nvim/lua/plugins/editor/editor_language_server.lua index 7874f3e..1d6f8b8 100644 --- a/.config/nvim/lua/plugins/editor/editor_language_server.lua +++ b/.config/nvim/lua/plugins/editor/editor_language_server.lua @@ -1,5 +1,6 @@ local lua_lsp = require("plugins.editor.language_server.language_server_lua") -local generic_lsp = require("plugins.editor.language_server.language_server_generic") +local generic_lsp = + require("plugins.editor.language_server.language_server_generic") local go_lsp = require("plugins.editor.language_server.language_server_go") local web_lsp = require("plugins.editor.language_server.language_server_web") local php_lsp = require("plugins.editor.language_server.language_server_php") @@ -8,9 +9,7 @@ return { { "williamboman/mason.nvim", lazy = false, - config = function() - require("mason").setup() - end, + config = function() require("mason").setup() end, }, { "williamboman/mason-lspconfig.nvim", @@ -45,10 +44,30 @@ return { php_lsp.setup(lspconfig, capabilities) -- Keybinding -- - vim.keymap.set("n", "cd", vim.lsp.buf.hover, { desc = "Show Code Definition" }) - vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to Definition" }) - vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "Go to References" }) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { desc = "Do Code Actions" }) + vim.keymap.set( + "n", + "cd", + vim.lsp.buf.hover, + { desc = "Show Code Definition" } + ) + vim.keymap.set( + "n", + "gd", + vim.lsp.buf.definition, + { desc = "Go to Definition" } + ) + vim.keymap.set( + "n", + "gr", + vim.lsp.buf.references, + { desc = "Go to References" } + ) + vim.keymap.set( + "n", + "ca", + vim.lsp.buf.code_action, + { desc = "Do Code Actions" } + ) end, }, { @@ -71,7 +90,12 @@ return { }) -- Keybinding -- - vim.keymap.set("n", "fc", vim.lsp.buf.format, { desc = "Format Code" }) + vim.keymap.set( + "n", + "fc", + vim.lsp.buf.format, + { desc = "Format Code" } + ) end, }, { @@ -86,9 +110,24 @@ return { lspsaga.setup({}) -- Keybinding -- - vim.keymap.set("n", "cr", ":Lspsaga rename", { desc = "Rename Variable" }) - vim.keymap.set("n", "cp", ":Lspsaga peek_definition", { desc = "Peek Code Definition" }) - vim.keymap.set({ "n", "t" }, "", "Lspsaga term_toggle", { desc = "Toggle Terminal" }) + vim.keymap.set( + "n", + "cr", + ":Lspsaga rename", + { desc = "Rename Variable" } + ) + vim.keymap.set( + "n", + "cp", + ":Lspsaga peek_definition", + { desc = "Peek Code Definition" } + ) + vim.keymap.set( + { "n", "t" }, + "", + "Lspsaga term_toggle", + { desc = "Toggle Terminal" } + ) end, }, } diff --git a/.config/nvim/lua/plugins/editor/editor_markdown_preview.lua b/.config/nvim/lua/plugins/editor/editor_markdown_preview.lua index f1bca7a..ad0cc39 100644 --- a/.config/nvim/lua/plugins/editor/editor_markdown_preview.lua +++ b/.config/nvim/lua/plugins/editor/editor_markdown_preview.lua @@ -25,6 +25,11 @@ return { }, }) - vim.keymap.set("n", "mp", ":Mdpreview", { desc = "Show Markdown Preview" }) + vim.keymap.set( + "n", + "mp", + ":Mdpreview", + { desc = "Show Markdown Preview" } + ) end, } diff --git a/.config/nvim/lua/plugins/extension/status_bar_plugin.lua b/.config/nvim/lua/plugins/extension/status_bar_plugin.lua index 120f25f..96bac22 100644 --- a/.config/nvim/lua/plugins/extension/status_bar_plugin.lua +++ b/.config/nvim/lua/plugins/extension/status_bar_plugin.lua @@ -34,12 +34,19 @@ local function get_dap_repl_winbar(active) return "" end - local background_color = string.format("lualine_b" .. "%s", active and get_mode() or "_inactive") + local background_color = string.format( + "lualine_b" .. "%s", + active and get_mode() or "_inactive" + ) local controls_string = "%#" .. background_color .. "#" for element in require("dapui.controls").controls():gmatch("%S+") do local color, action = string.match(element, "%%#(.*)#(%%.*)%%#0#") - controls_string = controls_string .. " %#" .. merge_colors(color, background_color) .. "#" .. action + controls_string = controls_string + .. " %#" + .. merge_colors(color, background_color) + .. "#" + .. action end return controls_string end diff --git a/.config/nvim/lua/plugins/file_tree.lua b/.config/nvim/lua/plugins/file_tree.lua index c75df68..0699686 100644 --- a/.config/nvim/lua/plugins/file_tree.lua +++ b/.config/nvim/lua/plugins/file_tree.lua @@ -65,7 +65,17 @@ return { }) -- Keybinding -- - vim.keymap.set("n", "ft", ":Neotree toggle reveal left", { desc = "Toggle File Tree" }) - vim.keymap.set("n", "fo", ":Neotree buffers reveal float", { desc = "Show Open Files" }) + vim.keymap.set( + "n", + "ft", + ":Neotree toggle reveal left", + { desc = "Toggle File Tree" } + ) + vim.keymap.set( + "n", + "fo", + ":Neotree buffers reveal float", + { desc = "Show Open Files" } + ) end, } diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua index ea9ea27..de2d008 100644 --- a/.config/nvim/lua/plugins/git.lua +++ b/.config/nvim/lua/plugins/git.lua @@ -9,14 +9,24 @@ return { require("gitsigns").setup() -- Keybinding -- - vim.keymap.set("n", "gh", ":Gitsigns preview_hunk_inline", { desc = "Toggle Inline Git Diff" }) + vim.keymap.set( + "n", + "gh", + ":Gitsigns preview_hunk_inline", + { desc = "Toggle Inline Git Diff" } + ) vim.keymap.set( "n", "gb", ":Gitsigns toggle_current_line_blame", { desc = "Toggle Inline Git Blame" } ) - vim.keymap.set("n", "go", ":Git ", { desc = "Open Git" }) + vim.keymap.set( + "n", + "go", + ":Git ", + { desc = "Open Git" } + ) end, }, { diff --git a/.config/nvim/lua/plugins/search.lua b/.config/nvim/lua/plugins/search.lua index db1821f..d6958bf 100644 --- a/.config/nvim/lua/plugins/search.lua +++ b/.config/nvim/lua/plugins/search.lua @@ -17,9 +17,18 @@ return { require("telescope").load_extension("ui-select") -- Keybinding -- - local function setTelescopeBinding(mode, keymap, method, search_global, description) + local function setTelescopeBinding( + mode, + keymap, + method, + search_global, + description + ) local function binding() - local path = search_global and "~" or require("neo-tree.sources.manager").get_state("filesystem").path + local path = search_global and "~" + or require("neo-tree.sources.manager").get_state( + "filesystem" + ).path method({ search_dirs = { path } }) end vim.keymap.set(mode, keymap, binding, { desc = description }) @@ -27,9 +36,33 @@ return { local telescope = require("telescope.builtin") - setTelescopeBinding("n", "ff", telescope.find_files, false, "Find File") - setTelescopeBinding("n", "fz", telescope.live_grep, false, "Fuzzy Find") - setTelescopeBinding("n", "gff", telescope.find_files, true, "Global Find File") - setTelescopeBinding("n", "gfz", telescope.live_grep, true, "Global Fuzzy Find") + setTelescopeBinding( + "n", + "ff", + telescope.find_files, + false, + "Find File" + ) + setTelescopeBinding( + "n", + "fz", + telescope.live_grep, + false, + "Fuzzy Find" + ) + setTelescopeBinding( + "n", + "gff", + telescope.find_files, + true, + "Global Find File" + ) + setTelescopeBinding( + "n", + "gfz", + telescope.live_grep, + true, + "Global Fuzzy Find" + ) end, } diff --git a/.config/nvim/lua/plugins/status_bar.lua b/.config/nvim/lua/plugins/status_bar.lua index 6a750f5..7636b35 100644 --- a/.config/nvim/lua/plugins/status_bar.lua +++ b/.config/nvim/lua/plugins/status_bar.lua @@ -72,8 +72,6 @@ return { "lewis6991/gitsigns.nvim", "nvim-tree/nvim-web-devicons", }, - config = function() - require("barbar").setup() - end, + config = function() require("barbar").setup() end, }, } diff --git a/.config/nvim/stylua.toml b/.config/nvim/stylua.toml new file mode 100644 index 0000000..474dd4d --- /dev/null +++ b/.config/nvim/stylua.toml @@ -0,0 +1,7 @@ +column_width = 80 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 4 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "FunctionOnly"