From 6fb33b02cd262114af52edf6a94dd31bb84e6314 Mon Sep 17 00:00:00 2001 From: AramJonghu Date: Sat, 20 Jun 2026 03:44:26 +0200 Subject: [PATCH] stylua added rule --- .stylua.toml | 3 +- lua/autocmd.lua | 10 ++-- lua/config/barbar.lua | 14 ++++-- lua/config/cmp.lua | 12 +++-- lua/config/dap.lua | 11 ++++- lua/config/gitsigns.lua | 20 ++------ lua/config/indent-blankline.lua | 10 +++- lua/config/lualine.lua | 31 ++++++------ lua/config/notify.lua | 88 ++++++++++++++++++++------------- lua/config/telescope.lua | 8 +-- lua/mappings.lua | 15 +++--- lua/options.lua | 11 +++-- lua/plugins/init.lua | 66 +++++++++---------------- 13 files changed, 154 insertions(+), 145 deletions(-) diff --git a/.stylua.toml b/.stylua.toml index ca1541c..56b16c4 100644 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,6 +1,7 @@ -column_width = 120 +column_width = 80 line_endings = "Unix" indent_type = "Spaces" indent_width = 4 quote_style = "AutoPreferDouble" call_parentheses = "None" +collapse_simple_statement = "Always" diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 7677012..a23a4a1 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -6,12 +6,14 @@ local neoformat_group = augroup("NeoformatOnSave", { clear = true }) autocmd("BufWritePost", { group = neoformat_group, callback = function() - if vim.bo.buftype ~= "" or vim.bo.modifiable == false or vim.bo.readonly then - return - end - if vim.fn.exists ":Neoformat" ~= 2 then + if + vim.bo.buftype ~= "" + or vim.bo.modifiable == false + or vim.bo.readonly + then return end + if vim.fn.exists ":Neoformat" ~= 2 then return end vim.cmd "silent! Neoformat" end, }) diff --git a/lua/config/barbar.lua b/lua/config/barbar.lua index d4dbc85..5369ef0 100644 --- a/lua/config/barbar.lua +++ b/lua/config/barbar.lua @@ -1,10 +1,16 @@ require("bufferline").setup { options = { diagnostics = "coc", - diagnostics_indicator = function(count, level, diagnostics_dict, context) + diagnostics_indicator = function( + count, + level, + diagnostics_dict, + context + ) local s = " " for e, n in pairs(diagnostics_dict) do - local sym = e == "error" and " " or (e == "warning" and " " or " ") + local sym = e == "error" and " " + or (e == "warning" and " " or " ") s = s .. n .. sym end return s @@ -16,9 +22,7 @@ require("bufferline").setup { }, vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, { callback = function() - vim.schedule(function() - pcall(nvim_bufferline) - end) + vim.schedule(function() pcall(nvim_bufferline) end) end, }), }, diff --git a/lua/config/cmp.lua b/lua/config/cmp.lua index db05675..cc5ea75 100644 --- a/lua/config/cmp.lua +++ b/lua/config/cmp.lua @@ -3,8 +3,12 @@ local cmp_lsp = require "cmp_nvim_lsp" local M = {} -M.capabilities = - vim.tbl_deep_extend("force", {}, vim.lsp.protocol.make_client_capabilities(), cmp_lsp.default_capabilities()) +M.capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities() +) local cmp_kinds = { Text = " ", @@ -47,9 +51,7 @@ cmp.setup { }, completion = { completeopt = "menu,menuone" }, snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, + expand = function(args) require("luasnip").lsp_expand(args.body) end, }, mapping = { -- change later zach is ???? [""] = cmp.mapping.scroll_docs(-4), diff --git a/lua/config/dap.lua b/lua/config/dap.lua index 2f8dd64..2b41683 100644 --- a/lua/config/dap.lua +++ b/lua/config/dap.lua @@ -7,7 +7,10 @@ dap.adapters.python = function(cb, config) local host = (config.connect or config).host or "127.0.0.1" cb { type = "server", - port = assert(port, "`connect.port` is required for a python `attach` configuration"), + port = assert( + port, + "`connect.port` is required for a python `attach` configuration" + ), host = host, options = { source_filetype = "python" }, } @@ -59,7 +62,11 @@ dap.configurations.cpp = { type = "lldb", request = "launch", program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + return vim.fn.input( + "Path to executable: ", + vim.fn.getcwd() .. "/", + "file" + ) end, cwd = "${workspaceFolder}", stopOnEntry = false, diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua index d7957c4..4c2dcde 100644 --- a/lua/config/gitsigns.lua +++ b/lua/config/gitsigns.lua @@ -6,22 +6,14 @@ local function on_attach(bufnr) end map("n", "]g", function() - if vim.wo.diff then - return "]g" - end - vim.schedule(function() - gs.next_hunk() - end) + if vim.wo.diff then return "]g" end + vim.schedule(function() gs.next_hunk() end) return "" end, "Next hunk") map("n", "[g", function() - if vim.wo.diff then - return "[g" - end - vim.schedule(function() - gs.prev_hunk() - end) + if vim.wo.diff then return "[g" end + vim.schedule(function() gs.prev_hunk() end) return "" end, "Prev hunk") @@ -30,9 +22,7 @@ local function on_attach(bufnr) map("n", "hp", gs.preview_hunk, "Preview hunk") map("n", "hb", gs.blame_line, "Blame line") map("n", "hd", gs.diffthis, "Diff this") - map("n", "hD", function() - gs.diffthis "~" - end, "Diff against ~") + map("n", "hD", function() gs.diffthis "~" end, "Diff against ~") map("n", "htb", gs.toggle_current_line_blame, "Toggle line blame") map("n", "htd", gs.toggle_deleted, "Toggle deleted") end diff --git a/lua/config/indent-blankline.lua b/lua/config/indent-blankline.lua index 35c3c21..0aa1a03 100644 --- a/lua/config/indent-blankline.lua +++ b/lua/config/indent-blankline.lua @@ -21,6 +21,12 @@ hooks.register(hooks.type.HIGHLIGHT_SETUP, function() end) vim.g.rainbow_delimiters = { highlight = highlight } -require("ibl").setup { indent = { char = "▏" }, scope = { highlight = highlight } } +require("ibl").setup { + indent = { char = "▏" }, + scope = { highlight = highlight }, +} -hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) +hooks.register( + hooks.type.SCOPE_HIGHLIGHT, + hooks.builtin.scope_highlight_from_extmark +) diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua index 18fc0a7..973aeba 100644 --- a/lua/config/lualine.lua +++ b/lua/config/lualine.lua @@ -1,7 +1,9 @@ local fn = vim.fn local function get_coc_lsp_client() - local clients = vim.g.coc_service_initialized and vim.fn["CocAction"] "services" or {} + local clients = vim.g.coc_service_initialized + and vim.fn["CocAction"] "services" + or {} for _, client in pairs(clients) do if client["state"] == "running" then local client_name = client["id"] @@ -14,9 +16,7 @@ local function get_coc_lsp_client() end local function spell() - if vim.o.spell then - return string.format "[SPELL]" - end + if vim.o.spell then return string.format "[SPELL]" end return "" end @@ -24,11 +24,10 @@ end --- show indicator for Chinese IME local function ime_state() if vim.g.is_mac then - local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "") + local layout = + fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "") local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]]) - if res ~= -1 then - return "[CN]" - end + if res ~= -1 then return "[CN]" end end return "" @@ -36,24 +35,21 @@ end local diff = function() local git_status = vim.b.gitsigns_status_dict - if git_status == nil then - return - end + if git_status == nil then return end local modify_num = git_status.changed local remove_num = git_status.removed local add_num = git_status.added - local info = { added = add_num, modified = modify_num, removed = remove_num } + local info = + { added = add_num, modified = modify_num, removed = remove_num } -- vim.print(info) return info end local virtual_env = function() -- only show virtual env for Python - if vim.bo.filetype ~= "python" then - return "" - end + if vim.bo.filetype ~= "python" then return "" end local conda_env = os.getenv "CONDA_DEFAULT_ENV" local venv_path = os.getenv "VIRTUAL_ENV" @@ -116,7 +112,10 @@ require("lualine").setup { }, lualine_y = { { "encoding", fmt = string.upper }, - { "fileformat", symbols = { unix = "", dos = "", mac = "" } }, + { + "fileformat", + symbols = { unix = "", dos = "", mac = "" }, + }, "filetype", }, lualine_z = { "progress" }, diff --git a/lua/config/notify.lua b/lua/config/notify.lua index 37ba152..8ddf99d 100644 --- a/lua/config/notify.lua +++ b/lua/config/notify.lua @@ -26,9 +26,7 @@ require("notify").setup { local client_notifs = {} local function get_notif_data(client_id, token) - if not client_notifs[client_id] then - client_notifs[client_id] = {} - end + if not client_notifs[client_id] then client_notifs[client_id] = {} end if not client_notifs[client_id][token] then client_notifs[client_id][token] = {} @@ -37,7 +35,8 @@ local function get_notif_data(client_id, token) return client_notifs[client_id][token] end -local spinner_frames = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" } +local spinner_frames = + { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" } local function update_spinner(client_id, token) local notif_data = get_notif_data(client_id, token) @@ -52,9 +51,7 @@ local function update_spinner(client_id, token) replace = notif_data.notification, }) - vim.defer_fn(function() - update_spinner(client_id, token) - end, 100) + vim.defer_fn(function() update_spinner(client_id, token) end, 100) end end @@ -74,9 +71,7 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx) local val = result.value - if not val.kind then - return - end + if not val.kind then return end local notif_data = get_notif_data(client_id, result.token) @@ -84,7 +79,10 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx) local message = format_message(val.message, val.percentage) notif_data.notification = vim.notify(message, "info", { - title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name), + title = format_title( + val.title, + vim.lsp.get_client_by_id(client_id).name + ), icon = spinner_frames[1], timeout = false, hide_from_history = false, @@ -93,16 +91,21 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx) notif_data.spinner = 1 update_spinner(client_id, result.token) elseif val.kind == "report" and notif_data then - notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", { - replace = notif_data.notification, - hide_from_history = false, - }) + notif_data.notification = + vim.notify(format_message(val.message, val.percentage), "info", { + replace = notif_data.notification, + hide_from_history = false, + }) elseif val.kind == "end" and notif_data then - notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", { - icon = "", - replace = notif_data.notification, - timeout = 6000, - }) + notif_data.notification = vim.notify( + val.message and format_message(val.message) or "Complete", + "info", + { + icon = "", + replace = notif_data.notification, + timeout = 6000, + } + ) notif_data.spinner = nil end @@ -111,14 +114,22 @@ end -- table from lsp severity to vim severity. local severity = { "error", "warn", "info" } -vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id) +vim.lsp.handlers["window/showMessage"] = function( + err, + method, + params, + client_id +) vim.notify(method.message, severity[params.type]) end -- DAP integration -- Make sure to also have the snippet with the common helper functions in your config! -dap.listeners.before["event_progressStart"]["progress-notifications"] = function(session, body) +dap.listeners.before["event_progressStart"]["progress-notifications"] = function( + session, + body +) local notif_data = get_notif_data("dap", body.progressId) local message = format_message(body.message, body.percentage) @@ -132,20 +143,31 @@ dap.listeners.before["event_progressStart"]["progress-notifications"] = function notif_data.notification.spinner = 1, update_spinner("dap", body.progressId) end -dap.listeners.before["event_progressUpdate"]["progress-notifications"] = function(session, body) +dap.listeners.before["event_progressUpdate"]["progress-notifications"] = function( + session, + body +) local notif_data = get_notif_data("dap", body.progressId) - notif_data.notification = vim.notify(format_message(body.message, body.percentage), "info", { - replace = notif_data.notification, - hide_from_history = false, - }) + notif_data.notification = + vim.notify(format_message(body.message, body.percentage), "info", { + replace = notif_data.notification, + hide_from_history = false, + }) end -dap.listeners.before["event_progressEnd"]["progress-notifications"] = function(session, body) +dap.listeners.before["event_progressEnd"]["progress-notifications"] = function( + session, + body +) local notif_data = client_notifs["dap"][body.progressId] - notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", { - icon = "", - replace = notif_data.notification, - timeout = 6000, - }) + notif_data.notification = vim.notify( + body.message and format_message(body.message) or "Complete", + "info", + { + icon = "", + replace = notif_data.notification, + timeout = 6000, + } + ) notif_data.spinner = nil end diff --git a/lua/config/telescope.lua b/lua/config/telescope.lua index 3a61317..a845e49 100644 --- a/lua/config/telescope.lua +++ b/lua/config/telescope.lua @@ -1,12 +1,8 @@ -if not vim.F then - vim.F = {} -end +if not vim.F then vim.F = {} end if not vim.F.if_nil and not vim.nonnil then vim.F.if_nil = function(value, default) - if value == nil then - return default - end + if value == nil then return default end return value end end diff --git a/lua/mappings.lua b/lua/mappings.lua index 34a6cda..910fd50 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -1,9 +1,7 @@ local map = vim.keymap.set local default_opts = { noremap = true } -map("n", "n", function() - Snacks.notifier.show_history() -end) +map("n", "n", function() Snacks.notifier.show_history() end) map( "n", @@ -34,7 +32,12 @@ map("n", "", "k", { desc = "Move to top split" }) map("n", "", "l", { desc = "Move to right split" }) map("n", "e", vim.cmd.NvimTreeToggle) -map("n", "u", require("undotree").toggle, { noremap = true, silent = true }) +map( + "n", + "u", + require("undotree").toggle, + { noremap = true, silent = true } +) map("n", "", ":bdelete") -- map("n", "", ":BufferRestore") @@ -67,6 +70,4 @@ map("i", "", "") map("n", "mr", "CellularAutomaton make_it_rain") -map("n", "", function() - vim.cmd "so" -end) +map("n", "", function() vim.cmd "so" end) diff --git a/lua/options.lua b/lua/options.lua index c82168c..ac9a31d 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -22,7 +22,8 @@ vim.opt.updatetime = 50 vim.opt.textwidth = 0 vim.opt.colorcolumn = "100" vim.opt.formatoptions = "rqnj" -vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" +vim.o.sessionoptions = + "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" vim.o.laststatus = 0 vim.o.clipboard = "unnamedplus" vim.o.cursorline = true @@ -47,8 +48,8 @@ vim.g.loaded_ruby_provider = 0 local is_windows = vim.fn.has "win32" ~= 0 local sep = is_windows and "\\" or "/" local delim = is_windows and ";" or ":" -vim.env.PATH = table.concat({ vim.fn.stdpath "data", "mason", "bin" }, sep) .. delim .. vim.env.PATH +vim.env.PATH = table.concat({ vim.fn.stdpath "data", "mason", "bin" }, sep) + .. delim + .. vim.env.PATH -vim.api.nvim_create_user_command("Nf", function() - vim.cmd "Neoformat" -end, {}) +vim.api.nvim_create_user_command("Nf", function() vim.cmd "Neoformat" end, {}) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 318dc14..3a0b543 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -4,21 +4,23 @@ return { }, { "lewis6991/gitsigns.nvim", - config = function() - require "config.gitsigns" - end, + config = function() require "config.gitsigns" end, + }, + { + "vimpostor/vim-tpipeline", }, - { "vimpostor/vim-tpipeline" }, { "aznhe21/actions-preview.nvim", - config = function() - require "config.actions-preview" - end, + config = function() require "config.actions-preview" end, }, { "sbdchd/neoformat", init = function() - vim.cmd("source" .. vim.fn.stdpath "config" .. "/lua/config/neoformat.vim") + vim.cmd( + "source" + .. vim.fn.stdpath "config" + .. "/lua/config/neoformat.vim" + ) end, }, { @@ -62,90 +64,66 @@ return { "saadparwaiz1/cmp_luasnip", "j-hui/fidget.nvim", }, - config = function() - require "config.lspconfig" - end, + config = function() require "config.lspconfig" end, }, { "https://gitlab.com/itaranto/plantuml.nvim", version = "*", - config = function() - require("plantuml").setup() - end, + config = function() require("plantuml").setup() end, }, { "nvim-treesitter/nvim-treesitter", lazy = false, branch = "main", build = ":TSUpdate", - config = function() - require "config.treesitter" - end, + config = function() require "config.treesitter" end, }, { "rmagatti/auto-session", - config = function() - require "config.autosession" - end, + config = function() require "config.autosession" end, }, { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require "config.telescope" - end, + config = function() require "config.telescope" end, }, { "lambdalisue/vim-suda" }, { "nvim-tree/nvim-web-devicons" }, { "nvim-tree/nvim-tree.lua", cmd = { "NvimTreeToggle", "NvimTreeFocus" }, - config = function() - require "config.nvimtree" - end, + config = function() require "config.nvimtree" end, }, { "akinsho/bufferline.nvim", event = "VeryLazy", - config = function() - require "config.barbar" - end, + config = function() require "config.barbar" end, }, { "nvim-lualine/lualine.nvim", event = "VeryLazy", - config = function() - require "config.lualine" - end, + config = function() require "config.lualine" end, }, { "jiaoshijie/undotree", - config = function() - require "config.undotree" - end, + config = function() require "config.undotree" end, }, { "hiphish/rainbow-delimiters.nvim" }, { "windwp/nvim-autopairs", event = "InsertEnter", - config = function() - require "config.autopairs" - end, + config = function() require "config.autopairs" end, }, { "tpope/vim-fugitive" }, { "catgoose/nvim-colorizer.lua", - config = function() - require "config.colorizer" - end, + config = function() require "config.colorizer" end, }, { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, { "ellisonleao/gruvbox.nvim", priority = 1000, config = true, opts = ... }, { "mfussenegger/nvim-dap", - config = function() - require "config.dap" - end, + config = function() require "config.dap" end, }, { "MeanderingProgrammer/render-markdown.nvim",