fix(nvim): improve startup time
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
event = "VeryLazy",
|
||||
lazy = false,
|
||||
|
||||
keys = {
|
||||
{ "<leader>/", desc = "Toggle comment" },
|
||||
},
|
||||
config = function ()
|
||||
require('Comment').setup({
|
||||
opleader = {
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
return {
|
||||
'tamton-aquib/duck.nvim',
|
||||
config = function()
|
||||
local duck = require("duck")
|
||||
vim.keymap.set('n', '<leader>dd', function() duck.hatch() end, {})
|
||||
vim.keymap.set('n', '<leader>dc', function() duck.hatch("🐿️", 20) end, {})
|
||||
vim.keymap.set('n', '<leader>dk', function() duck.cook() end, {})
|
||||
vim.keymap.set('n', '<leader>dk', function() duck.cook("🐿️") end, {})
|
||||
-- duck.hatch("🐿️", 20)
|
||||
end
|
||||
"tamton-aquib/duck.nvim",
|
||||
keys = {
|
||||
{ "<leader>dd", function() require("duck").hatch() end, desc = "Duck hatch" },
|
||||
{ "<leader>dc", function() require("duck").hatch("🐿️", 20) end, desc = "Duck squirrel" },
|
||||
{ "<leader>dk", function() require("duck").cook() end, desc = "Duck cook" },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
return {
|
||||
"https://github.com/plentiform/go-ide",
|
||||
"https://github.com/plentiform/go-ide",
|
||||
ft = "go",
|
||||
}
|
||||
|
||||
@@ -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" },
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
return {
|
||||
"ravitemer/mcphub.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
},
|
||||
|
||||
@@ -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", "<leader>p", "<cmd>Profile<cr>", { silent = true })
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -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 = {
|
||||
{
|
||||
"<leader>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",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
{ "<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")
|
||||
|
||||
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", "<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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user