enc: fix nvim-tree exploler error

This commit is contained in:
Pojok Code 2024-10-11 21:00:37 +07:00
parent 2ce30970f6
commit 30ba4f5233
9 changed files with 414 additions and 11 deletions

View file

@ -103,7 +103,7 @@ pcode.coderunner = {
-- https://github.com/nvim-tree/nvim-tree.lua -- https://github.com/nvim-tree/nvim-tree.lua
-- 0 = normal -- 0 = normal
-- 1 = float -- 1 = float
pcode.nvimtree_isfloat = 0 pcode.nvimtree_isfloat = 1
-- https://github.com/roobert/tailwindcss-colorizer-cmp.nvim -- https://github.com/roobert/tailwindcss-colorizer-cmp.nvim
pcode.tailwindcolorizer = false pcode.tailwindcolorizer = false
@ -154,10 +154,10 @@ pcode.refactoring = false
pcode.database = false pcode.database = false
-- https://github.com/rest-nvim/rest.nvim -- https://github.com/rest-nvim/rest.nvim
pcode.rest_client = true pcode.rest_client = false
-- https://github.com/mfussenegger/nvim-dap -- https://github.com/mfussenegger/nvim-dap
pcode.nvim_dap = true -- not support for windows os (auto config mason-nvim-dap) pcode.nvim_dap = false -- not support for windows os (auto config mason-nvim-dap)
-- conefig special support test & dap -- conefig special support test & dap
pcode.active_rust_config = false pcode.active_rust_config = false
@ -166,7 +166,7 @@ pcode.active_javascript_config = {
jest_command = "npm test -- ", jest_command = "npm test -- ",
jest_config = "jest.config.mjs", jest_config = "jest.config.mjs",
} }
pcode.active_prisma_config = true pcode.active_prisma_config = false
pcode.active_php_config = false pcode.active_php_config = false
pcode.active_golang_config = false pcode.active_golang_config = false
pcode.active_python_config = false pcode.active_python_config = false

View file

@ -177,6 +177,10 @@ return {
fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" },
bg = { attribute = "bg", highlight = "Normal" }, bg = { attribute = "bg", highlight = "Normal" },
}, },
indicator_visible = {
fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" },
bg = { attribute = "bg", highlight = "Normal" },
},
}, },
}) })
end, end,

View file

