diff --git a/lua/plugins/ai.lua b/lua/plugins/ai.lua index 0c0226d..21da92f 100644 --- a/lua/plugins/ai.lua +++ b/lua/plugins/ai.lua @@ -11,48 +11,7 @@ return { silent = true, debounce = false, }, - keys = { - { -- Accept suggestion - "", - function() - require("neocodeium").accept() - end, - desc = "Accept suggestion", - mode = "i", - }, - { -- Accept word - "", - function() - require("neocodeium").accept_word() - end, - desc = "Accept word", - mode = "i", - }, - { -- Accept line - "", - function() - require("neocodeium").accept_line() - end, - desc = "Accept line", - mode = "i", - }, - { -- Cycle or complete (previous) - "", - function() - require("neocodeium").cycle_or_complete(-1) - end, - desc = "Cycle or complete (previous)", - mode = "i", - }, - { -- Cycle or complete (next) - "", - function() - require("neocodeium").cycle_or_complete() - end, - desc = "Cycle or complete (next)", - mode = "i", - }, - }, + keys = require("data.keys").neocodeium, }, { -- Copilot import = "lazyvim.plugins.extras.coding.copilot", diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 9a4ef30..a6b75ea 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -59,7 +59,6 @@ return { config = function() local cmp = require("cmp") local luasnip = require("luasnip") - local lspkind = require("lspkind") local neocodeium = require("neocodeium") local commands = require("neocodeium.commands") @@ -154,7 +153,7 @@ return { }) -- 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 cmp.setup.filetype(filetype, { sources = {}, diff --git a/lua/plugins/core.lua b/lua/plugins/core.lua index e76ae21..57631ab 100644 --- a/lua/plugins/core.lua +++ b/lua/plugins/core.lua @@ -18,9 +18,7 @@ return { { -- Bufferline "akinsho/bufferline.nvim", opts = { - options = { - separator_style = "slant", - }, + options = require("data.types").bufferline, }, }, { -- Which-Key diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua index 772af6d..fc897ca 100644 --- a/lua/plugins/git.lua +++ b/lua/plugins/git.lua @@ -9,46 +9,23 @@ return { { -- Octo plugin import = "lazyvim.plugins.extras.util.octo", }, + { -- DiffView + "sindrets/diffview.nvim", + lazy = true, + cmd = require("data.cmd").diffview, + }, { -- Gist Tools "Rawnly/gist.nvim", lazy = true, - cmd = { - "GistCreate", - "GistCreateFromFile", - "GistsList", - }, - keys = { - { -- Create Gist - "gnc", - "GistCreate", - desc = "Create Gist", - mode = { "n", "x" }, - }, - { -- Find Gists - "gnf", - "GistList", - desc = "Find Gists", - }, - }, + cmd = require("data.cmd").gist, + keys = require("data.keys").gist, config = true, }, { -- LazyGit "kdheepak/lazygit.nvim", lazy = true, - cmd = { - "LazyGit", - "LazyGitConfig", - "LazyGitCurrentFile", - "LazyGitFilter", - "LazyGitFilterCurrentFile", - }, - keys = { - { -- LazyGit - "lg", - "LazyGit", - desc = "LazyGit", - }, - }, + cmd = require("data.cmd").lazygit, + keys = require("data.keys").lazygit, dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim", @@ -60,12 +37,7 @@ return { { -- Thanks/github-stars "jsongerber/thanks.nvim", lazy = true, - cmd = { - "ThanksAll", - "ThanksGithubAuth", - "ThanksGithubLogout", - "ThanksClearCache", - }, + cmd = require("data.cmd").thanks, opts = { star_on_install = false, }, @@ -73,22 +45,9 @@ return { { -- GitLinker "linrongbin16/gitlinker.nvim", lazy = true, - cmd = "GitLink", + cmd = require("data.cmd").gitlinker, opts = {}, - keys = { - { -- Yank git link - "gy", - "GitLink", - mode = { "n", "v" }, - desc = "Yank git link", - }, - { -- Open git link - "gY", - "GitLink!", - mode = { "n", "v" }, - desc = "Open git link", - }, - }, + keys = require("data.keys").gitlinker, }, { -- Git Blame "f-person/git-blame.nvim", @@ -97,84 +56,46 @@ return { -- Get the current lualine configuration local config = require("lualine").get_config() 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 local width_limit = 180 -- Adjust this value as needed -- Add Git-blame to lualine_c section table.insert(config.sections.lualine_c, { 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() - and rootilities.is_window_wide_enough(width_limit) + and utils.is_window_wide_enough(width_limit) end, - color = { fg = rootilities.get_fg_color("GitSignsCurrentLineBlame") }, + color = { fg = utils.get_fg_color("GitSignsCurrentLineBlame") }, }) -- Apply the lualine configuration 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 = "", - } -- Return the git-blame options - return git_ops + return require("data.types").gitblame end, }, { -- Git Graph "isakbm/gitgraph.nvim", opts = { - 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 = "", - }, + symbols = require("data.types").gitgraph.symbols(), format = { - timestamp = "%H:%M:%S %d-%m-%Y", - fields = { "hash", "timestamp", "author", "branch_name", "tag" }, + timestamp = require("data.types").gitgraph.timestamp, + fields = require("data.types").gitgraph.fields, }, hooks = { + -- Check diff of a commit on_select_commit = function(commit) - print("selected commit:", commit.hash) + vim.notify("DiffviewOpen " .. commit.hash .. "^!") + vim.cmd(":DiffviewOpen " .. commit.hash .. "^!") end, + -- Check diff from commit a -> commit b 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, }, }, - keys = { - { -- gitgraph_toggle - "gm", - function() - require("utils.git").gitgraph_toggle() - end, - desc = "GitGraph - Toggle", - }, - }, + keys = require("data.keys").gitgraph, }, { -- FuGit "SuperBo/fugit2.nvim", @@ -189,17 +110,7 @@ return { dependencies = { "stevearc/dressing.nvim" }, }, }, - cmd = { - "Fugit2", - "Fugit2Diff", - "Fugit2Graph", - }, - keys = { - { -- Open Fugit - "F", - mode = "n", - "Fugit2", - }, - }, + cmd = require("data.cmd").fugit, + keys = require("data.keys").fugit, }, } diff --git a/lua/plugins/terminal.lua b/lua/plugins/terminal.lua index 7cd3ab2..72b6d3f 100644 --- a/lua/plugins/terminal.lua +++ b/lua/plugins/terminal.lua @@ -18,7 +18,7 @@ return { }, { -- Image Renderer "3rd/image.nvim", - ft = "markdown", + ft = require("data.types").image, config = function() require("image").setup() end, @@ -27,64 +27,20 @@ return { { -- ToggleTerm "akinsho/toggleterm.nvim", event = "VeryLazy", - keys = { - { -- Toggle Terminal - "", - "ToggleTerm", - desc = "Toggle Terminal", - mode = "n", - }, - }, + keys = require("data.keys").toggleterm, config = function() - require("toggleterm").setup({ - -- 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 = [[]], - 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, - }, - }) + require("toggleterm").setup(require("data.types").toggleterm) end, }, { -- Kitty-Runner "jghauser/kitty-runner.nvim", - cond = function() -- Using Kitty - local term = os.getenv("TERM") or "" - local kit = string.find(term, "kitty") - return kit ~= nil - end, + cond = require("data.func").is_kitty(), }, { -- Kitty-Scrollback "mikesmithgh/kitty-scrollback.nvim", enabled = true, lazy = true, - cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" }, + cmd = require("data.cmd").kitty_scrollback, event = { "User KittyScrollbackLaunch" }, version = "*", config = function() -- Using Kitty-Scrollback @@ -96,41 +52,12 @@ return { { -- Nekifoch "NeViRAIDE/nekifoch.nvim", lazy = true, - cmd = "Nekifoch", + cmd = require("data.cmd").nekifoch, opts = { kitty_conf_path = vim.env.HOME .. "/.kittyoverrides", }, - keys = { - { -- List Fonts - "u,l", - "Nekifoch list", - desc = "Fonts list", - }, - { -- Check Font - "u,c", - "Nekifoch check", - desc = "Check current font settings", - }, - { -- Set Font Family - "u,f", - function() - require("nekifoch.nui_set_font")() - end, - desc = "Set font family", - }, - { -- Set Font Size - "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, + keys = require("data.keys").nekifoch, + cond = require("data.func").is_kitty(), }, { -- WezTerm "willothy/wezterm.nvim", @@ -145,17 +72,6 @@ return { config = function() return require("tmux").setup() end, - cond = function() -- Using 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, + cond = require("data.func").is_tmux(), }, } diff --git a/lua/plugins/themes.lua b/lua/plugins/themes.lua index 810a928..c886a0c 100644 --- a/lua/plugins/themes.lua +++ b/lua/plugins/themes.lua @@ -125,6 +125,7 @@ return { "xiyaowong/transparent.nvim", lazy = true, config = true, + keys = { { "wt", @@ -158,9 +159,6 @@ return { ) end, }, - cond = function() -- Not Using SSH - local ssh = os.getenv("SSH_TTY") or false - return not ssh - end, + cond = not require("data.func").is_ssh(), }, } diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua index 5e4a520..73fa5c9 100644 --- a/lua/plugins/util.lua +++ b/lua/plugins/util.lua @@ -16,15 +16,8 @@ return { { -- Link following "chrishrb/gx.nvim", lazy = true, - cmd = { "Browse" }, - keys = { - { -- Open URL/Link - "gx", - "Browse", - mode = { "n", "x" }, - desc = "Open URL/Link", - }, - }, + cmd = require("data.cmd").gx, + keys = require("data.keys").gx, init = function() vim.g.netrw_nogx = 1 end, @@ -33,7 +26,7 @@ return { }, { -- Auto-save "okuuva/auto-save.nvim", - cmd = "ASToggle", + cmd = require("data.cmd").autosave, event = { "InsertLeave", "TextChanged" }, opts = { execution_message = { @@ -44,17 +37,8 @@ return { { -- Ripgrep substitute "chrisgrieser/nvim-rip-substitute", event = "InsertEnter", - cmd = "RipSubstitute", - keys = { - { -- Rip Substitute - "fs", - function() - require("rip-substitute").sub() - end, - mode = { "n", "x" }, - desc = "Rip Substitute", - }, - }, + cmd = require("data.cmd").ripsub, + keys = require("data.keys").ripsub, }, { -- Unception "samjwill/nvim-unception", @@ -68,24 +52,7 @@ return { config = function() require("icon-picker").setup({ disable_legacy_commands = true }) end, - keys = { - { -- Pick Icon - "Ii", - "IconPickerNormal", - desc = "Pick Icon", - }, - { -- Yank Icon - "Iy", - "IconPickerYank", - desc = "Yank Icon", - }, - { -- Insert Icon in insert mode - "", - "IconPickerInsert", - desc = "Insert Icon", - mode = "i", - }, - }, + keys = require("data.keys").iconpicker, }, { -- Codesnap "mistricky/codesnap.nvim", @@ -100,38 +67,8 @@ return { code_font_family = "Iosevka NF", code_font_size = 12, }, - cmd = { - "CodeSnap", - "CodeSnapSave", - "CodeSnapHighlight", - "CodeSnapASCII", - }, - keys = { - { -- Save selected code snapshot into clipboard - "cy", - "CodeSnap", - desc = "Save selected code snapshot into clipboard", - mode = "x", - }, - { -- Save selected code snapshot in ~/Pictures - "cs", - "CodeSnapSave", - desc = "Save selected code snapshot in ~/Pictures", - mode = "x", - }, - { -- Highlight and snapshot selected code into clipboard - "ch", - "CodeSnapHighlight", - desc = "Highlight and snapshot selected code into clipboard", - mode = "x", - }, - { -- Save ASCII code snapshot into clipboard - "ci", - "CodeSnapASCII", - desc = "Save ASCII code snapshot into clipboard", - mode = "x", - }, - }, + cmd = require("data.cmd").codesnap, + keys = require("data.keys").codesnap, }, { -- Kulala "mistweaverco/kulala.nvim", @@ -151,16 +88,7 @@ return { "dmtrKovalenko/caps-word.nvim", lazy = true, opts = {}, - keys = { - { - "", - function() - require("caps-word").toggle() - end, - desc = "Toggle CapsWord", - mode = { "i", "n" }, - }, - }, + keys = require("data.keys").capsword, }, { -- Music Controls "AntonVanAssche/music-controls.nvim", @@ -171,14 +99,8 @@ return { }, { -- Qalc "Apeiros-46B/qalc.nvim", - cmd = { - "Qalc", - "QalcAttach", - "QalcYank", - }, - keys = { - { "qc", "Qalc", desc = "Qalc" }, - }, + cmd = require("data.cmd").qalc, + keys = require("data.keys").qalc, opts = { set_ft = "qalc", },