From 22b81afe5f3267c74a3c1f147b58dc94ae80c08b Mon Sep 17 00:00:00 2001 From: "asep.komarudin" Date: Tue, 9 Apr 2024 05:51:53 +0700 Subject: [PATCH] add: update config (tuning speed) --- lazy-lock.json | 3 + lua/custom/plugins/bufferline.lua | 2 +- lua/custom/plugins/lualine.lua | 4 +- lua/custom/plugins/nvimufo.lua | 206 +++++++++++++++--------------- lua/plugins/init.lua | 16 ++- lua/plugins/ui.lua | 6 +- lua/user/keymaps.lua | 8 +- lua/user/smartspit.lua | 8 +- 8 files changed, 131 insertions(+), 122 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index ccd82d3..b07272a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -38,10 +38,13 @@ "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "734ebad31c81c6198dfe102aa23280937c937c42" }, "nvim-ts-rainbow2": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" }, + "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, "nvim-web-devicons": { "branch": "master", "commit": "a55b801b7ef5719ca25692c3a0a5447fdfb692ed" }, "onedark.nvim": { "branch": "master", "commit": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, "smart-splits.nvim": { "branch": "master", "commit": "f6fcb79527872e9330c554915af2ca511c388390" }, + "statuscol.nvim": { "branch": "main", "commit": "d954893262a57a92e46edd87de67e2b3fe72305e" }, "telescope.nvim": { "branch": "master", "commit": "d26b666b45e5dde23332e4bde1227677f2d92e31" }, "toggleterm.nvim": { "branch": "main", "commit": "193786e0371e3286d3bc9aa0079da1cd41beaa62" }, "vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" }, diff --git a/lua/custom/plugins/bufferline.lua b/lua/custom/plugins/bufferline.lua index 1afe7dc..c422785 100644 --- a/lua/custom/plugins/bufferline.lua +++ b/lua/custom/plugins/bufferline.lua @@ -1,6 +1,6 @@ return { "akinsho/bufferline.nvim", - event = "VeryLazy", + event = { "BufRead", "InsertEnter", "BufNewFile" }, config = function() local status_ok, bufferline = pcall(require, "bufferline") if not status_ok then diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua index 256c281..33c1523 100644 --- a/lua/custom/plugins/lualine.lua +++ b/lua/custom/plugins/lualine.lua @@ -1,7 +1,7 @@ return { { "nvim-lualine/lualine.nvim", - event = "BufWinEnter", + event = "insertEnter", config = function() local hide_in_width = function() return vim.fn.winwidth(0) > 80 @@ -198,7 +198,7 @@ return { normal = { a = { fg = colors.black, bg = colors.skyblue_1 }, b = { fg = colors.white, bg = colors.grey }, - c = { fg = colors.white, bg = "#393f4a" }, + c = { fg = colors.white, bg = "none" }, }, insert = { diff --git a/lua/custom/plugins/nvimufo.lua b/lua/custom/plugins/nvimufo.lua index cea902a..f376fb9 100644 --- a/lua/custom/plugins/nvimufo.lua +++ b/lua/custom/plugins/nvimufo.lua @@ -1,105 +1,105 @@ return { - -- "kevinhwang91/nvim-ufo", - -- dependencies = { - -- "kevinhwang91/promise-async", - -- { - -- "luukvbaal/statuscol.nvim", - -- config = function() - -- local builtin = require("statuscol.builtin") - -- require("statuscol").setup({ - -- -- relculright = true, - -- -- segments = { - -- -- { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, - -- -- { text = { "%s" }, click = "v:lua.ScSa" }, - -- -- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, - -- -- }, - -- setopt = true, - -- relculright = true, - -- segments = { - -- { text = { "%s" }, click = "v:lua.ScSa" }, - -- { - -- text = { builtin.foldfunc }, - -- condition = { builtin.not_empty, true, builtin.not_empty }, - -- click = "v:lua.ScFa", - -- }, - -- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, - -- }, - -- }) - -- end, - -- }, - -- }, - -- lazy = true, - -- -- event = "BufReadPost", - -- event = "BufWinEnter", - -- config = function() - -- vim.o.foldcolumn = "1" -- '0' is not bad - -- vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value - -- vim.o.foldlevelstart = 99 - -- vim.o.foldenable = true - -- -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] - -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] - -- - -- -- these are "extra", change them as you like - -- vim.keymap.set("n", "zR", require("ufo").openAllFolds) - -- vim.keymap.set("n", "zM", require("ufo").closeAllFolds) - -- vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("Comment")), "fg")) - -- -- Option 3: treesitter as a main provider instead - -- -- Only depend on `nvim-treesitter/queries/filetype/folds.scm`, - -- -- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` - -- require("ufo").setup({ - -- -- provider_selector = function(bufnr, filetype, buftype) - -- -- return { "treesitter", "indent" } - -- -- end, - -- open_fold_hl_timeout = 150, - -- - -- preview = { - -- win_config = { - -- border = { "", "─", "", "", "", "─", "", "" }, - -- -- winhighlight = 'Normal:Normal', - -- -- winhighlight = 'IncSearch:Folded', - -- winhighlight = "Normal:UfoPreviewNormal,FloatBorder:UfoPreviewBorder,CursorLine:UfoPreviewCursorLine", - -- winblend = 0, - -- }, - -- mappings = { - -- scrollU = "", - -- scrollD = "", - -- jumpTop = "[", - -- jumpBot = "]", - -- }, - -- }, - -- provider_selector = function(_, filetype) - -- return { "treesitter", "indent" } - -- end, - -- fold_virt_text_handler = function(virt_text, lnum, end_lnum, width, truncate) - -- local result = {} - -- local _end = end_lnum - 1 - -- local final_text = vim.trim(vim.api.nvim_buf_get_text(0, _end, 0, _end, -1, {})[1]) - -- local suffix = final_text:format(end_lnum - lnum) - -- local suffix_width = vim.fn.strdisplaywidth(suffix) - -- local target_width = width - suffix_width - -- local cur_width = 0 - -- for _, chunk in ipairs(virt_text) do - -- local chunk_text = chunk[1] - -- local chunk_width = vim.fn.strdisplaywidth(chunk_text) - -- if target_width > cur_width + chunk_width then - -- table.insert(result, chunk) - -- else - -- chunk_text = truncate(chunk_text, target_width - cur_width) - -- local hl_group = chunk[2] - -- table.insert(result, { chunk_text, hl_group }) - -- chunk_width = vim.fn.strdisplaywidth(chunk_text) - -- -- str width returned from truncate() may less than 2nd argument, need padding - -- if cur_width + chunk_width < target_width then - -- suffix = suffix .. (" "):rep(target_width - cur_width - chunk_width) - -- end - -- break - -- end - -- cur_width = cur_width + chunk_width - -- end - -- table.insert(result, { " ⋯ ", "NonText" }) - -- table.insert(result, { suffix, "TSPunctBracket" }) - -- return result - -- end, - -- }) - -- end, + "kevinhwang91/nvim-ufo", + dependencies = { + "kevinhwang91/promise-async", + { + "luukvbaal/statuscol.nvim", + config = function() + local builtin = require("statuscol.builtin") + require("statuscol").setup({ + -- relculright = true, + -- segments = { + -- { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + -- { text = { "%s" }, click = "v:lua.ScSa" }, + -- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + -- }, + setopt = true, + relculright = true, + segments = { + { text = { "%s" }, click = "v:lua.ScSa" }, + { + text = { builtin.foldfunc }, + condition = { builtin.not_empty, true, builtin.not_empty }, + click = "v:lua.ScFa", + }, + { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + }, + }) + end, + }, + }, + lazy = true, + -- event = "BufReadPost", + event = { "BufReadPost", "BufRead", "InsertEnter", "BufNewFile" }, + config = function() + vim.o.foldcolumn = "1" -- '0' is not bad + vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] + + -- these are "extra", change them as you like + vim.keymap.set("n", "zR", require("ufo").openAllFolds) + vim.keymap.set("n", "zM", require("ufo").closeAllFolds) + vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("Comment")), "fg")) + -- Option 3: treesitter as a main provider instead + -- Only depend on `nvim-treesitter/queries/filetype/folds.scm`, + -- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` + require("ufo").setup({ + -- provider_selector = function(bufnr, filetype, buftype) + -- return { "treesitter", "indent" } + -- end, + open_fold_hl_timeout = 150, + + preview = { + win_config = { + border = { "", "─", "", "", "", "─", "", "" }, + -- winhighlight = 'Normal:Normal', + -- winhighlight = 'IncSearch:Folded', + winhighlight = "Normal:UfoPreviewNormal,FloatBorder:UfoPreviewBorder,CursorLine:UfoPreviewCursorLine", + winblend = 0, + }, + mappings = { + scrollU = "", + scrollD = "", + jumpTop = "[", + jumpBot = "]", + }, + }, + provider_selector = function(_, filetype) + return { "treesitter", "indent" } + end, + fold_virt_text_handler = function(virt_text, lnum, end_lnum, width, truncate) + local result = {} + local _end = end_lnum - 1 + local final_text = vim.trim(vim.api.nvim_buf_get_text(0, _end, 0, _end, -1, {})[1]) + local suffix = final_text:format(end_lnum - lnum) + local suffix_width = vim.fn.strdisplaywidth(suffix) + local target_width = width - suffix_width + local cur_width = 0 + for _, chunk in ipairs(virt_text) do + local chunk_text = chunk[1] + local chunk_width = vim.fn.strdisplaywidth(chunk_text) + if target_width > cur_width + chunk_width then + table.insert(result, chunk) + else + chunk_text = truncate(chunk_text, target_width - cur_width) + local hl_group = chunk[2] + table.insert(result, { chunk_text, hl_group }) + chunk_width = vim.fn.strdisplaywidth(chunk_text) + -- str width returned from truncate() may less than 2nd argument, need padding + if cur_width + chunk_width < target_width then + suffix = suffix .. (" "):rep(target_width - cur_width - chunk_width) + end + break + end + cur_width = cur_width + chunk_width + end + table.insert(result, { " ⋯ ", "NonText" }) + table.insert(result, { suffix, "TSPunctBracket" }) + return result + end, + }) + end, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 50dc804..ef18fc0 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -260,7 +260,8 @@ return { }, { "lukas-reineke/indent-blankline.nvim", - event = "BufWinEnter", + -- event = "BufWinEnter", + event = { "BufRead", "InsertEnter", "BufNewFile" }, lazy = true, opts = { indent = { @@ -321,7 +322,7 @@ return { -- build = "npm install -g live-server", -- }, -- for multi cursor select - { "mg979/vim-visual-multi", event = "BufWinEnter", lazy = true }, + { "mg979/vim-visual-multi", event = { "BufRead", "InsertEnter", "BufNewFile" }, lazy = true }, -- for auto close tag { "windwp/nvim-ts-autotag", @@ -348,7 +349,8 @@ return { { "NvChad/nvim-colorizer.lua", lazy = true, - event = "BufWinEnter", + -- event = "BufWinEnter", + event = { "BufRead", "InsertEnter", "BufNewFile" }, opts = function() require("user.colorizer") end, @@ -400,7 +402,7 @@ return { { "mrjones2014/smart-splits.nvim", lazy = true, - -- event = "BufRead", + event = { "BufRead", "InsertEnter", "BufNewFile" }, config = function() require("user.smartspit") end, @@ -428,7 +430,8 @@ return { { "dstein64/nvim-scrollview", lazy = true, - event = "BufWinEnter", + -- event = "BufWinEnter", + event = { "BufRead", "InsertEnter", "BufNewFile" }, config = function() require("user.nvimscroll") end, @@ -454,7 +457,8 @@ return { lazy = true, enabled = vim.fn.executable("git") == 1, ft = "gitcommit", - event = "BufWinEnter", + -- event = "BufWinEnter", + event = "BufRead", config = function() require("user.gitsigns") end, diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 2fe06df..0b2d948 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -14,7 +14,8 @@ return { "nvim-lualine/lualine.nvim", lazy = true, -- dependencies = { "kyazdani42/nvim-web-devicons", opt = true }, - event = "BufWinEnter", + -- event = "BufWinEnter", + event = { "BufRead", "BufNewFile" }, config = function() require("user.lualine") end, @@ -54,7 +55,8 @@ return { { "akinsho/bufferline.nvim", lazy = true, - event = "BufWinEnter", + -- event = "BufWinEnter", + event = { "BufRead", "InsertEnter", "BufNewFile" }, config = function() require("user.bufferline") end, diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index 768e5fd..84331fa 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -193,7 +193,7 @@ end -- keymap("t", "", "k", term_opts) -- keymap("t", "", "l", term_opts) -vim.keymap.set("n", "", require("smart-splits").resize_left) -vim.keymap.set("n", "", require("smart-splits").resize_down) -vim.keymap.set("n", "", require("smart-splits").resize_right) +-- vim.keymap.set("n", "", require("smart-splits").resize_left) +-- vim.keymap.set("n", "", require("smart-splits").resize_down) +-- vim.keymap.set("n", "", require("smart-splits").resize_right) diff --git a/lua/user/smartspit.lua b/lua/user/smartspit.lua index 264f2fe..94242c9 100644 --- a/lua/user/smartspit.lua +++ b/lua/user/smartspit.lua @@ -12,7 +12,7 @@ smart_splits.setup({ ignored_buftypes = { "nofile" }, }) --- vim.keymap.set("n", "", require("smart-splits").resize_left) --- vim.keymap.set("n", "", require("smart-splits").resize_down) --- vim.keymap.set("n", "", require("smart-splits").resize_right) +vim.keymap.set("n", "", require("smart-splits").resize_left) +vim.keymap.set("n", "", require("smart-splits").resize_down) +vim.keymap.set("n", "", require("smart-splits").resize_right)