@ -99,6 +99,13 @@ return {
desc = "Scroll backward", desc = "Scroll backward",
mode = { "i", "n", "s" }, mode = { "i", "n", "s" },
}, },
{
"<f2>",
function()
require("user.utils.cheatsheet").run()
end,
desc = "Chatseet",
},
}, },
}, },
{ {

View file

@ -1,10 +1,10 @@
local icons = pcode.icons
local set_view = {} local set_view = {}
if pcode.nvimtree_isfloat == 1 then if pcode.nvimtree_isfloat == 1 then
set_view = require("user.utils.nvimtree").float set_view = require("user.utils.nvimtree").float
else else
set_view = require("user.utils.nvimtree").normal set_view = require("user.utils.nvimtree").normal
end end
--[[ local icons = pcode.icons
return { return {
"kyazdani42/nvim-tree.lua", "kyazdani42/nvim-tree.lua",
lazy = true, lazy = true,
@ -219,3 +219,98 @@ return {
end) end)
end, end,
} }
]]
return {
"nvim-tree/nvim-tree.lua",
cmd = { "NvimTreeFindFileToggle", "NvimTree", "NvimTreeOpen", "NvimTreeToggle", "NvimTreeFocus", "NvimTreeClose" },
keys = {
{ "<leader>e", "<cmd>NvimTreeToggle<cr>", desc = "󰙅 Explorer" },
},
opts = function()
local icons = pcode.icons
return {
filters = { dotfiles = false },
disable_netrw = true,
hijack_cursor = true,
sync_root_with_cwd = true,
update_focused_file = {
enable = true,
update_root = false,
},
view = set_view,
renderer = {
root_folder_label = false,
highlight_git = true,
-- indent_markers = { enable = true },
indent_markers = {
enable = true,
inline_arrows = true,
icons = {
corner = "",
edge = "",
item = "",
none = " ",
},
},
icons = {
webdev_colors = true,
git_placement = "before",
padding = " ",
symlink_arrow = "",
show = {
file = true,
folder = true,
folder_arrow = true,
git = true,
},
glyphs = {
default = icons.ui.Text,
symlink = icons.ui.FileSymlink,
bookmark = icons.ui.BookMark,
folder = {
-- arrow_closed = icons.ui.TriangleShortArrowRight,
arrow_closed = icons.ui.ChevronShortRight,
-- arrow_open = icons.ui.TriangleShortArrowDown,
arrow_open = icons.ui.ChevronShortDown,
default = icons.ui.Folder,
open = icons.ui.FolderOpen,
empty = icons.ui.EmptyFolder,
empty_open = icons.ui.EmptyFolderOpen,
symlink = icons.ui.FolderSymlink,
symlink_open = icons.ui.FolderOpen,
},
git = {
unstaged = icons.git.FileUnstaged,
staged = icons.git.FileStaged,
unmerged = icons.git.FileUnmerged,
renamed = icons.git.FileRenamed,
untracked = icons.git.FileUntracked,
deleted = icons.git.FileDeleted,
ignored = icons.git.FileIgnored,
},
},
},
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
symlink_destination = true,
},
filters = {
dotfiles = false,
git_clean = false,
no_buffer = false,
custom = { "node_modules", "\\.cache", "\\.git" },
exclude = {
".gitignore",
".prettierignore",
},
},
}
end,
config = function(_, opts)
require("nvim-tree").setup(opts)
local api = require("nvim-tree.api")
api.events.subscribe(api.events.Event.FileCreated, function(file)
vim.cmd("edit " .. file.fname)
end)
end,
}

View file

@ -0,0 +1,222 @@
-- local icons = pcode.icons
-- local set_view = {}
-- if pcode.nvimtree_isfloat == 1 then
-- set_view = require("user.utils.nvimtree").float
-- else
-- set_view = require("user.utils.nvimtree").normal
-- end
-- return {
-- "kyazdani42/nvim-tree.lua",
-- lazy = true,
-- cmd = { "NvimTreeFindFileToggle", "NvimTree", "NvimTreeOpen", "NvimTreeToggle", "NvimTreeFocus", "NvimTreeClose" },
-- opts = {
-- auto_reload_on_write = false,
-- disable_netrw = false,
-- hijack_cursor = false,
-- hijack_netrw = true,
-- hijack_unnamed_buffer_when_opening = false,
-- sort_by = "name",
-- root_dirs = {},
-- prefer_startup_root = false,
-- sync_root_with_cwd = true,
-- reload_on_bufenter = false,
-- respect_buf_cwd = false,
-- on_attach = "default",
-- select_prompts = false,
-- view = set_view,
-- renderer = {
-- add_trailing = false,
-- group_empty = false,
-- highlight_git = true,
-- full_name = false,
-- highlight_opened_files = "none",
-- -- root_folder_label = ":t",
-- root_folder_label = false,
-- indent_width = 2,
-- indent_markers = {
-- enable = true,
-- inline_arrows = true,
-- icons = {
-- corner = "└",
-- edge = "│",
-- item = "│",
-- none = " ",
-- },
-- },
-- icons = {
-- webdev_colors = true,
-- git_placement = "before",
-- padding = " ",
-- symlink_arrow = " ➛ ",
-- show = {
-- file = true,
-- folder = true,
-- folder_arrow = true,
-- git = true,
-- },
-- glyphs = {
-- default = icons.ui.Text,
-- symlink = icons.ui.FileSymlink,
-- bookmark = icons.ui.BookMark,
-- folder = {
-- -- arrow_closed = icons.ui.TriangleShortArrowRight,
-- arrow_closed = icons.ui.ChevronShortRight,
-- -- arrow_open = icons.ui.TriangleShortArrowDown,
-- arrow_open = icons.ui.ChevronShortDown,
-- default = icons.ui.Folder,
-- open = icons.ui.FolderOpen,
-- empty = icons.ui.EmptyFolder,
-- empty_open = icons.ui.EmptyFolderOpen,
-- symlink = icons.ui.FolderSymlink,
-- symlink_open = icons.ui.FolderOpen,
-- },
-- git = {
-- unstaged = icons.git.FileUnstaged,
-- staged = icons.git.FileStaged,
-- unmerged = icons.git.FileUnmerged,
-- renamed = icons.git.FileRenamed,
-- untracked = icons.git.FileUntracked,
-- deleted = icons.git.FileDeleted,
-- ignored = icons.git.FileIgnored,
-- },
-- },
-- },
-- special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
-- symlink_destination = true,
-- },
-- hijack_directories = {
-- enable = false,
-- auto_open = true,
-- },
-- update_focused_file = {
-- enable = true,
-- debounce_delay = 15,
-- update_root = true,
-- ignore_list = {},
-- },
-- diagnostics = {
-- enable = true,
-- show_on_dirs = false,
-- show_on_open_dirs = true,
-- debounce_delay = 50,
-- severity = {
-- min = vim.diagnostic.severity.HINT,
-- max = vim.diagnostic.severity.ERROR,
-- },
-- icons = {
-- hint = icons.diagnostics.BoldHint,
-- info = icons.diagnostics.BoldInformation,
-- warning = icons.diagnostics.BoldWarning,
-- error = icons.diagnostics.BoldError,
-- },
-- },
-- filters = {
-- dotfiles = false,
-- git_clean = false,
-- no_buffer = false,
-- custom = { "node_modules", "\\.cache", "\\.git" },
-- exclude = {
-- ".gitignore",
-- ".prettierignore",
-- },
-- },
-- filesystem_watchers = {
-- enable = true,
-- debounce_delay = 50,
-- ignore_dirs = {},
-- },
-- git = {
-- enable = true,
-- ignore = false,
-- show_on_dirs = true,
-- show_on_open_dirs = true,
-- disable_for_dirs = {},
-- timeout = 400,
-- },
-- actions = {
-- use_system_clipboard = true,
-- change_dir = {
-- enable = true,
-- global = false,
-- restrict_above_cwd = false,
-- },
-- expand_all = {
-- max_folder_discovery = 300,
-- exclude = {},
-- },
-- file_popup = {
-- open_win_config = {
-- col = 1,
-- row = 1,
-- relative = "cursor",
-- border = "shadow",
-- style = "minimal",
-- },
-- },
-- open_file = {
-- quit_on_open = false,
-- resize_window = false,
-- window_picker = {
-- enable = true,
-- picker = "default",
-- chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
-- exclude = {
-- filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" },
-- buftype = { "nofile", "terminal", "help" },
-- },
-- },
-- },
-- remove_file = {
-- close_window = true,
-- },
-- },
-- trash = {
-- cmd = "trash",
-- require_confirm = true,
-- },
-- live_filter = {
-- prefix = "[FILTER]: ",
-- always_show_folders = true,
-- },
-- tab = {
-- sync = {
-- open = false,
-- close = false,
-- ignore = {},
-- },
-- },
-- notify = {
-- -- threshold = vim.log.levels.INFO,
-- threshold = vim.log.levels.ERROR,
-- },
-- log = {
-- enable = false,
-- truncate = false,
-- types = {
-- all = false,
-- config = false,
-- copy_paste = false,
-- dev = false,
-- diagnostics = false,
-- git = false,
-- profile = false,
-- watcher = false,
-- },
-- },
-- system_open = {
-- cmd = nil,
-- args = {},
-- },
-- },
-- keys = {
-- { "<leader>e", "<cmd>NvimTreeToggle<cr>", desc = "󰙅 Explorer" },
-- },
-- config = function(_, opts)
-- require("nvim-tree").setup(opts)
-- local api = require("nvim-tree.api")
-- api.events.subscribe(api.events.Event.FileCreated, function(file)
-- vim.cmd("edit " .. file.fname)
-- end)
-- end,
-- }
return {}

View file

@ -11,8 +11,12 @@ if substring(tostring(clr), "Eva") and true or false then
pattern = "*", pattern = "*",
callback = function() callback = function()
local hi = vim.api.nvim_set_hl local hi = vim.api.nvim_set_hl
hi(0, "LspInfoBorder", { fg = "#2F3F5C" }) -- hi(0, "LspInfoBorder", { fg = "#2F3F5C" })
hi(0, "FloatBorder", { fg = "#2F3F5C" }) -- hi(0, "LspInfoBorder", { fg = "#598DEF" })
hi(0, "LspInfoBorder", { fg = "#8A97C3" })
-- hi(0, "FloatBorder", { fg = "#2F3F5C" })
-- hi(0, "FloatBorder", { fg = "#598DEF" })
hi(0, "FloatBorder", { fg = "#8A97C3" })
hi(0, "StatusLine", { bg = color.background }) hi(0, "StatusLine", { bg = color.background })
hi(0, "StatusLineNC", { bg = color.background }) hi(0, "StatusLineNC", { bg = color.background })
hi(0, "WinBar", { bg = color.background }) hi(0, "WinBar", { bg = color.background })
@ -30,6 +34,11 @@ if substring(tostring(clr), "Eva") and true or false then
hi(0, "NvimTreeGitMergeIcon", { bg = color.dark, fg = color.git.diffModified }) hi(0, "NvimTreeGitMergeIcon", { bg = color.dark, fg = color.git.diffModified })
hi(0, "NvimTreeGitStagedIcon", { bg = color.dark, fg = color.git.stagedModified }) hi(0, "NvimTreeGitStagedIcon", { bg = color.dark, fg = color.git.stagedModified })
hi(0, "MiniIndentscopeSymbol", { bg = color.dark, fg = color.parameter }) hi(0, "MiniIndentscopeSymbol", { bg = color.dark, fg = color.parameter })
-- cursor
-- hi(0, "Cursor", { bg = "#838FA7", fg = "#838FA7" })
hi(0, "CursorColumn", { bg = color.dark, fg = "#838FA7" })
hi(0, "TermCursor", { bg = "#FF9070", fg = color.dark })
hi(0, "TermCursorNC", { bg = "#FF9070", fg = color.dark })
end, end,
}) })
end, end,

