diff --git a/nvim/lua/olinpin/plugins/comment.lua b/nvim/lua/olinpin/plugins/comment.lua index efa47bc..32fc014 100644 --- a/nvim/lua/olinpin/plugins/comment.lua +++ b/nvim/lua/olinpin/plugins/comment.lua @@ -1,8 +1,8 @@ return { "numToStr/Comment.nvim", - event = "VeryLazy", - lazy = false, - + keys = { + { "/", desc = "Toggle comment" }, + }, config = function () require('Comment').setup({ opleader = { diff --git a/nvim/lua/olinpin/plugins/duck.lua b/nvim/lua/olinpin/plugins/duck.lua index 4435ec3..6e7a883 100644 --- a/nvim/lua/olinpin/plugins/duck.lua +++ b/nvim/lua/olinpin/plugins/duck.lua @@ -1,11 +1,8 @@ return { - 'tamton-aquib/duck.nvim', - config = function() - local duck = require("duck") - vim.keymap.set('n', 'dd', function() duck.hatch() end, {}) - vim.keymap.set('n', 'dc', function() duck.hatch("🐿️", 20) end, {}) - vim.keymap.set('n', 'dk', function() duck.cook() end, {}) - vim.keymap.set('n', 'dk', function() duck.cook("🐿️") end, {}) - -- duck.hatch("🐿️", 20) - end + "tamton-aquib/duck.nvim", + keys = { + { "dd", function() require("duck").hatch() end, desc = "Duck hatch" }, + { "dc", function() require("duck").hatch("🐿️", 20) end, desc = "Duck squirrel" }, + { "dk", function() require("duck").cook() end, desc = "Duck cook" }, + }, } diff --git a/nvim/lua/olinpin/plugins/gitsigns.lua b/nvim/lua/olinpin/plugins/gitsigns.lua index 5f9a6ea..e15f2a2 100644 --- a/nvim/lua/olinpin/plugins/gitsigns.lua +++ b/nvim/lua/olinpin/plugins/gitsigns.lua @@ -1,19 +1,17 @@ return { - "lewis6991/gitsigns.nvim", - event = "VeryLazy", - opts = function() - return { - signs = { - add = { text = "│" }, - change = { text = "│" }, - delete = { text = "󰍵" }, - topdelete = { text = "‾" }, - changedelete = { text = "~" }, - untracked = { text = "│" }, - } - } - end, - config = function() - require("gitsigns").setup() - end + "lewis6991/gitsigns.nvim", + event = "VeryLazy", + opts = { + signs = { + add = { text = "|" }, + change = { text = "|" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "~" }, + untracked = { text = "|" }, + }, + }, + config = function(_, opts) + require("gitsigns").setup(opts) + end, } diff --git a/nvim/lua/olinpin/plugins/go-ide.lua b/nvim/lua/olinpin/plugins/go-ide.lua index 9551809..14ab379 100644 --- a/nvim/lua/olinpin/plugins/go-ide.lua +++ b/nvim/lua/olinpin/plugins/go-ide.lua @@ -1,3 +1,4 @@ return { - "https://github.com/plentiform/go-ide", + "https://github.com/plentiform/go-ide", + ft = "go", } diff --git a/nvim/lua/olinpin/plugins/lualine.lua b/nvim/lua/olinpin/plugins/lualine.lua index b9d3648..1460056 100644 --- a/nvim/lua/olinpin/plugins/lualine.lua +++ b/nvim/lua/olinpin/plugins/lualine.lua @@ -1,14 +1,14 @@ return { "nvim-lualine/lualine.nvim", event = "VeryLazy", - requires = { "nvim-tree/nvim-web-devicons", opt = true }, - init = function() + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() local lualine = require("lualine") local custom_ayu_mirage = require("lualine.themes.ayu_mirage") custom_ayu_mirage.normal.c.bg = "#172c35" lualine.setup({ - section_separators = { left = "", right = "" }, - component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + component_separators = { left = "", right = "" }, sections = { lualine_a = { "mode" }, lualine_b = { "branch", "diff", "diagnostics" }, diff --git a/nvim/lua/olinpin/plugins/mcphub.lua b/nvim/lua/olinpin/plugins/mcphub.lua index 966d5b8..ebca30f 100644 --- a/nvim/lua/olinpin/plugins/mcphub.lua +++ b/nvim/lua/olinpin/plugins/mcphub.lua @@ -1,5 +1,6 @@ return { "ravitemer/mcphub.nvim", + event = "VeryLazy", dependencies = { "nvim-lua/plenary.nvim", }, diff --git a/nvim/lua/olinpin/plugins/profile.lua b/nvim/lua/olinpin/plugins/profile.lua index 02cdf27..55d3590 100644 --- a/nvim/lua/olinpin/plugins/profile.lua +++ b/nvim/lua/olinpin/plugins/profile.lua @@ -3,6 +3,7 @@ return { "Kurama622/profile.nvim", config = function() local comp = require("profile.components") + require("profile").setup({ avatar_opts = { force_blank = false, @@ -48,15 +49,44 @@ return { end comp:separator_render() - handle = io.popen("curl -s -m 3 https://vtip.43z.one") - result = handle:read("*a") - handle:close() - comp:text_component_render({ - comp:text_component("Neovim Tip of the Day:", "center", "ProfileGreen"), - comp:text_component(result or "Could not fetch tip.", "center", "ProfileGreen"), - }) + comp:text_component_render({ + comp:text_component("Neovim Tip of the Day:", "center", "ProfileGreen"), + comp:text_component("Loading...", "center", "ProfileGreen"), + }) end, }) + + -- Fetch tip asynchronously and update the buffer + vim.fn.jobstart({ "curl", "-s", "-m", "3", "https://vtip.43z.one" }, { + stdout_buffered = true, + on_stdout = function(_, data) + if data and data[1] and data[1] ~= "" then + local tip = table.concat(data, "") + vim.schedule(function() + -- Find the profile buffer + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_is_loaded(buf) then + local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) + for i, line in ipairs(lines) do + if line:match("Loading%.%.%.") then + -- Replace "Loading..." with the actual tip + local width = vim.api.nvim_win_get_width(0) + local padding = math.floor((width - #tip) / 2) + local centered_tip = string.rep(" ", math.max(0, padding)) .. tip + vim.api.nvim_buf_set_option(buf, "modifiable", true) + vim.api.nvim_buf_set_lines(buf, i - 1, i, false, { centered_tip }) + vim.api.nvim_buf_set_option(buf, "modifiable", false) + vim.api.nvim_buf_set_option(buf, "modified", false) + return + end + end + end + end + end) + end + end, + }) + vim.api.nvim_set_keymap("n", "p", "Profile", { silent = true }) end, }, diff --git a/nvim/lua/olinpin/plugins/smart-open.lua b/nvim/lua/olinpin/plugins/smart-open.lua index 9b9f57d..76217c7 100644 --- a/nvim/lua/olinpin/plugins/smart-open.lua +++ b/nvim/lua/olinpin/plugins/smart-open.lua @@ -1,10 +1,19 @@ return { "danielfalk/smart-open.nvim", branch = "0.2.x", - config = function() - require("telescope").load_extension("smart_open") - end, + lazy = true, + keys = { + { + "ff", + function() + require("telescope").load_extension("smart_open") + require("telescope").extensions.smart_open.smart_open() + end, + desc = "Smart Open", + }, + }, dependencies = { "kkharji/sqlite.lua", + "nvim-telescope/telescope.nvim", }, } diff --git a/nvim/lua/olinpin/plugins/telescope.lua b/nvim/lua/olinpin/plugins/telescope.lua index 222f408..99f0dc3 100644 --- a/nvim/lua/olinpin/plugins/telescope.lua +++ b/nvim/lua/olinpin/plugins/telescope.lua @@ -19,13 +19,42 @@ local new_maker = function(filepath, bufnr, opts) previewers.buffer_previewer_maker(filepath, bufnr, opts) end +local function grepInFiles() + local builtin = require("telescope.builtin") + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + builtin.filetypes({ + attach_mappings = function(prompt_bufnr, _) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + local filetype = selection.value + + builtin.live_grep({ + additional_args = function() + return { "--glob", "*." .. filetype } + end, + }) + end) + return true + end, + }) +end + return { "nvim-telescope/telescope.nvim", - event = "VeryLazy", + cmd = "Telescope", tag = "0.1.8", dependencies = { "nvim-lua/plenary.nvim" }, - init = function() - local builtin = require("telescope.builtin") + keys = { + { "ft", grepInFiles, desc = "Live grep by filetype" }, + { "*", function() require("telescope.builtin").grep_string() end, desc = "Grep current string" }, + { "fs", function() require("telescope.builtin").find_files() end, desc = "Find files" }, + { "fg", function() require("telescope.builtin").git_branches() end, desc = "Find Git branches" }, + { "fc", function() require("telescope.builtin").git_commits() end, desc = "Find Commits" }, + { "fw", function() require("telescope.builtin").live_grep() end, desc = "Find Words" }, + }, + config = function() local telescope = require("telescope") telescope.setup({ @@ -82,38 +111,5 @@ return { filesize_limit = 0.5, -- MB }, }) - - local function grepInFiles() - local actions = require("telescope.actions") - local action_state = require("telescope.actions.state") - builtin.filetypes({ - attach_mappings = function(prompt_bufnr, _) - actions.select_default:replace(function() - actions.close(prompt_bufnr) - local selection = action_state.get_selected_entry() - local filetype = selection.value - - builtin.live_grep({ - additional_args = function() - return { "--glob", "*." .. filetype } - end, - }) - end) - return true - end, - }) - end - - local function smart_open() - require("telescope").extensions.smart_open.smart_open() - end - - vim.keymap.set("n", "ft", grepInFiles, { desc = "Live grep by filetype" }) - vim.keymap.set("n", "*", builtin.grep_string, { desc = "Grep current string" }) - vim.keymap.set("n", "fs", builtin.find_files, { desc = "Find files" }) - vim.keymap.set("n", "fg", builtin.git_branches, { desc = "Find Git branches" }) - vim.keymap.set("n", "fc", builtin.git_commits, { desc = "Find Commits" }) - vim.keymap.set("n", "fw", builtin.live_grep, { desc = "Find Words" }) - vim.keymap.set("n", "ff", smart_open, { desc = "Smart Open" }) end, }