refactor: centralize configuration data to require data module

This commit is contained in:
2024-08-23 10:04:54 -04:00
parent a6e251fe2a
commit 9a6d4e4158
7 changed files with 54 additions and 351 deletions
+1 -42
View File
@@ -11,48 +11,7 @@ return {
silent = true, silent = true,
debounce = false, debounce = false,
}, },
keys = { keys = require("data.keys").neocodeium,
{ -- Accept suggestion
"<c-y>",
function()
require("neocodeium").accept()
end,
desc = "Accept suggestion",
mode = "i",
},
{ -- Accept word
"<c-w>",
function()
require("neocodeium").accept_word()
end,
desc = "Accept word",
mode = "i",
},
{ -- Accept line
"<c-l>",
function()
require("neocodeium").accept_line()
end,
desc = "Accept line",
mode = "i",
},
{ -- Cycle or complete (previous)
"<c-p>",
function()
require("neocodeium").cycle_or_complete(-1)
end,
desc = "Cycle or complete (previous)",
mode = "i",
},
{ -- Cycle or complete (next)
"<c-n>",
function()
require("neocodeium").cycle_or_complete()
end,
desc = "Cycle or complete (next)",
mode = "i",
},
},
}, },
{ -- Copilot { -- Copilot
import = "lazyvim.plugins.extras.coding.copilot", import = "lazyvim.plugins.extras.coding.copilot",
+1 -2
View File
@@ -59,7 +59,6 @@ return {
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
local luasnip = require("luasnip") local luasnip = require("luasnip")
local lspkind = require("lspkind")
local neocodeium = require("neocodeium") local neocodeium = require("neocodeium")
local commands = require("neocodeium.commands") local commands = require("neocodeium.commands")
@@ -154,7 +153,7 @@ return {
}) })
-- List of filetypes to disable completion -- List of filetypes to disable completion
local disabled_filetypes = { "dashboard", "qalc" } local disabled_filetypes = require("data.types").cmp
for _, filetype in ipairs(disabled_filetypes) do for _, filetype in ipairs(disabled_filetypes) do
cmp.setup.filetype(filetype, { cmp.setup.filetype(filetype, {
sources = {}, sources = {},
+1 -3
View File
@@ -18,9 +18,7 @@ return {
{ -- Bufferline { -- Bufferline
"akinsho/bufferline.nvim", "akinsho/bufferline.nvim",
opts = { opts = {
options = { options = require("data.types").bufferline,
separator_style = "slant",
},
}, },
}, },
{ -- Which-Key { -- Which-Key
+29 -118
View File
@@ -9,46 +9,23 @@ return {
{ -- Octo plugin { -- Octo plugin
import = "lazyvim.plugins.extras.util.octo", import = "lazyvim.plugins.extras.util.octo",
}, },
{ -- DiffView
"sindrets/diffview.nvim",
lazy = true,
cmd = require("data.cmd").diffview,
},
{ -- Gist Tools { -- Gist Tools
"Rawnly/gist.nvim", "Rawnly/gist.nvim",
lazy = true, lazy = true,
cmd = { cmd = require("data.cmd").gist,
"GistCreate", keys = require("data.keys").gist,
"GistCreateFromFile",
"GistsList",
},
keys = {
{ -- Create Gist
"<leader>gnc",
"<cmd>GistCreate<cr>",
desc = "Create Gist",
mode = { "n", "x" },
},
{ -- Find Gists
"<leader>gnf",
"<cmd>GistList<cr>",
desc = "Find Gists",
},
},
config = true, config = true,
}, },
{ -- LazyGit { -- LazyGit
"kdheepak/lazygit.nvim", "kdheepak/lazygit.nvim",
lazy = true, lazy = true,
cmd = { cmd = require("data.cmd").lazygit,
"LazyGit", keys = require("data.keys").lazygit,
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
keys = {
{ -- LazyGit
"<leader>lg",
"<cmd>LazyGit<cr>",
desc = "LazyGit",
},
},
dependencies = { dependencies = {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
@@ -60,12 +37,7 @@ return {
{ -- Thanks/github-stars { -- Thanks/github-stars
"jsongerber/thanks.nvim", "jsongerber/thanks.nvim",
lazy = true, lazy = true,
cmd = { cmd = require("data.cmd").thanks,
"ThanksAll",
"ThanksGithubAuth",
"ThanksGithubLogout",
"ThanksClearCache",
},
opts = { opts = {
star_on_install = false, star_on_install = false,
}, },
@@ -73,22 +45,9 @@ return {
{ -- GitLinker { -- GitLinker
"linrongbin16/gitlinker.nvim", "linrongbin16/gitlinker.nvim",
lazy = true, lazy = true,
cmd = "GitLink", cmd = require("data.cmd").gitlinker,
opts = {}, opts = {},
keys = { keys = require("data.keys").gitlinker,
{ -- Yank git link
"<leader>gy",
"<cmd>GitLink<cr>",
mode = { "n", "v" },
desc = "Yank git link",
},
{ -- Open git link
"<leader>gY",
"<cmd>GitLink!<cr>",
mode = { "n", "v" },
desc = "Open git link",
},
},
}, },
{ -- Git Blame { -- Git Blame
"f-person/git-blame.nvim", "f-person/git-blame.nvim",
@@ -97,84 +56,46 @@ return {
-- Get the current lualine configuration -- Get the current lualine configuration
local config = require("lualine").get_config() local config = require("lualine").get_config()
local git_blame = require("gitblame") local git_blame = require("gitblame")
local rootilities = require("utils.rootiest") local utils = require("utils.rootiest")
-- Define the width limit for displaying the Git blame component -- Define the width limit for displaying the Git blame component
local width_limit = 180 -- Adjust this value as needed local width_limit = 180 -- Adjust this value as needed
-- Add Git-blame to lualine_c section -- Add Git-blame to lualine_c section
table.insert(config.sections.lualine_c, { table.insert(config.sections.lualine_c, {
git_blame.get_current_blame_text, git_blame.get_current_blame_text,
cond = function() -- Only show the component if the text is available cond = function() -- Only show if text is available
return git_blame.is_blame_text_available() return git_blame.is_blame_text_available()
and rootilities.is_window_wide_enough(width_limit) and utils.is_window_wide_enough(width_limit)
end, end,
color = { fg = rootilities.get_fg_color("GitSignsCurrentLineBlame") }, color = { fg = utils.get_fg_color("GitSignsCurrentLineBlame") },
}) })
-- Apply the lualine configuration -- Apply the lualine configuration
require("lualine").setup(config) require("lualine").setup(config)
-- Define git-blame options
local git_ops = {
display_virtual_text = 0, -- Disable virtual text
date_format = "%r", -- Relative date format
message_when_not_committed = " Not yet committed",
message_template = "<author> • <date> • <summary>",
}
-- Return the git-blame options -- Return the git-blame options
return git_ops return require("data.types").gitblame
end, end,
}, },
{ -- Git Graph { -- Git Graph
"isakbm/gitgraph.nvim", "isakbm/gitgraph.nvim",
opts = { opts = {
symbols = { symbols = require("data.types").gitgraph.symbols(),
merge_commit = "",
commit = "",
merge_commit_end = "",
commit_end = "",
-- Advanced symbols
GVER = "",
GHOR = "",
GCLD = "",
GCRD = "",
GCLU = "",
GCRU = "",
GLRU = "",
GLRD = "",
GLUD = "",
GRUD = "",
GFORKU = "",
GFORKD = "",
GRUDCD = "",
GRUDCU = "",
GLUDCD = "",
GLUDCU = "",
GLRDCL = "",
GLRDCR = "",
GLRUCL = "",
GLRUCR = "",
},
format = { format = {
timestamp = "%H:%M:%S %d-%m-%Y", timestamp = require("data.types").gitgraph.timestamp,
fields = { "hash", "timestamp", "author", "branch_name", "tag" }, fields = require("data.types").gitgraph.fields,
}, },
hooks = { hooks = {
-- Check diff of a commit
on_select_commit = function(commit) on_select_commit = function(commit)
print("selected commit:", commit.hash) vim.notify("DiffviewOpen " .. commit.hash .. "^!")
vim.cmd(":DiffviewOpen " .. commit.hash .. "^!")
end, end,
-- Check diff from commit a -> commit b
on_select_range_commit = function(from, to) on_select_range_commit = function(from, to)
print("selected range:", from.hash, to.hash) vim.notify("DiffviewOpen " .. from.hash .. "~1.." .. to.hash)
vim.cmd(":DiffviewOpen " .. from.hash .. "~1.." .. to.hash)
end, end,
}, },
}, },
keys = { keys = require("data.keys").gitgraph,
{ -- gitgraph_toggle
"<leader>gm",
function()
require("utils.git").gitgraph_toggle()
end,
desc = "GitGraph - Toggle",
},
},
}, },
{ -- FuGit { -- FuGit
"SuperBo/fugit2.nvim", "SuperBo/fugit2.nvim",
@@ -189,17 +110,7 @@ return {
dependencies = { "stevearc/dressing.nvim" }, dependencies = { "stevearc/dressing.nvim" },
}, },
}, },
cmd = { cmd = require("data.cmd").fugit,
"Fugit2", keys = require("data.keys").fugit,
"Fugit2Diff",
"Fugit2Graph",
},
keys = {
{ -- Open Fugit
"<leader>F",
mode = "n",
"<cmd>Fugit2<cr>",
},
},
}, },
} }
+9 -93
View File
@@ -18,7 +18,7 @@ return {
}, },
{ -- Image Renderer { -- Image Renderer
"3rd/image.nvim", "3rd/image.nvim",
ft = "markdown", ft = require("data.types").image,
config = function() config = function()
require("image").setup() require("image").setup()
end, end,
@@ -27,64 +27,20 @@ return {
{ -- ToggleTerm { -- ToggleTerm
"akinsho/toggleterm.nvim", "akinsho/toggleterm.nvim",
event = "VeryLazy", event = "VeryLazy",
keys = { keys = require("data.keys").toggleterm,
{ -- Toggle Terminal
"<c-/>",
"<cmd>ToggleTerm<cr>",
desc = "Toggle Terminal",
mode = "n",
},
},
config = function() config = function()
require("toggleterm").setup({ require("toggleterm").setup(require("data.types").toggleterm)
-- size can be a number or function which is passed the current terminal
size = function(term)
if term.direction == "horizontal" then
return 10
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
open_mapping = [[<c-\>]],
hide_numbers = true,
autochdir = true,
shade_terminals = false,
start_in_insert = true,
insert_mappings = true,
terminal_mappings = true,
persist_size = true,
persist_mode = true,
direction = "horizontal",
close_on_exit = true,
shell = vim.o.shell,
auto_scroll = true,
float_opts = {
border = "curved",
winblend = 3,
title_pos = "center",
},
winbar = {
enabled = true,
name_formatter = function(term) -- term: Terminal
return term.name
end,
},
})
end, end,
}, },
{ -- Kitty-Runner { -- Kitty-Runner
"jghauser/kitty-runner.nvim", "jghauser/kitty-runner.nvim",
cond = function() -- Using Kitty cond = require("data.func").is_kitty(),
local term = os.getenv("TERM") or ""
local kit = string.find(term, "kitty")
return kit ~= nil
end,
}, },
{ -- Kitty-Scrollback { -- Kitty-Scrollback
"mikesmithgh/kitty-scrollback.nvim", "mikesmithgh/kitty-scrollback.nvim",
enabled = true, enabled = true,
lazy = true, lazy = true,
cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" }, cmd = require("data.cmd").kitty_scrollback,
event = { "User KittyScrollbackLaunch" }, event = { "User KittyScrollbackLaunch" },
version = "*", version = "*",
config = function() -- Using Kitty-Scrollback config = function() -- Using Kitty-Scrollback
@@ -96,41 +52,12 @@ return {
{ -- Nekifoch { -- Nekifoch
"NeViRAIDE/nekifoch.nvim", "NeViRAIDE/nekifoch.nvim",
lazy = true, lazy = true,
cmd = "Nekifoch", cmd = require("data.cmd").nekifoch,
opts = { opts = {
kitty_conf_path = vim.env.HOME .. "/.kittyoverrides", kitty_conf_path = vim.env.HOME .. "/.kittyoverrides",
}, },
keys = { keys = require("data.keys").nekifoch,
{ -- List Fonts cond = require("data.func").is_kitty(),
"<leader>u,l",
"<cmd>Nekifoch list<cr>",
desc = "Fonts list",
},
{ -- Check Font
"<leader>u,c",
"<cmd>Nekifoch check<cr>",
desc = "Check current font settings",
},
{ -- Set Font Family
"<leader>u,f",
function()
require("nekifoch.nui_set_font")()
end,
desc = "Set font family",
},
{ -- Set Font Size
"<leader>u,s",
function()
require("nekifoch.nui_set_size")()
end,
desc = "Set font size",
},
},
cond = function() -- Using Kitty
local term = os.getenv("TERM") or ""
local kit = string.find(term, "kitty")
return kit ~= nil
end,
}, },
{ -- WezTerm { -- WezTerm
"willothy/wezterm.nvim", "willothy/wezterm.nvim",
@@ -145,17 +72,6 @@ return {
config = function() config = function()
return require("tmux").setup() return require("tmux").setup()
end, end,
cond = function() -- Using Tmux cond = require("data.func").is_tmux(),
local tterm = os.getenv("TERM")
if tterm and string.find(tterm, "screen") then
if os.getenv("TMUX") then
return true
end
else
if tterm and string.find(tterm, "tmux") then
return true
end
end
end,
}, },
} }
+2 -4
View File
@@ -125,6 +125,7 @@ return {
"xiyaowong/transparent.nvim", "xiyaowong/transparent.nvim",
lazy = true, lazy = true,
config = true, config = true,
keys = { keys = {
{ {
"<leader>wt", "<leader>wt",
@@ -158,9 +159,6 @@ return {
) )
end, end,
}, },
cond = function() -- Not Using SSH cond = not require("data.func").is_ssh(),
local ssh = os.getenv("SSH_TTY") or false
return not ssh
end,
}, },
} }
+11 -89
View File
@@ -16,15 +16,8 @@ return {
{ -- Link following { -- Link following
"chrishrb/gx.nvim", "chrishrb/gx.nvim",
lazy = true, lazy = true,
cmd = { "Browse" }, cmd = require("data.cmd").gx,
keys = { keys = require("data.keys").gx,
{ -- Open URL/Link
"gx",
"<cmd>Browse<cr>",
mode = { "n", "x" },
desc = "Open URL/Link",
},
},
init = function() init = function()
vim.g.netrw_nogx = 1 vim.g.netrw_nogx = 1
end, end,
@@ -33,7 +26,7 @@ return {
}, },
{ -- Auto-save { -- Auto-save
"okuuva/auto-save.nvim", "okuuva/auto-save.nvim",
cmd = "ASToggle", cmd = require("data.cmd").autosave,
event = { "InsertLeave", "TextChanged" }, event = { "InsertLeave", "TextChanged" },
opts = { opts = {
execution_message = { execution_message = {
@@ -44,17 +37,8 @@ return {
{ -- Ripgrep substitute { -- Ripgrep substitute
"chrisgrieser/nvim-rip-substitute", "chrisgrieser/nvim-rip-substitute",
event = "InsertEnter", event = "InsertEnter",
cmd = "RipSubstitute", cmd = require("data.cmd").ripsub,
keys = { keys = require("data.keys").ripsub,
{ -- Rip Substitute
"<leader>fs",
function()
require("rip-substitute").sub()
end,
mode = { "n", "x" },
desc = "Rip Substitute",
},
},
}, },
{ -- Unception { -- Unception
"samjwill/nvim-unception", "samjwill/nvim-unception",
@@ -68,24 +52,7 @@ return {
config = function() config = function()
require("icon-picker").setup({ disable_legacy_commands = true }) require("icon-picker").setup({ disable_legacy_commands = true })
end, end,
keys = { keys = require("data.keys").iconpicker,
{ -- Pick Icon
"<leader>Ii",
"<cmd>IconPickerNormal<cr>",
desc = "Pick Icon",
},
{ -- Yank Icon
"<leader>Iy",
"<cmd>IconPickerYank<cr>",
desc = "Yank Icon",
},
{ -- Insert Icon in insert mode
"<C-.>",
"<cmd>IconPickerInsert<cr>",
desc = "Insert Icon",
mode = "i",
},
},
}, },
{ -- Codesnap { -- Codesnap
"mistricky/codesnap.nvim", "mistricky/codesnap.nvim",
@@ -100,38 +67,8 @@ return {
code_font_family = "Iosevka NF", code_font_family = "Iosevka NF",
code_font_size = 12, code_font_size = 12,
}, },
cmd = { cmd = require("data.cmd").codesnap,
"CodeSnap", keys = require("data.keys").codesnap,
"CodeSnapSave",
"CodeSnapHighlight",
"CodeSnapASCII",
},
keys = {
{ -- Save selected code snapshot into clipboard
"<leader>cy",
"<cmd>CodeSnap<cr>",
desc = "Save selected code snapshot into clipboard",
mode = "x",
},
{ -- Save selected code snapshot in ~/Pictures
"<leader>cs",
"<cmd>CodeSnapSave<cr>",
desc = "Save selected code snapshot in ~/Pictures",
mode = "x",
},
{ -- Highlight and snapshot selected code into clipboard
"<leader>ch",
"<cmd>CodeSnapHighlight<cr>",
desc = "Highlight and snapshot selected code into clipboard",
mode = "x",
},
{ -- Save ASCII code snapshot into clipboard
"<leader>ci",
"<cmd>CodeSnapASCII<cr>",
desc = "Save ASCII code snapshot into clipboard",
mode = "x",
},
},
}, },
{ -- Kulala { -- Kulala
"mistweaverco/kulala.nvim", "mistweaverco/kulala.nvim",
@@ -151,16 +88,7 @@ return {
"dmtrKovalenko/caps-word.nvim", "dmtrKovalenko/caps-word.nvim",
lazy = true, lazy = true,
opts = {}, opts = {},
keys = { keys = require("data.keys").capsword,
{
"<C-s>",
function()
require("caps-word").toggle()
end,
desc = "Toggle CapsWord",
mode = { "i", "n" },
},
},
}, },
{ -- Music Controls { -- Music Controls
"AntonVanAssche/music-controls.nvim", "AntonVanAssche/music-controls.nvim",
@@ -171,14 +99,8 @@ return {
}, },
{ -- Qalc { -- Qalc
"Apeiros-46B/qalc.nvim", "Apeiros-46B/qalc.nvim",
cmd = { cmd = require("data.cmd").qalc,
"Qalc", keys = require("data.keys").qalc,
"QalcAttach",
"QalcYank",
},
keys = {
{ "<leader>qc", "<cmd>Qalc<cr>", desc = "Qalc" },
},
opts = { opts = {
set_ft = "qalc", set_ft = "qalc",
}, },