View file

@ -86,6 +86,16 @@ vim.filetype.add({
}, },
}) })
-- config cursor
vim.opt.guicursor = {
"n-v:block", -- Normal, Visual, Command mode: block cursor
"i-ci-ve-c:ver25", -- Insert, Command-line Insert, Visual mode: vertical bar cursor
"r-cr:hor20", -- Replace, Command-line Replace mode: horizontal bar cursor
"o:hor50", -- Operator-pending mode: horizontal bar cursor
"a:blinkwait700-blinkoff400-blinkon250", -- Blinking settings
"sm:block-blinkwait175-blinkoff150-blinkon175", -- Select mode: block cursor with blinking
}
-- Autoformat -- Autoformat
-- augroup _lsp -- augroup _lsp
-- autocmd! -- autocmd!

View file

@ -0,0 +1,56 @@
local M = {}
M.run = function()
local Popup = require("nui.popup")
local event = require("nui.utils.autocmd").event
-- Buat popup untuk menampilkan keymapping
local popup = Popup({
enter = true,
focusable = true,
border = {
style = "rounded",
text = {
top = " Key Mappings ",
},
},
position = "50%",
size = {
width = "80%",
height = "80%",
},
})
-- Daftar keymapping yang akan ditampilkan dalam dua kolom dengan section header
-- stylua: ignore
local key_mappings = {
{ "<leader>a ", "Toggle Dashboard ", "<leader>e ", "Toggle Explorer "},
{ "<leader>c ", "Chat AI ", "<leader>bb", ":Telescope buffers<CR> "},
{ " ", " ", "<leader>bd", ":bdelete<CR> "},
{ " ", " ", " ", " "},
{ "Terminal ", " ", " ", " "},
{ "<leader>tt ", ":ToggleTerm<CR> ", "<leader>tn", ":ToggleTerm direction=horizontal<CR>"},
}
-- Fungsi untuk mengubah daftar keymapping menjadi format string
local function format_key_mappings(mappings)
local formatted = {}
for _, mapping in ipairs(mappings) do
table.insert(formatted, string.format("%-20s %-20s %-20s %s", mapping[1], mapping[2], mapping[3], mapping[4]))
end
return formatted
end
-- Set konten popup dengan daftar keymapping yang diformat
vim.api.nvim_buf_set_lines(popup.bufnr, 0, -1, false, format_key_mappings(key_mappings))
-- Mount popup
popup:mount()
-- Unmount popup ketika cursor meninggalkan buffer
popup:on(event.BufLeave, function()
popup:unmount()
end)
end
return M

