fix(nvim): improve startup time
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
return {
|
return {
|
||||||
"numToStr/Comment.nvim",
|
"numToStr/Comment.nvim",
|
||||||
event = "VeryLazy",
|
keys = {
|
||||||
lazy = false,
|
{ "<leader>/", desc = "Toggle comment" },
|
||||||
|
},
|
||||||
config = function ()
|
config = function ()
|
||||||
require('Comment').setup({
|
require('Comment').setup({
|
||||||
opleader = {
|
opleader = {
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
return {
|
return {
|
||||||
'tamton-aquib/duck.nvim',
|
"tamton-aquib/duck.nvim",
|
||||||
config = function()
|
keys = {
|
||||||
local duck = require("duck")
|
{ "<leader>dd", function() require("duck").hatch() end, desc = "Duck hatch" },
|
||||||
vim.keymap.set('n', '<leader>dd', function() duck.hatch() end, {})
|
{ "<leader>dc", function() require("duck").hatch("🐿️", 20) end, desc = "Duck squirrel" },
|
||||||
vim.keymap.set('n', '<leader>dc', function() duck.hatch("🐿️", 20) end, {})
|
{ "<leader>dk", function() require("duck").cook() end, desc = "Duck cook" },
|
||||||
vim.keymap.set('n', '<leader>dk', function() duck.cook() end, {})
|
},
|
||||||
vim.keymap.set('n', '<leader>dk', function() duck.cook("🐿️") end, {})
|
|
||||||
-- duck.hatch("🐿️", 20)
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
return {
|
return {
|
||||||
"lewis6991/gitsigns.nvim",
|
"lewis6991/gitsigns.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = function()
|
opts = {
|
||||||
return {
|
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = "│" },
|
add = { text = "|" },
|
||||||
change = { text = "│" },
|
change = { text = "|" },
|
||||||
delete = { text = "" },
|
delete = { text = "" },
|
||||||
topdelete = { text = "‾" },
|
topdelete = { text = "" },
|
||||||
changedelete = { text = "~" },
|
changedelete = { text = "~" },
|
||||||
untracked = { text = "│" },
|
untracked = { text = "|" },
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
|
config = function(_, opts)
|
||||||
|
require("gitsigns").setup(opts)
|
||||||
end,
|
end,
|
||||||
config = function()
|
|
||||||
require("gitsigns").setup()
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
return {
|
return {
|
||||||
"https://github.com/plentiform/go-ide",
|
"https://github.com/plentiform/go-ide",
|
||||||
|
ft = "go",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
return {
|
return {
|
||||||
"nvim-lualine/lualine.nvim",
|
"nvim-lualine/lualine.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
requires = { "nvim-tree/nvim-web-devicons", opt = true },
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
init = function()
|
config = function()
|
||||||
local lualine = require("lualine")
|
local lualine = require("lualine")
|
||||||
local custom_ayu_mirage = require("lualine.themes.ayu_mirage")
|
local custom_ayu_mirage = require("lualine.themes.ayu_mirage")
|
||||||
custom_ayu_mirage.normal.c.bg = "#172c35"
|
custom_ayu_mirage.normal.c.bg = "#172c35"
|
||||||
lualine.setup({
|
lualine.setup({
|
||||||
section_separators = { left = "", right = "" },
|
section_separators = { left = "", right = "" },
|
||||||
component_separators = { left = "", right = "" },
|
component_separators = { left = "", right = "" },
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { "mode" },
|
lualine_a = { "mode" },
|
||||||
lualine_b = { "branch", "diff", "diagnostics" },
|
lualine_b = { "branch", "diff", "diagnostics" },
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
"ravitemer/mcphub.nvim",
|
"ravitemer/mcphub.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ return {
|
|||||||
"Kurama622/profile.nvim",
|
"Kurama622/profile.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
local comp = require("profile.components")
|
local comp = require("profile.components")
|
||||||
|
|
||||||
require("profile").setup({
|
require("profile").setup({
|
||||||
avatar_opts = {
|
avatar_opts = {
|
||||||
force_blank = false,
|
force_blank = false,
|
||||||
@@ -48,15 +49,44 @@ return {
|
|||||||
end
|
end
|
||||||
|
|
||||||
comp:separator_render()
|
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_render({
|
||||||
comp:text_component("Neovim Tip of the Day:", "center", "ProfileGreen"),
|
comp:text_component("Neovim Tip of the Day:", "center", "ProfileGreen"),
|
||||||
comp:text_component(result or "Could not fetch tip.", "center", "ProfileGreen"),
|
comp:text_component("Loading...", "center", "ProfileGreen"),
|
||||||
})
|
})
|
||||||
end,
|
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", "<leader>p", "<cmd>Profile<cr>", { silent = true })
|
vim.api.nvim_set_keymap("n", "<leader>p", "<cmd>Profile<cr>", { silent = true })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
return {
|
return {
|
||||||
"danielfalk/smart-open.nvim",
|
"danielfalk/smart-open.nvim",
|
||||||
branch = "0.2.x",
|
branch = "0.2.x",
|
||||||
config = function()
|
lazy = true,
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>ff",
|
||||||
|
function()
|
||||||
require("telescope").load_extension("smart_open")
|
require("telescope").load_extension("smart_open")
|
||||||
|
require("telescope").extensions.smart_open.smart_open()
|
||||||
end,
|
end,
|
||||||
|
desc = "Smart Open",
|
||||||
|
},
|
||||||
|
},
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"kkharji/sqlite.lua",
|
"kkharji/sqlite.lua",
|
||||||
|
"nvim-telescope/telescope.nvim",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,42 @@ local new_maker = function(filepath, bufnr, opts)
|
|||||||
previewers.buffer_previewer_maker(filepath, bufnr, opts)
|
previewers.buffer_previewer_maker(filepath, bufnr, opts)
|
||||||
end
|
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 {
|
return {
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
event = "VeryLazy",
|
cmd = "Telescope",
|
||||||
tag = "0.1.8",
|
tag = "0.1.8",
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
init = function()
|
keys = {
|
||||||
local builtin = require("telescope.builtin")
|
{ "<leader>ft", grepInFiles, desc = "Live grep by filetype" },
|
||||||
|
{ "<leader>*", function() require("telescope.builtin").grep_string() end, desc = "Grep current string" },
|
||||||
|
{ "<leader>fs", function() require("telescope.builtin").find_files() end, desc = "Find files" },
|
||||||
|
{ "<leader>fg", function() require("telescope.builtin").git_branches() end, desc = "Find Git branches" },
|
||||||
|
{ "<leader>fc", function() require("telescope.builtin").git_commits() end, desc = "Find Commits" },
|
||||||
|
{ "<leader>fw", function() require("telescope.builtin").live_grep() end, desc = "Find Words" },
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
local telescope = require("telescope")
|
local telescope = require("telescope")
|
||||||
|
|
||||||
telescope.setup({
|
telescope.setup({
|
||||||
@@ -82,38 +111,5 @@ return {
|
|||||||
filesize_limit = 0.5, -- MB
|
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", "<leader>ft", grepInFiles, { desc = "Live grep by filetype" })
|
|
||||||
vim.keymap.set("n", "<leader>*", builtin.grep_string, { desc = "Grep current string" })
|
|
||||||
vim.keymap.set("n", "<leader>fs", builtin.find_files, { desc = "Find files" })
|
|
||||||
vim.keymap.set("n", "<leader>fg", builtin.git_branches, { desc = "Find Git branches" })
|
|
||||||
vim.keymap.set("n", "<leader>fc", builtin.git_commits, { desc = "Find Commits" })
|
|
||||||
vim.keymap.set("n", "<leader>fw", builtin.live_grep, { desc = "Find Words" })
|
|
||||||
vim.keymap.set("n", "<leader>ff", smart_open, { desc = "Smart Open" })
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user