add: nvim fold config

This commit is contained in:
asep.komarudin 2024-03-29 16:33:42 +07:00
parent 5518885b31
commit e2ba1a6fb2
5 changed files with 160 additions and 102 deletions

View file

@ -15,7 +15,7 @@
"friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" },
"gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" },
"indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" },
"lazy.nvim": { "branch": "main", "commit": "65887ea871d44822bff47504202b3643f29d614e" },
"lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" },
"lsp-progress.nvim": { "branch": "main", "commit": "1c37b1cd0611563a767f0a340d61f265c4c54ecd" },
"lualine.nvim": { "branch": "master", "commit": "b5e8bb642138f787a2c1c5aedc2a78cb2cebbd67" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "2ba17cecfde8b8c7c7c287909a1e4de895223df6" },
@ -25,7 +25,7 @@
"mini.indentscope": { "branch": "main", "commit": "cf07f19e718ebb0bcc5b00999083ce11c37b8d40" },
"neoscroll.nvim": { "branch": "master", "commit": "21d52973bde32db998fc8b6590f87eb3c3c6d8e4" },
"noice.nvim": { "branch": "main", "commit": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12" },
"none-ls-extras.nvim": { "branch": "main", "commit": "4f6ba0c4a317a630157bc02fad110fcd826e9494" },
"none-ls-extras.nvim": { "branch": "main", "commit": "4d1b26b963edb82c45ed261d988f9e72253c3469" },
"none-ls.nvim": { "branch": "main", "commit": "18910d09d21d7df339805343bfe4a2b2e41c057b" },
"nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" },
"nvim-autopairs": { "branch": "master", "commit": "dbfc1c34bed415906395db8303c71039b3a3ffb4" },
@ -53,5 +53,6 @@
"vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" },
"vim-startuptime": { "branch": "master", "commit": "97a88e688482a09c3c4b777d07b509b328a5ec29" },
"vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" },
"which-key.nvim": { "branch": "main", "commit": "ce741eb559c924d72e3a67d2189ad3771a231414" }
"which-key.nvim": { "branch": "main", "commit": "ce741eb559c924d72e3a67d2189ad3771a231414" },
"yanky.nvim": { "branch": "main", "commit": "9268018e92d02650a94e39dd5f5903c542f7ea11" }
}

View file

@ -41,13 +41,13 @@ return {
"hrsh7th/cmp-nvim-lua",
enabled = false,
},
-- {
-- "gbprod/yanky.nvim",
-- event = "InsertEnter",
-- config = function()
-- require("user.yanky")
-- end,
-- },
{
"gbprod/yanky.nvim",
event = "BufReadPre",
config = function()
require("user.yanky")
end,
},
-- {
-- "is0n/jaq-nvim",
-- event = "BufRead",

View file

@ -7,10 +7,21 @@ return {
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 = { builtin.foldfunc }, click = "v:lua.ScFa" },
{ 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" },
},
})
@ -24,6 +35,7 @@ return {
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)
@ -33,9 +45,43 @@ return {
-- 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)
-- provider_selector = function(bufnr, filetype, buftype)
-- return { "treesitter", "indent" }
-- end,
open_fold_hl_timeout = 0,
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,
}

View file

@ -215,7 +215,17 @@ end
return {
-- color scheme
{ "luisiacc/gruvbox-baby", lazy = true, enabled = gruvbox },
{
"luisiacc/gruvbox-baby",
lazy = true,
enabled = gruvbox,
config = function()
local colors = require("gruvbox-baby.colors").config()
vim.g.gruvbox_baby_highlights = {
StatusLine = { fg = colors.fg, bg = "NONE" },
}
end,
},
{
"Mofiqul/dracula.nvim",
enabled = dracula,
@ -368,6 +378,7 @@ return {
variables = "none",
},
highlights = {
Search = { fg = "$bg0", bg = "$bg_yellow" },
-- BorderBG = { fg = "#333842" }, -- untuk custom brder color cmp
-- overide indent line fill color
NvimTreeNormal = { fg = "$fg", bg = "$bg0" },