View file

@ -46,7 +46,7 @@ return {
color = function() color = function()
local buf = vim.api.nvim_get_current_buf() local buf = vim.api.nvim_get_current_buf()
local ts = vim.treesitter.highlighter.active[buf] local ts = vim.treesitter.highlighter.active[buf]
return { fg = ts and not vim.tbl_isempty(ts) and "#50fa7b" or "#FF5555" } return { fg = ts and not vim.tbl_isempty(ts) and "#98C379" or "#E06C75" }
end, end,
cond = hide_in_width, cond = hide_in_width,
}, },
@ -71,7 +71,7 @@ return {
color = function() color = function()
if pcode.codeium then if pcode.codeium then
local codeium = all_trim(vim.api.nvim_call_function("codeium#GetStatusString", {})) local codeium = all_trim(vim.api.nvim_call_function("codeium#GetStatusString", {}))
return { fg = codeium == "OFF" and "#3E4452" or "#50fa7b" } return { fg = codeium == "OFF" and "#3E4452" or "#98C379" }
else else
return {} return {}
end end
@ -222,11 +222,11 @@ return {
separator = { left = "", right = "" }, separator = { left = "", right = "" },
fmt = function(str) fmt = function(str)
if pcode.show_mode == 1 then if pcode.show_mode == 1 then
return icons.ui.Neovim .. " " .. (mode_map[str] or str) return icons.ui.Neovim .. " " .. str:sub(1, 1)
elseif pcode.show_mode == 2 then elseif pcode.show_mode == 2 then
return icons.ui.Neovim return icons.ui.Neovim
elseif pcode.show_mode == 3 then elseif pcode.show_mode == 3 then
return (mode_map[str] or str) return str:sub(1, 1)
elseif pcode.show_mode == 4 then elseif pcode.show_mode == 4 then
return nil return nil
else else