From 368cce2a274a154601e032e20bfce0c73016521b Mon Sep 17 00:00:00 2001 From: asep komarudin Date: Thu, 9 Feb 2023 13:22:54 +0700 Subject: [PATCH] tuning startup time --- lazy-lock.json | 4 +-- lua/plugins/init.lua | 79 ++++++++++++++++++++++++++++---------------- lua/user/cmdline.lua | 8 +++-- lua/user/cmp.lua | 23 +++++++++++++ 4 files changed, 82 insertions(+), 32 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 1722a63..bbae3c4 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -24,7 +24,7 @@ "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "7a97a77eee486ae152d2c559a459eda7c8aa12aa" }, "mason-null-ls.nvim": { "branch": "main", "commit": "13c6ab4a4f810cbbb1799a9cf4d4a27fd862d885" }, - "mason.nvim": { "branch": "main", "commit": "6f8f1ab3f4c5193578797b0d89afa7c497398bb1" }, + "mason.nvim": { "branch": "main", "commit": "0efc7ceb29a933317e625544d3eb160e7c46dc81" }, "mini.indentscope": { "branch": "main", "commit": "cbabbf3be4a59c7f23725b74ed15e0fba951e328" }, "neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" }, "null-ls.nvim": { "branch": "main", "commit": "60b4a7167c79c7d04d1ff48b55f2235bf58158a7" }, @@ -48,7 +48,7 @@ "todo-comments.nvim": { "branch": "main", "commit": "077c59586d9d0726b0696dc5680eb863f4e04bc5" }, "toggleterm.nvim": { "branch": "main", "commit": "2a787c426ef00cb3488c11b14f5dcf892bbd0bda" }, "tokyonight.nvim": { "branch": "main", "commit": "e52c41314e83232840d6970e6b072f9fba242eb9" }, - "trouble.nvim": { "branch": "main", "commit": "83ec606e7065adf134d17f4af6bae510e3c491c1" }, + "trouble.nvim": { "branch": "main", "commit": "2fceec1ee299689f42483252ca50b5ba44a0ebdb" }, "vim-bbye": { "branch": "master", "commit": "903f5eb17f72ebf7b0b1524bbb792c0b36761af6" }, "vim-illuminate": { "branch": "master", "commit": "d6ca7f77eeaf61b3e6ce9f0e5a978d606df44298" }, "vim-startuptime": { "branch": "master", "commit": "5f52ed26e0296a3e1d1453935f417e5808eefab8" }, diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 4a988d7..7c79e97 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -6,7 +6,7 @@ return { -- plugin ini merupakan penyedia library neovim lua { "nvim-lua/plenary.nvim", - event = "VeryLazy", + event = "BufRead", }, -- color scheme { @@ -87,6 +87,7 @@ return { -- coloring code { "nvim-treesitter/nvim-treesitter", + event = "BufRead", cmd = { "TSBufDisable", "TSBufEnable", @@ -138,7 +139,7 @@ return { -- auto completion { "hrsh7th/nvim-cmp", - event = "InsertEnter", + event = "BufWinEnter", dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", @@ -148,15 +149,17 @@ return { { "tzachar/cmp-tabnine", build = build, + event = "BufWinEnter", config = function() require("user.tabnine") end, }, { "hrsh7th/cmp-cmdline", - init = function() - require("user.cmdline") - end, + event = "BufWinEnter", + -- config = function() + -- require("user.cmdline") + -- end, }, }, opts = function() @@ -188,7 +191,7 @@ return { end, }, -- for formater linter - { "RRethy/vim-illuminate", event = "VeryLazy" }, + { "RRethy/vim-illuminate", event = "BufRead" }, { "jayp0521/mason-null-ls.nvim", dependencies = "jose-elias-alvarez/null-ls.nvim", @@ -228,11 +231,11 @@ return { end, }, -- untuk comment - { "JoosepAlviste/nvim-ts-context-commentstring" }, + { "JoosepAlviste/nvim-ts-context-commentstring", event = "BufRead" }, { "numToStr/Comment.nvim", - event = "InsertEnter", - init = function() + event = "BufRead", + config = function() require("user.comment") end, }, @@ -248,7 +251,7 @@ return { { "lukas-reineke/indent-blankline.nvim", event = "BufRead", - init = function() + config = function() require("user.indentline") end, }, @@ -298,14 +301,17 @@ return { -- for file tab { "akinsho/bufferline.nvim", - dependencies = { "kyazdani42/nvim-web-devicons", "famiu/bufdelete.nvim" }, - event = "VeryLazy", + dependencies = { + "kyazdani42/nvim-web-devicons", + { "famiu/bufdelete.nvim", event = "BufRead" }, + }, + event = "BufRead", -- config = function() -- require("user.bufferline") -- end, }, -- for delete buffers (close files) without closing your windows or messing up your layout. - { "moll/vim-bbye", event = "VeryLazy" }, + { "moll/vim-bbye", event = "BufRead" }, -- for view terminal { "akinsho/toggleterm.nvim", @@ -319,8 +325,8 @@ return { -- for Speed up loading Lua modules in Neovim to improve startup time. { "lewis6991/impatient.nvim", - event = "VeryLazy", - init = function() + event = "BufRead", + config = function() require("user.impatient") end, }, @@ -343,22 +349,22 @@ return { end, }, -- for live server html,css,js - { "manzeloth/live-server", cmd = { "LiveServer" }, event = "VeryLazy" }, + { "manzeloth/live-server", cmd = { "LiveServer" }, event = "BufRead" }, -- for multi cursor select - { "mg979/vim-visual-multi", event = "BufWinEnter" }, + { "mg979/vim-visual-multi", event = "BufRead" }, -- for auto close tag { "windwp/nvim-ts-autotag", - event = "VeryLazy", + event = "BufRead", dependencies = "nvim-treesitter/nvim-treesitter", - init = function() + config = function() require("nvim-ts-autotag").setup() end, }, -- for auto detection file and run code { "CRAG666/code_runner.nvim", - event = "VeryLazy", + event = "BufRead", dependencies = "nvim-lua/plenary.nvim", cmd = { "RunCode", "RunFile", "RunProject", "RunClose" }, config = function() @@ -367,7 +373,7 @@ return { }, { "is0n/jaq-nvim", - event = "CursorHold", + event = "BufRead", config = function() require("user.jaq") end, @@ -375,7 +381,7 @@ return { -- for color view { "NvChad/nvim-colorizer.lua", - event = "VeryLazy", + event = "BufRead", opts = function() require("user.colorizer") end, @@ -421,7 +427,7 @@ return { -- mini scrollview { "karb94/neoscroll.nvim", - event = "WinScrolled", + event = "BufRead", config = function() require("user.neoscroll") end, @@ -442,15 +448,15 @@ return { end, }, -- for check startuptime - { "dstein64/vim-startuptime", cmd = "StartupTime", event = "VeryLazy" }, + { "dstein64/vim-startuptime", cmd = "StartupTime", event = "BufRead" }, -- for coloring pairs - { "p00f/nvim-ts-rainbow", event = "BufWinEnter", dependencies = "nvim-treesitter/nvim-treesitter" }, + { "p00f/nvim-ts-rainbow", event = "BufRead", dependencies = "nvim-treesitter/nvim-treesitter" }, -- for git { "lewis6991/gitsigns.nvim", enabled = vim.fn.executable("git") == 1, ft = "gitcommit", - event = "VeryLazy", + event = "BufRead", config = function() require("user.gitsigns") end, @@ -482,7 +488,7 @@ return { -- better diagnostics list and others { "folke/trouble.nvim", - event = "VeryLazy", + event = "BufRead", cmd = { "TroubleToggle", "Trouble" }, opts = { use_diagnostic_signs = true }, keys = { @@ -553,9 +559,26 @@ return { -- for loading info { "j-hui/fidget.nvim", - event = "VeryLazy", + event = "BufRead", config = function() require("fidget").setup() end, }, + -- for auto complate commond mode + -- { + -- "gelguy/wilder.nvim", + -- event = "BufWinEnter", + -- config = function() + -- local wilder = require("wilder") + -- wilder.setup({ modes = { ":", "/", "?" } }) + -- wilder.set_option( + -- "renderer", + -- wilder.popupmenu_renderer({ + -- highlighter = wilder.basic_highlighter(), + -- left = { " ", wilder.popupmenu_devicons() }, + -- right = { " ", wilder.popupmenu_scrollbar() }, + -- }) + -- ) + -- end, + -- }, } diff --git a/lua/user/cmdline.lua b/lua/user/cmdline.lua index fc39835..5dc91d8 100644 --- a/lua/user/cmdline.lua +++ b/lua/user/cmdline.lua @@ -1,4 +1,8 @@ -require("cmp").setup.cmdline({ "/", "?" }, { +local status_ok, ncmp = pcall(require, "cmp") +if not status_ok then + return +end +ncmp.setup.cmdline({ "/", "?" }, { mapping = require("cmp").mapping.preset.cmdline({ [""] = { c = function() @@ -15,7 +19,7 @@ require("cmp").setup.cmdline({ "/", "?" }, { sources = require("cmp").config.sources({ { name = "buffer", keyword_length = 1 } }), }) -require("cmp").setup.cmdline(":", { +ncmp.setup.cmdline(":", { mapping = require("cmp").mapping.preset.cmdline({ [""] = { c = function() diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua index 81c2734..ac39f40 100644 --- a/lua/user/cmp.lua +++ b/lua/user/cmp.lua @@ -139,3 +139,26 @@ cmp.setup({ native_menu = false, }, }) + +-- for cmd line +cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) + +-- `:` cmdline setup. +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { + name = "cmdline", + option = { + ignore_cmds = { "Man", "!" }, + }, + }, + }), +})