stylua added rule

This commit is contained in:
2026-06-20 03:44:26 +02:00
parent 907b234eb7
commit 6fb33b02cd
13 changed files with 154 additions and 145 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
column_width = 120 column_width = 80
line_endings = "Unix" line_endings = "Unix"
indent_type = "Spaces" indent_type = "Spaces"
indent_width = 4 indent_width = 4
quote_style = "AutoPreferDouble" quote_style = "AutoPreferDouble"
call_parentheses = "None" call_parentheses = "None"
collapse_simple_statement = "Always"
+6 -4
View File
@@ -6,12 +6,14 @@ local neoformat_group = augroup("NeoformatOnSave", { clear = true })
autocmd("BufWritePost", { autocmd("BufWritePost", {
group = neoformat_group, group = neoformat_group,
callback = function() callback = function()
if vim.bo.buftype ~= "" or vim.bo.modifiable == false or vim.bo.readonly then if
return vim.bo.buftype ~= ""
end or vim.bo.modifiable == false
if vim.fn.exists ":Neoformat" ~= 2 then or vim.bo.readonly
then
return return
end end
if vim.fn.exists ":Neoformat" ~= 2 then return end
vim.cmd "silent! Neoformat" vim.cmd "silent! Neoformat"
end, end,
}) })
+9 -5
View File
@@ -1,10 +1,16 @@
require("bufferline").setup { require("bufferline").setup {
options = { options = {
diagnostics = "coc", diagnostics = "coc",
diagnostics_indicator = function(count, level, diagnostics_dict, context) diagnostics_indicator = function(
count,
level,
diagnostics_dict,
context
)
local s = " " local s = " "
for e, n in pairs(diagnostics_dict) do 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 s = s .. n .. sym
end end
return s return s
@@ -16,9 +22,7 @@ require("bufferline").setup {
}, },
vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, { vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, {
callback = function() callback = function()
vim.schedule(function() vim.schedule(function() pcall(nvim_bufferline) end)
pcall(nvim_bufferline)
end)
end, end,
}), }),
}, },
+7 -5
View File
@@ -3,8 +3,12 @@ local cmp_lsp = require "cmp_nvim_lsp"
local M = {} local M = {}
M.capabilities = M.capabilities = vim.tbl_deep_extend(
vim.tbl_deep_extend("force", {}, vim.lsp.protocol.make_client_capabilities(), cmp_lsp.default_capabilities()) "force",
{},
vim.lsp.protocol.make_client_capabilities(),
cmp_lsp.default_capabilities()
)
local cmp_kinds = { local cmp_kinds = {
Text = "", Text = "",
@@ -47,9 +51,7 @@ cmp.setup {
}, },
completion = { completeopt = "menu,menuone" }, completion = { completeopt = "menu,menuone" },
snippet = { snippet = {
expand = function(args) expand = function(args) require("luasnip").lsp_expand(args.body) end,
require("luasnip").lsp_expand(args.body)
end,
}, },
mapping = { -- change later zach is ???? mapping = { -- change later zach is ????
["<C-d>"] = cmp.mapping.scroll_docs(-4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
+9 -2
View File
@@ -7,7 +7,10 @@ dap.adapters.python = function(cb, config)
local host = (config.connect or config).host or "127.0.0.1" local host = (config.connect or config).host or "127.0.0.1"
cb { cb {
type = "server", 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, host = host,
options = { source_filetype = "python" }, options = { source_filetype = "python" },
} }
@@ -59,7 +62,11 @@ dap.configurations.cpp = {
type = "lldb", type = "lldb",
request = "launch", request = "launch",
program = function() 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, end,
cwd = "${workspaceFolder}", cwd = "${workspaceFolder}",
stopOnEntry = false, stopOnEntry = false,
+5 -15
View File
@@ -6,22 +6,14 @@ local function on_attach(bufnr)
end end
map("n", "]g", function() map("n", "]g", function()
if vim.wo.diff then if vim.wo.diff then return "]g" end
return "]g" vim.schedule(function() gs.next_hunk() end)
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>" return "<Ignore>"
end, "Next hunk") end, "Next hunk")
map("n", "[g", function() map("n", "[g", function()
if vim.wo.diff then if vim.wo.diff then return "[g" end
return "[g" vim.schedule(function() gs.prev_hunk() end)
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>" return "<Ignore>"
end, "Prev hunk") end, "Prev hunk")
@@ -30,9 +22,7 @@ local function on_attach(bufnr)
map("n", "<leader>hp", gs.preview_hunk, "Preview hunk") map("n", "<leader>hp", gs.preview_hunk, "Preview hunk")
map("n", "<leader>hb", gs.blame_line, "Blame line") map("n", "<leader>hb", gs.blame_line, "Blame line")
map("n", "<leader>hd", gs.diffthis, "Diff this") map("n", "<leader>hd", gs.diffthis, "Diff this")
map("n", "<leader>hD", function() map("n", "<leader>hD", function() gs.diffthis "~" end, "Diff against ~")
gs.diffthis "~"
end, "Diff against ~")
map("n", "<leader>htb", gs.toggle_current_line_blame, "Toggle line blame") map("n", "<leader>htb", gs.toggle_current_line_blame, "Toggle line blame")
map("n", "<leader>htd", gs.toggle_deleted, "Toggle deleted") map("n", "<leader>htd", gs.toggle_deleted, "Toggle deleted")
end end
+8 -2
View File
@@ -21,6 +21,12 @@ hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
end) end)
vim.g.rainbow_delimiters = { highlight = highlight } 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
)
+15 -16
View File
@@ -1,7 +1,9 @@
local fn = vim.fn local fn = vim.fn
local function get_coc_lsp_client() 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 for _, client in pairs(clients) do
if client["state"] == "running" then if client["state"] == "running" then
local client_name = client["id"] local client_name = client["id"]
@@ -14,9 +16,7 @@ local function get_coc_lsp_client()
end end
local function spell() local function spell()
if vim.o.spell then if vim.o.spell then return string.format "[SPELL]" end
return string.format "[SPELL]"
end
return "" return ""
end end
@@ -24,11 +24,10 @@ end
--- show indicator for Chinese IME --- show indicator for Chinese IME
local function ime_state() local function ime_state()
if vim.g.is_mac then 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)]]) local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
if res ~= -1 then if res ~= -1 then return "[CN]" end
return "[CN]"
end
end end
return "" return ""
@@ -36,24 +35,21 @@ end
local diff = function() local diff = function()
local git_status = vim.b.gitsigns_status_dict local git_status = vim.b.gitsigns_status_dict
if git_status == nil then if git_status == nil then return end
return
end
local modify_num = git_status.changed local modify_num = git_status.changed
local remove_num = git_status.removed local remove_num = git_status.removed
local add_num = git_status.added 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) -- vim.print(info)
return info return info
end end
local virtual_env = function() local virtual_env = function()
-- only show virtual env for Python -- only show virtual env for Python
if vim.bo.filetype ~= "python" then if vim.bo.filetype ~= "python" then return "" end
return ""
end
local conda_env = os.getenv "CONDA_DEFAULT_ENV" local conda_env = os.getenv "CONDA_DEFAULT_ENV"
local venv_path = os.getenv "VIRTUAL_ENV" local venv_path = os.getenv "VIRTUAL_ENV"
@@ -116,7 +112,10 @@ require("lualine").setup {
}, },
lualine_y = { lualine_y = {
{ "encoding", fmt = string.upper }, { "encoding", fmt = string.upper },
{ "fileformat", symbols = { unix = "", dos = "", mac = "" } }, {
"fileformat",
symbols = { unix = "", dos = "", mac = "" },
},
"filetype", "filetype",
}, },
lualine_z = { "progress" }, lualine_z = { "progress" },
+55 -33
View File
@@ -26,9 +26,7 @@ require("notify").setup {
local client_notifs = {} local client_notifs = {}
local function get_notif_data(client_id, token) local function get_notif_data(client_id, token)
if not client_notifs[client_id] then if not client_notifs[client_id] then client_notifs[client_id] = {} end
client_notifs[client_id] = {}
end
if not client_notifs[client_id][token] then if not client_notifs[client_id][token] then
client_notifs[client_id][token] = {} client_notifs[client_id][token] = {}
@@ -37,7 +35,8 @@ local function get_notif_data(client_id, token)
return client_notifs[client_id][token] return client_notifs[client_id][token]
end end
local spinner_frames = { "", "", "", "", "", "", "", "" } local spinner_frames =
{ "", "", "", "", "", "", "", "" }
local function update_spinner(client_id, token) local function update_spinner(client_id, token)
local notif_data = get_notif_data(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, replace = notif_data.notification,
}) })
vim.defer_fn(function() vim.defer_fn(function() update_spinner(client_id, token) end, 100)
update_spinner(client_id, token)
end, 100)
end end
end end
@@ -74,9 +71,7 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
local val = result.value local val = result.value
if not val.kind then if not val.kind then return end
return
end
local notif_data = get_notif_data(client_id, result.token) 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) local message = format_message(val.message, val.percentage)
notif_data.notification = vim.notify(message, "info", { 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], icon = spinner_frames[1],
timeout = false, timeout = false,
hide_from_history = false, hide_from_history = false,
@@ -93,16 +91,21 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
notif_data.spinner = 1 notif_data.spinner = 1
update_spinner(client_id, result.token) update_spinner(client_id, result.token)
elseif val.kind == "report" and notif_data then elseif val.kind == "report" and notif_data then
notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", { notif_data.notification =
replace = notif_data.notification, vim.notify(format_message(val.message, val.percentage), "info", {
hide_from_history = false, replace = notif_data.notification,
}) hide_from_history = false,
})
elseif val.kind == "end" and notif_data then elseif val.kind == "end" and notif_data then
notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", { notif_data.notification = vim.notify(
icon = "", val.message and format_message(val.message) or "Complete",
replace = notif_data.notification, "info",
timeout = 6000, {
}) icon = "",
replace = notif_data.notification,
timeout = 6000,
}
)
notif_data.spinner = nil notif_data.spinner = nil
end end
@@ -111,14 +114,22 @@ end
-- table from lsp severity to vim severity. -- table from lsp severity to vim severity.
local severity = { "error", "warn", "info" } 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]) vim.notify(method.message, severity[params.type])
end end
-- DAP integration -- DAP integration
-- Make sure to also have the snippet with the common helper functions in your config! -- 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 notif_data = get_notif_data("dap", body.progressId)
local message = format_message(body.message, body.percentage) 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) notif_data.notification.spinner = 1, update_spinner("dap", body.progressId)
end 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) local notif_data = get_notif_data("dap", body.progressId)
notif_data.notification = vim.notify(format_message(body.message, body.percentage), "info", { notif_data.notification =
replace = notif_data.notification, vim.notify(format_message(body.message, body.percentage), "info", {
hide_from_history = false, replace = notif_data.notification,
}) hide_from_history = false,
})
end 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] local notif_data = client_notifs["dap"][body.progressId]
notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", { notif_data.notification = vim.notify(
icon = "", body.message and format_message(body.message) or "Complete",
replace = notif_data.notification, "info",
timeout = 6000, {
}) icon = "",
replace = notif_data.notification,
timeout = 6000,
}
)
notif_data.spinner = nil notif_data.spinner = nil
end end
+2 -6
View File
@@ -1,12 +1,8 @@
if not vim.F then if not vim.F then vim.F = {} end
vim.F = {}
end
if not vim.F.if_nil and not vim.nonnil then if not vim.F.if_nil and not vim.nonnil then
vim.F.if_nil = function(value, default) vim.F.if_nil = function(value, default)
if value == nil then if value == nil then return default end
return default
end
return value return value
end end
end end
+8 -7
View File
@@ -1,9 +1,7 @@
local map = vim.keymap.set local map = vim.keymap.set
local default_opts = { noremap = true } local default_opts = { noremap = true }
map("n", "<leader>n", function() map("n", "<leader>n", function() Snacks.notifier.show_history() end)
Snacks.notifier.show_history()
end)
map( map(
"n", "n",
@@ -34,7 +32,12 @@ map("n", "<A-k>", "<C-w>k", { desc = "Move to top split" })
map("n", "<A-l>", "<C-w>l", { desc = "Move to right split" }) map("n", "<A-l>", "<C-w>l", { desc = "Move to right split" })
map("n", "<leader>e", vim.cmd.NvimTreeToggle) map("n", "<leader>e", vim.cmd.NvimTreeToggle)
map("n", "<leader>u", require("undotree").toggle, { noremap = true, silent = true }) map(
"n",
"<leader>u",
require("undotree").toggle,
{ noremap = true, silent = true }
)
map("n", "<A-->", ":bdelete<CR>") map("n", "<A-->", ":bdelete<CR>")
-- map("n", "<SA-->", ":BufferRestore<CR>") -- map("n", "<SA-->", ":BufferRestore<CR>")
@@ -67,6 +70,4 @@ map("i", "<C-c>", "<Esc>")
map("n", "<leader>mr", "<cmd>CellularAutomaton make_it_rain<CR>") map("n", "<leader>mr", "<cmd>CellularAutomaton make_it_rain<CR>")
map("n", "<leader><leader>", function() map("n", "<leader><leader>", function() vim.cmd "so" end)
vim.cmd "so"
end)
+6 -5
View File
@@ -22,7 +22,8 @@ vim.opt.updatetime = 50
vim.opt.textwidth = 0 vim.opt.textwidth = 0
vim.opt.colorcolumn = "100" vim.opt.colorcolumn = "100"
vim.opt.formatoptions = "rqnj" 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.laststatus = 0
vim.o.clipboard = "unnamedplus" vim.o.clipboard = "unnamedplus"
vim.o.cursorline = true vim.o.cursorline = true
@@ -47,8 +48,8 @@ vim.g.loaded_ruby_provider = 0
local is_windows = vim.fn.has "win32" ~= 0 local is_windows = vim.fn.has "win32" ~= 0
local sep = is_windows and "\\" or "/" local sep = is_windows and "\\" or "/"
local delim = 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.api.nvim_create_user_command("Nf", function() vim.cmd "Neoformat" end, {})
vim.cmd "Neoformat"
end, {})
+22 -44
View File
@@ -4,21 +4,23 @@ return {
}, },
{ {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
config = function() config = function() require "config.gitsigns" end,
require "config.gitsigns" },
end, {
"vimpostor/vim-tpipeline",
}, },
{ "vimpostor/vim-tpipeline" },
{ {
"aznhe21/actions-preview.nvim", "aznhe21/actions-preview.nvim",
config = function() config = function() require "config.actions-preview" end,
require "config.actions-preview"
end,
}, },
{ {
"sbdchd/neoformat", "sbdchd/neoformat",
init = function() 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, end,
}, },
{ {
@@ -62,90 +64,66 @@ return {
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
}, },
config = function() config = function() require "config.lspconfig" end,
require "config.lspconfig"
end,
}, },
{ {
"https://gitlab.com/itaranto/plantuml.nvim", "https://gitlab.com/itaranto/plantuml.nvim",
version = "*", version = "*",
config = function() config = function() require("plantuml").setup() end,
require("plantuml").setup()
end,
}, },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
lazy = false, lazy = false,
branch = "main", branch = "main",
build = ":TSUpdate", build = ":TSUpdate",
config = function() config = function() require "config.treesitter" end,
require "config.treesitter"
end,
}, },
{ {
"rmagatti/auto-session", "rmagatti/auto-session",
config = function() config = function() require "config.autosession" end,
require "config.autosession"
end,
}, },
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
config = function() config = function() require "config.telescope" end,
require "config.telescope"
end,
}, },
{ "lambdalisue/vim-suda" }, { "lambdalisue/vim-suda" },
{ "nvim-tree/nvim-web-devicons" }, { "nvim-tree/nvim-web-devicons" },
{ {
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
cmd = { "NvimTreeToggle", "NvimTreeFocus" }, cmd = { "NvimTreeToggle", "NvimTreeFocus" },
config = function() config = function() require "config.nvimtree" end,
require "config.nvimtree"
end,
}, },
{ {
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
event = "VeryLazy", event = "VeryLazy",
config = function() config = function() require "config.barbar" end,
require "config.barbar"
end,
}, },
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
event = "VeryLazy", event = "VeryLazy",
config = function() config = function() require "config.lualine" end,
require "config.lualine"
end,
}, },
{ {
"jiaoshijie/undotree", "jiaoshijie/undotree",
config = function() config = function() require "config.undotree" end,
require "config.undotree"
end,
}, },
{ "hiphish/rainbow-delimiters.nvim" }, { "hiphish/rainbow-delimiters.nvim" },
{ {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
event = "InsertEnter", event = "InsertEnter",
config = function() config = function() require "config.autopairs" end,
require "config.autopairs"
end,
}, },
{ "tpope/vim-fugitive" }, { "tpope/vim-fugitive" },
{ {
"catgoose/nvim-colorizer.lua", "catgoose/nvim-colorizer.lua",
config = function() config = function() require "config.colorizer" end,
require "config.colorizer"
end,
}, },
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 }, { "catppuccin/nvim", name = "catppuccin", priority = 1000 },
{ "ellisonleao/gruvbox.nvim", priority = 1000, config = true, opts = ... }, { "ellisonleao/gruvbox.nvim", priority = 1000, config = true, opts = ... },
{ {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
config = function() config = function() require "config.dap" end,
require "config.dap"
end,
}, },
{ {
"MeanderingProgrammer/render-markdown.nvim", "MeanderingProgrammer/render-markdown.nvim",