mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
add: miniaimate
This commit is contained in:
parent
e50fb19878
commit
72ff763f68
15 changed files with 897 additions and 607 deletions
|
@ -6,6 +6,7 @@
|
|||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"code_runner.nvim": { "branch": "main", "commit": "6c5bfe44a6c7523350cd706e6b3b8101166eed99" },
|
||||
|
@ -15,7 +16,7 @@
|
|||
"friendly-snippets": { "branch": "main", "commit": "d0610077b6129cf9f7f78afbe3a1425d60f6e2f1" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "eab487c2520f0fe9e54eb5e3ea0606e20512492e" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "ad30030b6abca7dac5a493c58b4d183b3fe93202" },
|
||||
"lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" },
|
||||
|
@ -38,7 +39,7 @@
|
|||
"nvim-scrollview": { "branch": "main", "commit": "c29c5f69d37040a1fac88cbea7f5e6f06f0aff4d" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "2bc725a3ebc23f0172fb0ab4d1134b81bcc13812" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "979beffc1a86e7ba19bd6535c0370d8e1aaaad3c" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "5d60748e863a53442590e5767b2be216db32943a" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "fd41b7ccc5490a3a99c734d1ee418b68d06c48a9" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "bcf3146864262ef2d3c877beba3e222b5c73780d" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
|
||||
"nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" },
|
||||
|
|
|
@ -29,17 +29,6 @@ vim.api.nvim_create_autocmd("ExitPre", {
|
|||
desc = "Set cursor back to beam when leaving Neovim.",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"NvimTree",
|
||||
"lazy",
|
||||
"mason",
|
||||
},
|
||||
callback = function()
|
||||
require("ufo").detach()
|
||||
vim.opt_local.foldenable = false
|
||||
end,
|
||||
})
|
||||
|
||||
-- config for vim-visual-multi color selection
|
||||
vim.g.VM_Mono_hl = "DiffText"
|
||||
|
|
|
@ -111,4 +111,10 @@ vim.g.pcode_cmptag = false --https://github.com/quangnguyen30192/cmp-nvim-tags
|
|||
|
||||
-- 0 = normal
|
||||
-- 1 = float
|
||||
vim.g.pcode_nvimtree_isfloat = 1
|
||||
vim.g.pcode_nvimtree_isfloat = 0
|
||||
|
||||
vim.g.pcode_tailwindcolorizer = true
|
||||
vim.g.pcode_codeium = true
|
||||
vim.g.pcode_nvimufo = true
|
||||
vim.g.pcode_indentscope = true
|
||||
vim.g.pvode_minianimate = true
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
vim.g.codeium_disable_bindings = 1
|
||||
return {
|
||||
"Exafunction/codeium.vim",
|
||||
enabled = true,
|
||||
-- event = "BufEnter",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
-- Change '<C-g>' here to any keycode you like.
|
||||
vim.keymap.set("i", "<C-g>", function()
|
||||
return vim.fn["codeium#Accept"]()
|
||||
end, { expr = true, silent = true })
|
||||
vim.keymap.set("i", "<c-;>", function()
|
||||
return vim.fn["codeium#CycleCompletions"](1)
|
||||
end, { expr = true, silent = true })
|
||||
vim.keymap.set("i", "<c-,>", function()
|
||||
return vim.fn["codeium#CycleCompletions"](-1)
|
||||
end, { expr = true, silent = true })
|
||||
vim.keymap.set("i", "<c-x>", function()
|
||||
return vim.fn["codeium#Clear"]()
|
||||
end, { expr = true, silent = true })
|
||||
end,
|
||||
}
|
|
@ -19,30 +19,30 @@ return {
|
|||
-- },
|
||||
-- },
|
||||
-- },
|
||||
{
|
||||
"echasnovski/mini.indentscope",
|
||||
version = false, -- wait till new 0.7.0 release to put it back on semver
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
-- symbol = "▏",
|
||||
-- symbol = "│",
|
||||
symbol = icons.ui.LineMiddle,
|
||||
options = { try_as_border = true },
|
||||
},
|
||||
config = function(_, opts)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "help", "alpha", "dashboard", "NvimTree", "Trouble", "lazy", "mason" },
|
||||
callback = function()
|
||||
vim.b.miniindentscope_disable = true
|
||||
end,
|
||||
})
|
||||
require("mini.indentscope").setup(opts)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lua",
|
||||
enabled = false,
|
||||
},
|
||||
-- {
|
||||
-- "echasnovski/mini.indentscope",
|
||||
-- version = false, -- wait till new 0.7.0 release to put it back on semver
|
||||
-- event = "BufReadPre",
|
||||
-- opts = {
|
||||
-- -- symbol = "▏",
|
||||
-- -- symbol = "│",
|
||||
-- symbol = icons.ui.LineMiddle,
|
||||
-- options = { try_as_border = true },
|
||||
-- },
|
||||
-- config = function(_, opts)
|
||||
-- vim.api.nvim_create_autocmd("FileType", {
|
||||
-- pattern = { "help", "alpha", "dashboard", "NvimTree", "Trouble", "lazy", "mason" },
|
||||
-- callback = function()
|
||||
-- vim.b.miniindentscope_disable = true
|
||||
-- end,
|
||||
-- })
|
||||
-- require("mini.indentscope").setup(opts)
|
||||
-- end,
|
||||
-- },
|
||||
-- {
|
||||
-- "hrsh7th/cmp-nvim-lua",
|
||||
-- enabled = false,
|
||||
-- },
|
||||
-- {
|
||||
-- "gbprod/yanky.nvim",
|
||||
-- event = "BufReadPre",
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
return {
|
||||
-- "pojokcodeid/nvim-juliana",
|
||||
-- lazy = false,
|
||||
-- priority = 1000,
|
||||
-- opts = {},
|
||||
-- config = function()
|
||||
-- vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- -- get colors
|
||||
-- local colors = require("nvim-juliana").colors()
|
||||
-- -- custom hilights
|
||||
-- local hi = vim.api.nvim_set_hl
|
||||
-- hi(0, "FoldColumn", { bg = colors.bg2 })
|
||||
-- end,
|
||||
-- })
|
||||
-- end,
|
||||
}
|
|
@ -5,42 +5,42 @@ end
|
|||
|
||||
return {
|
||||
-- animations
|
||||
{
|
||||
"echasnovski/mini.animate",
|
||||
event = "BufRead",
|
||||
enabled = not is_neovide,
|
||||
opts = function()
|
||||
-- don't use animate when scrolling with the mouse
|
||||
local mouse_scrolled = false
|
||||
for _, scroll in ipairs({ "Up", "Down" }) do
|
||||
local key = "<ScrollWheel" .. scroll .. ">"
|
||||
vim.keymap.set({ "", "i" }, key, function()
|
||||
mouse_scrolled = true
|
||||
return key
|
||||
end, { expr = true })
|
||||
end
|
||||
|
||||
local animate = require("mini.animate")
|
||||
return {
|
||||
resize = {
|
||||
timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
|
||||
},
|
||||
scroll = {
|
||||
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
||||
subscroll = animate.gen_subscroll.equal({
|
||||
predicate = function(total_scroll)
|
||||
if mouse_scrolled then
|
||||
mouse_scrolled = false
|
||||
return false
|
||||
end
|
||||
return total_scroll > 1
|
||||
end,
|
||||
}),
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("mini.animate").setup(opts)
|
||||
end,
|
||||
},
|
||||
-- {
|
||||
-- "echasnovski/mini.animate",
|
||||
-- event = "BufRead",
|
||||
-- enabled = not is_neovide,
|
||||
-- opts = function()
|
||||
-- -- don't use animate when scrolling with the mouse
|
||||
-- local mouse_scrolled = false
|
||||
-- for _, scroll in ipairs({ "Up", "Down" }) do
|
||||
-- local key = "<ScrollWheel" .. scroll .. ">"
|
||||
-- vim.keymap.set({ "", "i" }, key, function()
|
||||
-- mouse_scrolled = true
|
||||
-- return key
|
||||
-- end, { expr = true })
|
||||
-- end
|
||||
--
|
||||
-- local animate = require("mini.animate")
|
||||
-- return {
|
||||
-- resize = {
|
||||
-- timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
|
||||
-- },
|
||||
-- scroll = {
|
||||
-- timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
||||
-- subscroll = animate.gen_subscroll.equal({
|
||||
-- predicate = function(total_scroll)
|
||||
-- if mouse_scrolled then
|
||||
-- mouse_scrolled = false
|
||||
-- return false
|
||||
-- end
|
||||
-- return total_scroll > 1
|
||||
-- end,
|
||||
-- }),
|
||||
-- },
|
||||
-- }
|
||||
-- end,
|
||||
-- config = function(_, opts)
|
||||
-- require("mini.animate").setup(opts)
|
||||
-- end,
|
||||
-- },
|
||||
}
|
||||
|
|
|
@ -11,325 +11,325 @@ end
|
|||
local icons = vim.g.pcode_icons.folding
|
||||
|
||||
return {
|
||||
"kevinhwang91/nvim-ufo",
|
||||
dependencies = {
|
||||
"kevinhwang91/promise-async",
|
||||
{
|
||||
"luukvbaal/statuscol.nvim",
|
||||
config = function()
|
||||
local builtin = require("statuscol.builtin")
|
||||
require("statuscol").setup({
|
||||
-- "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 = { builtin.foldfunc }, click = "v:lua.ScFa" },
|
||||
-- { text = { "%s" }, click = "v:lua.ScSa" },
|
||||
-- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||
-- {
|
||||
-- -- text = { builtin.foldfunc, " " },
|
||||
-- text = { builtin.foldfunc },
|
||||
-- condition = { builtin.not_empty, true, builtin.not_empty },
|
||||
-- click = "v:lua.ScFa",
|
||||
-- },
|
||||
setopt = true,
|
||||
relculright = true,
|
||||
segments = {
|
||||
{ text = { "%s" }, click = "v:lua.ScSa" },
|
||||
{
|
||||
-- text = { builtin.foldfunc, " " },
|
||||
text = { builtin.foldfunc },
|
||||
condition = { builtin.not_empty, true, builtin.not_empty },
|
||||
click = "v:lua.ScFa",
|
||||
},
|
||||
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||
-- { text = { builtin.lnumfunc }, click = "v:lua.ScLa" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
enabled = true,
|
||||
lazy = true,
|
||||
-- event = "BufReadPost",
|
||||
-- event = { "BufReadPost", "BufRead", "InsertEnter", "BufNewFile" },
|
||||
event = "VeryLazy",
|
||||
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:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:▾,foldsep:│,foldclose:▸]]
|
||||
vim.opt.fillchars = {
|
||||
vert = icons.vert,
|
||||
fold = icons.fold,
|
||||
eob = icons.eob,
|
||||
diff = icons.diff,
|
||||
msgsep = icons.msgsep,
|
||||
foldopen = icons.foldopen,
|
||||
foldsep = icons.foldsep,
|
||||
foldclose = icons.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"))
|
||||
-- vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("IblIndent")), "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" }
|
||||
-- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||
-- -- { text = { builtin.lnumfunc }, click = "v:lua.ScLa" },
|
||||
-- },
|
||||
-- }
|
||||
-- end,
|
||||
open_fold_hl_timeout = 150,
|
||||
close_fold_kinds_for_ft = {
|
||||
default = { "imports", "comment" },
|
||||
json = { "array" },
|
||||
c = { "comment", "region" },
|
||||
},
|
||||
preview = {
|
||||
win_config = {
|
||||
border = { "", "─", "", "", "", "─", "", "" },
|
||||
-- winhighlight = 'Normal:Normal',
|
||||
-- winhighlight = 'IncSearch:Folded',
|
||||
winhighlight = "Normal:UfoPreviewNormal,FloatBorder:UfoPreviewBorder,CursorLine:UfoPreviewCursorLine",
|
||||
winblend = 0,
|
||||
},
|
||||
mappings = {
|
||||
scrollU = "<C-u>",
|
||||
scrollD = "<C-d>",
|
||||
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" })
|
||||
if vim.bo.filetype ~= "json" then
|
||||
table.insert(result, { suffix, "TSPunctBracket" })
|
||||
end
|
||||
return result
|
||||
end,
|
||||
})]]
|
||||
-- },
|
||||
-- },
|
||||
-- enabled = true,
|
||||
-- lazy = true,
|
||||
-- -- event = "BufReadPost",
|
||||
-- -- event = { "BufReadPost", "BufRead", "InsertEnter", "BufNewFile" },
|
||||
-- event = "VeryLazy",
|
||||
-- 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:]]
|
||||
-- -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- -- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- -- vim.o.fillchars = [[eob: ,fold: ,foldopen:▾,foldsep:│,foldclose:▸]]
|
||||
-- vim.opt.fillchars = {
|
||||
-- vert = icons.vert,
|
||||
-- fold = icons.fold,
|
||||
-- eob = icons.eob,
|
||||
-- diff = icons.diff,
|
||||
-- msgsep = icons.msgsep,
|
||||
-- foldopen = icons.foldopen,
|
||||
-- foldsep = icons.foldsep,
|
||||
-- foldclose = icons.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"))
|
||||
-- -- vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("IblIndent")), "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()`
|
||||
--
|
||||
|
||||
-- start ini bagian code support comment dan import
|
||||
local ftMap = {
|
||||
vim = "indent",
|
||||
python = { "indent" },
|
||||
git = "",
|
||||
-- javascriptreact = { "treesitter", "indent" },
|
||||
-- typescriptreact = { "treesitter", "indent" },
|
||||
}
|
||||
|
||||
local function customizeSelector(bufnr)
|
||||
local function handleFallbackException(err, providerName)
|
||||
if type(err) == "string" and err:match("UfoFallbackException") then
|
||||
return require("ufo").getFolds(bufnr, providerName)
|
||||
else
|
||||
return require("promise").reject(err)
|
||||
end
|
||||
end
|
||||
|
||||
return require("ufo")
|
||||
.getFolds(bufnr, "lsp")
|
||||
:catch(function(err)
|
||||
return handleFallbackException(err, "treesitter")
|
||||
end)
|
||||
:catch(function(err)
|
||||
return handleFallbackException(err, "indent")
|
||||
end)
|
||||
end
|
||||
|
||||
require("ufo").setup({
|
||||
open_fold_hl_timeout = 150,
|
||||
close_fold_kinds_for_ft = {
|
||||
-- --[[require("ufo").setup({
|
||||
-- -- provider_selector = function(bufnr, filetype, buftype)
|
||||
-- -- return { "treesitter", "indent" }
|
||||
-- -- end,
|
||||
-- open_fold_hl_timeout = 150,
|
||||
-- close_fold_kinds_for_ft = {
|
||||
-- default = { "imports", "comment" },
|
||||
-- json = { "array" },
|
||||
-- c = { "comment", "region" },
|
||||
},
|
||||
preview = {
|
||||
win_config = {
|
||||
border = { "", "─", "", "", "", "─", "", "" },
|
||||
winhighlight = "Normal:Folded",
|
||||
winblend = 0,
|
||||
},
|
||||
mappings = {
|
||||
scrollU = "<C-u>",
|
||||
scrollD = "<C-d>",
|
||||
jumpTop = "[",
|
||||
jumpBot = "]",
|
||||
},
|
||||
},
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
-- if you prefer treesitter provider rather than lsp,
|
||||
-- return ftMap[filetype]
|
||||
-- return ftMap[filetype] or {'treesitter', 'indent'}
|
||||
return ftMap[filetype] or customizeSelector
|
||||
|
||||
-- refer to ./doc/example.lua for detail
|
||||
end,
|
||||
|
||||
fold_virt_text_handler = function(virt_text, lnum, end_lnum, width, truncate)
|
||||
local result = {}
|
||||
local closed_fold_text = "comments ..." -- Teks yang ingin ditampilkan
|
||||
local import_fold_text = "import ..." -- Teks yang ingin ditampilkan
|
||||
local is_comment = false -- Variabel untuk mengecek apakah ini komentar
|
||||
local is_import = false
|
||||
local is_bracket = false
|
||||
|
||||
-- Memeriksa apakah baris awal dari fold adalah komentar
|
||||
local start_line = vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, false)[1]
|
||||
-- cari comentar dengan awalan /* untuk generaal comment
|
||||
if start_line:find("^%s*%/%*") then
|
||||
is_comment = true
|
||||
-- cara commentar dengan awalan <!-- untuk html
|
||||
elseif start_line:find("^%s*<!--") then
|
||||
is_comment = true
|
||||
-- cari comentar dengan awalan -- untuk lua
|
||||
elseif start_line:find("^%s*%-%-") then
|
||||
is_comment = true
|
||||
end
|
||||
-- cek fold yang berawalan import
|
||||
if start_line:find("^%s*import") then
|
||||
is_import = true
|
||||
end
|
||||
-- cek fold dengan akhiran {
|
||||
if start_line:find("%s*{%s*$") then
|
||||
is_bracket = true
|
||||
end
|
||||
if is_comment then
|
||||
local suffix = string.format(" %s ", closed_fold_text)
|
||||
local target_width = width - vim.fn.strdisplaywidth(suffix)
|
||||
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 })
|
||||
break
|
||||
end
|
||||
cur_width = cur_width + chunk_width
|
||||
end
|
||||
-- Menambahkan teks 'Comments ...' ke akhir baris yang dilipat
|
||||
table.insert(result, { suffix, "NonText" })
|
||||
elseif is_import then
|
||||
--[[
|
||||
local suffix = string.format(" %s ", import_fold_text)
|
||||
local target_width = width - vim.fn.strdisplaywidth(suffix)
|
||||
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 })
|
||||
break
|
||||
end
|
||||
cur_width = cur_width + chunk_width
|
||||
end
|
||||
-- Menambahkan teks 'Comments ...' ke akhir baris yang dilipat
|
||||
table.insert(result, { suffix, "NonText" })
|
||||
]]
|
||||
--
|
||||
|
||||
local suffix = (" %d "):format(end_lnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
for _, chunk in ipairs(virt_text) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(result, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(result, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
table.insert(result, { " import⋯ ", "NonText" })
|
||||
table.insert(result, { suffix, "MoreMsg" })
|
||||
else
|
||||
-- Jika bukan komentar, tampilkan teks asli
|
||||
-- },
|
||||
-- preview = {
|
||||
-- win_config = {
|
||||
-- border = { "", "─", "", "", "", "─", "", "" },
|
||||
-- -- winhighlight = 'Normal:Normal',
|
||||
-- -- winhighlight = 'IncSearch:Folded',
|
||||
-- winhighlight = "Normal:UfoPreviewNormal,FloatBorder:UfoPreviewBorder,CursorLine:UfoPreviewCursorLine",
|
||||
-- winblend = 0,
|
||||
-- },
|
||||
-- mappings = {
|
||||
-- scrollU = "<C-u>",
|
||||
-- scrollD = "<C-d>",
|
||||
-- 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
|
||||
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" })
|
||||
local l = { "javascriptreact", "typescriptreact" }
|
||||
if TABLE_CONTAINS(l, vim.bo.filetype) and not is_bracket then
|
||||
table.insert(result, { suffix, "TSPunctBracket" })
|
||||
end
|
||||
end
|
||||
return result
|
||||
end,
|
||||
})
|
||||
-- end bagian code support comment dan import
|
||||
end,
|
||||
-- break
|
||||
-- end
|
||||
-- cur_width = cur_width + chunk_width
|
||||
-- end
|
||||
-- table.insert(result, { " ⋯ ", "NonText" })
|
||||
-- if vim.bo.filetype ~= "json" then
|
||||
-- table.insert(result, { suffix, "TSPunctBracket" })
|
||||
-- end
|
||||
-- return result
|
||||
-- end,
|
||||
-- })]]
|
||||
-- --
|
||||
--
|
||||
-- -- start ini bagian code support comment dan import
|
||||
-- local ftMap = {
|
||||
-- vim = "indent",
|
||||
-- python = { "indent" },
|
||||
-- git = "",
|
||||
-- -- javascriptreact = { "treesitter", "indent" },
|
||||
-- -- typescriptreact = { "treesitter", "indent" },
|
||||
-- }
|
||||
--
|
||||
-- local function customizeSelector(bufnr)
|
||||
-- local function handleFallbackException(err, providerName)
|
||||
-- if type(err) == "string" and err:match "UfoFallbackException" then
|
||||
-- return require("ufo").getFolds(bufnr, providerName)
|
||||
-- else
|
||||
-- return require("promise").reject(err)
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- return require("ufo")
|
||||
-- .getFolds(bufnr, "lsp")
|
||||
-- :catch(function(err)
|
||||
-- return handleFallbackException(err, "treesitter")
|
||||
-- end)
|
||||
-- :catch(function(err)
|
||||
-- return handleFallbackException(err, "indent")
|
||||
-- end)
|
||||
-- end
|
||||
--
|
||||
-- require("ufo").setup {
|
||||
-- open_fold_hl_timeout = 150,
|
||||
-- close_fold_kinds_for_ft = {
|
||||
-- -- default = { "imports", "comment" },
|
||||
-- -- json = { "array" },
|
||||
-- -- c = { "comment", "region" },
|
||||
-- },
|
||||
-- preview = {
|
||||
-- win_config = {
|
||||
-- border = { "", "─", "", "", "", "─", "", "" },
|
||||
-- winhighlight = "Normal:Folded",
|
||||
-- winblend = 0,
|
||||
-- },
|
||||
-- mappings = {
|
||||
-- scrollU = "<C-u>",
|
||||
-- scrollD = "<C-d>",
|
||||
-- jumpTop = "[",
|
||||
-- jumpBot = "]",
|
||||
-- },
|
||||
-- },
|
||||
-- provider_selector = function(bufnr, filetype, buftype)
|
||||
-- -- if you prefer treesitter provider rather than lsp,
|
||||
-- -- return ftMap[filetype]
|
||||
-- -- return ftMap[filetype] or {'treesitter', 'indent'}
|
||||
-- return ftMap[filetype] or customizeSelector
|
||||
--
|
||||
-- -- refer to ./doc/example.lua for detail
|
||||
-- end,
|
||||
--
|
||||
-- fold_virt_text_handler = function(virt_text, lnum, end_lnum, width, truncate)
|
||||
-- local result = {}
|
||||
-- local closed_fold_text = "comments ..." -- Teks yang ingin ditampilkan
|
||||
-- local import_fold_text = "import ..." -- Teks yang ingin ditampilkan
|
||||
-- local is_comment = false -- Variabel untuk mengecek apakah ini komentar
|
||||
-- local is_import = false
|
||||
-- local is_bracket = false
|
||||
--
|
||||
-- -- Memeriksa apakah baris awal dari fold adalah komentar
|
||||
-- local start_line = vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, false)[1]
|
||||
-- -- cari comentar dengan awalan /* untuk generaal comment
|
||||
-- if start_line:find "^%s*%/%*" then
|
||||
-- is_comment = true
|
||||
-- -- cara commentar dengan awalan <!-- untuk html
|
||||
-- elseif start_line:find "^%s*<!--" then
|
||||
-- is_comment = true
|
||||
-- -- cari comentar dengan awalan -- untuk lua
|
||||
-- elseif start_line:find "^%s*%-%-" then
|
||||
-- is_comment = true
|
||||
-- end
|
||||
-- -- cek fold yang berawalan import
|
||||
-- if start_line:find "^%s*import" then
|
||||
-- is_import = true
|
||||
-- end
|
||||
-- -- cek fold dengan akhiran {
|
||||
-- if start_line:find "%s*{%s*$" then
|
||||
-- is_bracket = true
|
||||
-- end
|
||||
-- if is_comment then
|
||||
-- local suffix = string.format(" %s ", closed_fold_text)
|
||||
-- local target_width = width - vim.fn.strdisplaywidth(suffix)
|
||||
-- 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 })
|
||||
-- break
|
||||
-- end
|
||||
-- cur_width = cur_width + chunk_width
|
||||
-- end
|
||||
-- -- Menambahkan teks 'Comments ...' ke akhir baris yang dilipat
|
||||
-- table.insert(result, { suffix, "NonText" })
|
||||
-- elseif is_import then
|
||||
-- --[[
|
||||
-- local suffix = string.format(" %s ", import_fold_text)
|
||||
-- local target_width = width - vim.fn.strdisplaywidth(suffix)
|
||||
-- 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 })
|
||||
-- break
|
||||
-- end
|
||||
-- cur_width = cur_width + chunk_width
|
||||
-- end
|
||||
-- -- Menambahkan teks 'Comments ...' ke akhir baris yang dilipat
|
||||
-- table.insert(result, { suffix, "NonText" })
|
||||
-- ]]
|
||||
-- --
|
||||
--
|
||||
-- local suffix = (" %d "):format(end_lnum - lnum)
|
||||
-- local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
-- local targetWidth = width - sufWidth
|
||||
-- local curWidth = 0
|
||||
-- for _, chunk in ipairs(virt_text) do
|
||||
-- local chunkText = chunk[1]
|
||||
-- local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- if targetWidth > curWidth + chunkWidth then
|
||||
-- table.insert(result, chunk)
|
||||
-- else
|
||||
-- chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
-- local hlGroup = chunk[2]
|
||||
-- table.insert(result, { chunkText, hlGroup })
|
||||
-- chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- -- str width returned from truncate() may less than 2nd argument, need padding
|
||||
-- if curWidth + chunkWidth < targetWidth then
|
||||
-- suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||
-- end
|
||||
-- break
|
||||
-- end
|
||||
-- curWidth = curWidth + chunkWidth
|
||||
-- end
|
||||
-- table.insert(result, { " import⋯ ", "NonText" })
|
||||
-- table.insert(result, { suffix, "MoreMsg" })
|
||||
-- else
|
||||
-- -- Jika bukan komentar, tampilkan teks asli
|
||||
-- -- for _, chunk in ipairs(virt_text) do
|
||||
-- -- table.insert(result, chunk)
|
||||
-- -- end
|
||||
-- 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" })
|
||||
-- local l = { "javascriptreact", "typescriptreact" }
|
||||
-- if TABLE_CONTAINS(l, vim.bo.filetype) and not is_bracket then
|
||||
-- table.insert(result, { suffix, "TSPunctBracket" })
|
||||
-- end
|
||||
-- end
|
||||
-- return result
|
||||
-- end,
|
||||
-- }
|
||||
-- -- end bagian code support comment dan import
|
||||
-- end,
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
return {
|
||||
{
|
||||
"NvChad/nvim-colorizer.lua",
|
||||
opts = {
|
||||
user_default_options = {
|
||||
tailwind = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
||||
},
|
||||
opts = function(_, opts)
|
||||
-- original kind icon formatter
|
||||
local format_kinds = opts.formatting.format
|
||||
opts.formatting.format = function(entry, item)
|
||||
format_kinds(entry, item) -- add icons
|
||||
local lspkind = require("tailwindcss-colorizer-cmp").formatter(entry, item)
|
||||
if lspkind.kind == "XX" then
|
||||
lspkind.kind = " "
|
||||
end
|
||||
return lspkind
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
-- config = function()
|
||||
-- -- require("nvim-treesitter.configs").setup({
|
||||
-- -- ensure_installed = { "html", "css", "javascript" },
|
||||
-- -- })
|
||||
-- end,
|
||||
}
|
29
lua/plugins/codeioum.lua
Normal file
29
lua/plugins/codeioum.lua
Normal file
|
@ -0,0 +1,29 @@
|
|||
local M = {}
|
||||
if vim.g.pcode_codeium then
|
||||
M.codeium = {
|
||||
"Exafunction/codeium.vim",
|
||||
enabled = true,
|
||||
-- event = "BufEnter",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
vim.g.codeium_disable_bindings = 1
|
||||
-- Change '<C-g>' here to any keycode you like.
|
||||
vim.keymap.set("i", "<C-g>", function()
|
||||
return vim.fn["codeium#Accept"]()
|
||||
end, { expr = true, silent = true })
|
||||
vim.keymap.set("i", "<c-;>", function()
|
||||
return vim.fn["codeium#CycleCompletions"](1)
|
||||
end, { expr = true, silent = true })
|
||||
vim.keymap.set("i", "<c-,>", function()
|
||||
return vim.fn["codeium#CycleCompletions"](-1)
|
||||
end, { expr = true, silent = true })
|
||||
vim.keymap.set("i", "<c-x>", function()
|
||||
return vim.fn["codeium#Clear"]()
|
||||
end, { expr = true, silent = true })
|
||||
end,
|
||||
}
|
||||
else
|
||||
M.codeium = {}
|
||||
end
|
||||
|
||||
return M.codeium
|
20
lua/plugins/indentscupe.lua
Normal file
20
lua/plugins/indentscupe.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
local icons = vim.g.pcode_icons
|
||||
return {
|
||||
"echasnovski/mini.indentscope",
|
||||
version = false, -- wait till new 0.7.0 release to put it back on semver
|
||||
event = "BufReadPre",
|
||||
enabled = vim.g.pcode_indentscope and true or false,
|
||||
opts = {
|
||||
symbol = icons.ui.LineMiddle,
|
||||
options = { try_as_border = true },
|
||||
},
|
||||
config = function(_, opts)
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "help", "alpha", "dashboard", "NvimTree", "Trouble", "lazy", "mason" },
|
||||
callback = function()
|
||||
vim.b.miniindentscope_disable = true
|
||||
end,
|
||||
})
|
||||
require("mini.indentscope").setup(opts)
|
||||
end,
|
||||
}
|
41
lua/plugins/mini-animate.lua
Normal file
41
lua/plugins/mini-animate.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
return {
|
||||
-- animations
|
||||
{
|
||||
"echasnovski/mini.animate",
|
||||
event = "BufRead",
|
||||
enabled = not vim.g.neovide and vim.g.pvode_minianimate and true or false,
|
||||
opts = function()
|
||||
-- don't use animate when scrolling with the mouse
|
||||
local mouse_scrolled = false
|
||||
for _, scroll in ipairs { "Up", "Down" } do
|
||||
local key = "<ScrollWheel" .. scroll .. ">"
|
||||
vim.keymap.set({ "", "i" }, key, function()
|
||||
mouse_scrolled = true
|
||||
return key
|
||||
end, { expr = true })
|
||||
end
|
||||
|
||||
local animate = require "mini.animate"
|
||||
return {
|
||||
resize = {
|
||||
timing = animate.gen_timing.linear { duration = 100, unit = "total" },
|
||||
},
|
||||
scroll = {
|
||||
timing = animate.gen_timing.linear { duration = 150, unit = "total" },
|
||||
subscroll = animate.gen_subscroll.equal {
|
||||
predicate = function(total_scroll)
|
||||
if mouse_scrolled then
|
||||
mouse_scrolled = false
|
||||
return false
|
||||
end
|
||||
return total_scroll > 1
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("mini.animate").setup(opts)
|
||||
end,
|
||||
},
|
||||
}
|
243
lua/plugins/nvimufo.lua
Normal file
243
lua/plugins/nvimufo.lua
Normal file
|
@ -0,0 +1,243 @@
|
|||
function TABLE_CONTAINS(tbl, x)
|
||||
local found = false
|
||||
for _, v in pairs(tbl) do
|
||||
if v == x then
|
||||
found = true
|
||||
end
|
||||
end
|
||||
return found
|
||||
end
|
||||
|
||||
local icons = vim.g.pcode_icons.folding
|
||||
|
||||
local M = {}
|
||||
|
||||
if vim.g.pcode_nvimufo then
|
||||
M.ufo = {
|
||||
"kevinhwang91/nvim-ufo",
|
||||
dependencies = {
|
||||
"kevinhwang91/promise-async",
|
||||
{
|
||||
"luukvbaal/statuscol.nvim",
|
||||
config = function()
|
||||
local builtin = require "statuscol.builtin"
|
||||
require("statuscol").setup {
|
||||
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,
|
||||
},
|
||||
},
|
||||
enabled = true,
|
||||
lazy = true,
|
||||
event = "VeryLazy",
|
||||
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:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
|
||||
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:▾,foldsep:│,foldclose:▸]]
|
||||
vim.opt.fillchars = {
|
||||
vert = icons.vert,
|
||||
fold = icons.fold,
|
||||
eob = icons.eob,
|
||||
diff = icons.diff,
|
||||
msgsep = icons.msgsep,
|
||||
foldopen = icons.foldopen,
|
||||
foldsep = icons.foldsep,
|
||||
foldclose = icons.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"))
|
||||
-- start ini bagian code support comment dan import
|
||||
local ftMap = {
|
||||
vim = "indent",
|
||||
python = { "indent" },
|
||||
git = "",
|
||||
}
|
||||
|
||||
local function customizeSelector(bufnr)
|
||||
local function handleFallbackException(err, providerName)
|
||||
if type(err) == "string" and err:match "UfoFallbackException" then
|
||||
return require("ufo").getFolds(bufnr, providerName)
|
||||
else
|
||||
return require("promise").reject(err)
|
||||
end
|
||||
end
|
||||
|
||||
return require("ufo")
|
||||
.getFolds(bufnr, "lsp")
|
||||
:catch(function(err)
|
||||
return handleFallbackException(err, "treesitter")
|
||||
end)
|
||||
:catch(function(err)
|
||||
return handleFallbackException(err, "indent")
|
||||
end)
|
||||
end
|
||||
|
||||
require("ufo").setup {
|
||||
open_fold_hl_timeout = 150,
|
||||
close_fold_kinds_for_ft = {
|
||||
-- default = { "imports", "comment" },
|
||||
-- json = { "array" },
|
||||
-- c = { "comment", "region" },
|
||||
},
|
||||
preview = {
|
||||
win_config = {
|
||||
border = { "", "─", "", "", "", "─", "", "" },
|
||||
winhighlight = "Normal:Folded",
|
||||
winblend = 0,
|
||||
},
|
||||
mappings = {
|
||||
scrollU = "<C-u>",
|
||||
scrollD = "<C-d>",
|
||||
jumpTop = "[",
|
||||
jumpBot = "]",
|
||||
},
|
||||
},
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
return ftMap[filetype] or customizeSelector
|
||||
end,
|
||||
|
||||
fold_virt_text_handler = function(virt_text, lnum, end_lnum, width, truncate)
|
||||
local result = {}
|
||||
local closed_fold_text = "comments ..." -- Teks yang ingin ditampilkan
|
||||
local import_fold_text = "import ..." -- Teks yang ingin ditampilkan
|
||||
local is_comment = false -- Variabel untuk mengecek apakah ini komentar
|
||||
local is_import = false
|
||||
local is_bracket = false
|
||||
|
||||
-- Memeriksa apakah baris awal dari fold adalah komentar
|
||||
local start_line = vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, false)[1]
|
||||
-- cari comentar dengan awalan /* untuk generaal comment
|
||||
if start_line:find "^%s*%/%*" then
|
||||
is_comment = true
|
||||
-- cara commentar dengan awalan <!-- untuk html
|
||||
elseif start_line:find "^%s*<!--" then
|
||||
is_comment = true
|
||||
-- cari comentar dengan awalan -- untuk lua
|
||||
elseif start_line:find "^%s*%-%-" then
|
||||
is_comment = true
|
||||
end
|
||||
-- cek fold yang berawalan import
|
||||
if start_line:find "^%s*import" then
|
||||
is_import = true
|
||||
end
|
||||
-- cek fold dengan akhiran {
|
||||
if start_line:find "%s*{%s*$" then
|
||||
is_bracket = true
|
||||
end
|
||||
if is_comment then
|
||||
local suffix = string.format(" %s ", closed_fold_text)
|
||||
local target_width = width - vim.fn.strdisplaywidth(suffix)
|
||||
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 })
|
||||
break
|
||||
end
|
||||
cur_width = cur_width + chunk_width
|
||||
end
|
||||
-- Menambahkan teks 'Comments ...' ke akhir baris yang dilipat
|
||||
table.insert(result, { suffix, "NonText" })
|
||||
elseif is_import then
|
||||
local suffix = (" %d "):format(end_lnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
for _, chunk in ipairs(virt_text) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(result, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(result, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
table.insert(result, { " import⋯ ", "NonText" })
|
||||
table.insert(result, { suffix, "MoreMsg" })
|
||||
else
|
||||
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" })
|
||||
local l = { "javascriptreact", "typescriptreact" }
|
||||
if TABLE_CONTAINS(l, vim.bo.filetype) and not is_bracket then
|
||||
table.insert(result, { suffix, "TSPunctBracket" })
|
||||
end
|
||||
end
|
||||
return result
|
||||
end,
|
||||
}
|
||||
-- end bagian code support comment dan import
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = {
|
||||
"NvimTree",
|
||||
"lazy",
|
||||
"mason",
|
||||
},
|
||||
callback = function()
|
||||
require("ufo").detach()
|
||||
vim.opt_local.foldenable = false
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
else
|
||||
M.ufo = {}
|
||||
end
|
||||
|
||||
return M.ufo
|
37
lua/plugins/tailwind.lua
Normal file
37
lua/plugins/tailwind.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
local M = {}
|
||||
if vim.g.pcode_tailwindcolorizer then
|
||||
M.tailwind = {
|
||||
{
|
||||
"NvChad/nvim-colorizer.lua",
|
||||
opts = {
|
||||
user_default_options = {
|
||||
tailwind = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
||||
},
|
||||
opts = function(_, opts)
|
||||
-- original kind icon formatter
|
||||
local format_kinds = opts.formatting.format
|
||||
opts.formatting.format = function(entry, item)
|
||||
format_kinds(entry, item) -- add icons
|
||||
local lspkind = require("tailwindcss-colorizer-cmp").formatter(entry, item)
|
||||
if lspkind.kind == "XX" then
|
||||
lspkind.kind = " "
|
||||
end
|
||||
return lspkind
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
else
|
||||
M.tailwind = {}
|
||||
end
|
||||
|
||||
return {
|
||||
M.tailwind,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue