From 5b2d06cf97bea37e77db529ad499c75c7b648333 Mon Sep 17 00:00:00 2001 From: pojok code Date: Tue, 10 Jun 2025 07:44:40 +0700 Subject: [PATCH 01/28] enc: add transparant config for tab --- lazy-lock.json | 7 ++++--- lua/pcode/plugins/extras/transparent.lua | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index e85acfe..106593e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -17,9 +17,9 @@ "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "code_runner.nvim": { "branch": "main", "commit": "386bcaa8aa7ae8703281afce4465ecfdb7c44e65" }, + "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, - "conform.nvim": { "branch": "master", "commit": "0e93e0d12d2f7ebdea9e3e444dfaff0050cefbe6" }, + "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" }, @@ -38,7 +38,7 @@ "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "nui.nvim": { "branch": "main", "commit": "7cd18e73cfbd70e1546931b7268b3eebaeff9391" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, @@ -66,6 +66,7 @@ "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "transparent.nvim": { "branch": "main", "commit": "d41ae9b56ac2706cb3db4b16afe5cd6903013937" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, diff --git a/lua/pcode/plugins/extras/transparent.lua b/lua/pcode/plugins/extras/transparent.lua index b0970e0..ff59aef 100644 --- a/lua/pcode/plugins/extras/transparent.lua +++ b/lua/pcode/plugins/extras/transparent.lua @@ -21,6 +21,7 @@ return { "WinBar", "WinBarNC", "NotifyBackground", + "TabLine", }, exclude_groups = { -- disable active selection backgroun From 65b1300677b18417bc37a4ffce936d6fa09cccac Mon Sep 17 00:00:00 2001 From: pojok code Date: Tue, 10 Jun 2025 21:09:13 +0700 Subject: [PATCH 02/28] enc: update transparant config for tabbufferline bg color --- lazy-lock.json | 4 +- lua/pcode/plugins/extras/fidget.lua | 14 +++ lua/pcode/plugins/extras/transparent.lua | 1 + lua/pcode/plugins/theme/dracula.lua | 120 +++++++++++------------ lua/pcode/plugins/theme/jetbrains.lua | 78 +++++++-------- lua/pcode/user/default.lua | 7 +- 6 files changed, 120 insertions(+), 104 deletions(-) create mode 100644 lua/pcode/plugins/extras/fidget.lua diff --git a/lazy-lock.json b/lazy-lock.json index 106593e..0eae901 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,6 +1,5 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "5271933f7cea9f6b1c7de953379469010ed4553a" }, "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, @@ -20,6 +19,7 @@ "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" }, @@ -52,7 +52,7 @@ "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, - "nvim-scrollview": { "branch": "main", "commit": "23db9bbd210fed942085070071fdac921837a55f" }, + "nvim-scrollview": { "branch": "main", "commit": "b65192ef2e39c456e8dc5f8f5cdd9b8d13f121e4" }, "nvim-tree.lua": { "branch": "master", "commit": "1c733e8c1957dc67f47580fe9c458a13b5612d5b" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, diff --git a/lua/pcode/plugins/extras/fidget.lua b/lua/pcode/plugins/extras/fidget.lua new file mode 100644 index 0000000..6d9c12c --- /dev/null +++ b/lua/pcode/plugins/extras/fidget.lua @@ -0,0 +1,14 @@ +return { + "j-hui/fidget.nvim", + lazy = true, + tag = "legacy", + event = "BufRead", + config = function() + require("fidget").setup({ + window = { + blend = 0, + relative = "editor", + }, + }) + end, +} diff --git a/lua/pcode/plugins/extras/transparent.lua b/lua/pcode/plugins/extras/transparent.lua index ff59aef..2241527 100644 --- a/lua/pcode/plugins/extras/transparent.lua +++ b/lua/pcode/plugins/extras/transparent.lua @@ -22,6 +22,7 @@ return { "WinBarNC", "NotifyBackground", "TabLine", + "TabLineFill", }, exclude_groups = { -- disable active selection backgroun diff --git a/lua/pcode/plugins/theme/dracula.lua b/lua/pcode/plugins/theme/dracula.lua index a789f3d..21d5a22 100644 --- a/lua/pcode/plugins/theme/dracula.lua +++ b/lua/pcode/plugins/theme/dracula.lua @@ -1,62 +1,62 @@ return { - "Mofiqul/dracula.nvim", - priority = 1000, - opts=function() - local colors = require("dracula").colors() - return{ - colors = { - -- purple = "#FCC76A", - menu = colors.bg, - selection = "#363848", - }, - italic_comment = true, - lualine_bg_color = colors.bg, - overrides = { - Keywords = { fg = colors.cyan, italic = true }, - ["@keyword"] = { fg = colors.pink, italic = true }, - ["@keyword.function"] = { fg = colors.cyan, italic = true }, - ["@function"] = { fg = colors.green, italic = true }, - ["@tag.attribute"] = { fg = colors.green, italic = true }, - ["@tag.builtin.javascript"] = { fg = colors.pink }, - ["@tag.delimiter.javascript"] = { fg = colors.fg }, - ["@type.javascript"] = { fg = colors.fg }, - ["@property.css"] = { fg = colors.cyan }, - ["@type.css"] = { fg = colors.green }, - ["@tag.css"] = { fg = colors.pink }, - ["@keyword.css"] = { fg = colors.fg }, - ["@string.css"] = { fg = colors.pink }, - NvimTreeFolderIcon = { fg = "#6776a7" }, - CmpItemAbbr = { fg = "#ABB2BF" }, - CmpItemKind = { fg = "#ABB2BF" }, - CmpItemAbbrDeprecated = { fg = "#ABB2BF" }, - CmpItemAbbrMatch = { fg = "#8BE9FD" }, - htmlLink = { fg = "#BD93F9", underline = false }, - Underlined = { fg = "#8BE9FD" }, - NvimTreeSpecialFile = { fg = "#FF79C6" }, - SpellBad = { fg = "#FF6E6E" }, - illuminatedWord = { bg = "#3b4261" }, - illuminatedCurWord = { bg = "#3b4261" }, - IlluminatedWordText = { bg = "#3b4261" }, - IlluminatedWordRead = { bg = "#3b4261" }, - IlluminatedWordWrite = { bg = "#3b4261" }, - DiffChange = { fg = colors.fg }, - StatusLine = { fg = colors.fg, bg = colors.bg }, - StatusLineTerm = { fg = colors.fg, bg = colors.bg }, - BufferLineFill = { bg = colors.bg }, - Pmenu = { fg = colors.fg, bg = colors.bg }, - LspInfoBorder = { fg = colors.fg }, - LspReferenceText = { bg = "#3b4261" }, - LspReferenceRead = { bg = "#3b4261" }, - LspReferenceWrite = { bg = "#3b4261" }, - WinBar = { bg = colors.bg }, - WinBarNC = { fg = colors.fg, bg = colors.bg }, - }, - transparent_bg = false, - } - end, - config = function(_,opts) - require("dracula").setup(opts) - local colorscheme = pcode.themes.dracula or "dracula" - vim.cmd("colorscheme " .. colorscheme) - end, + "Mofiqul/dracula.nvim", + priority = 1000, + opts = function() + local colors = require("dracula").colors() + return { + colors = { + -- purple = "#FCC76A", + menu = colors.bg, + selection = "#363848", + }, + italic_comment = true, + lualine_bg_color = colors.bg, + overrides = { + Keywords = { fg = colors.cyan, italic = true }, + ["@keyword"] = { fg = colors.pink, italic = true }, + ["@keyword.function"] = { fg = colors.cyan, italic = true }, + ["@function"] = { fg = colors.green, italic = true }, + ["@tag.attribute"] = { fg = colors.green, italic = true }, + ["@tag.builtin.javascript"] = { fg = colors.pink }, + ["@tag.delimiter.javascript"] = { fg = colors.fg }, + ["@type.javascript"] = { fg = colors.fg }, + ["@property.css"] = { fg = colors.cyan }, + ["@type.css"] = { fg = colors.green }, + ["@tag.css"] = { fg = colors.pink }, + ["@keyword.css"] = { fg = colors.fg }, + ["@string.css"] = { fg = colors.pink }, + NvimTreeFolderIcon = { fg = "#6776a7" }, + CmpItemAbbr = { fg = "#ABB2BF" }, + CmpItemKind = { fg = "#ABB2BF" }, + CmpItemAbbrDeprecated = { fg = "#ABB2BF" }, + CmpItemAbbrMatch = { fg = "#8BE9FD" }, + htmlLink = { fg = "#BD93F9", underline = false }, + Underlined = { fg = "#8BE9FD" }, + NvimTreeSpecialFile = { fg = "#FF79C6" }, + SpellBad = { fg = "#FF6E6E" }, + illuminatedWord = { bg = "#3b4261" }, + illuminatedCurWord = { bg = "#3b4261" }, + IlluminatedWordText = { bg = "#3b4261" }, + IlluminatedWordRead = { bg = "#3b4261" }, + IlluminatedWordWrite = { bg = "#3b4261" }, + DiffChange = { fg = colors.fg }, + StatusLine = { fg = colors.fg, bg = colors.bg }, + StatusLineTerm = { fg = colors.fg, bg = colors.bg }, + BufferLineFill = { bg = colors.bg }, + Pmenu = { fg = colors.fg, bg = colors.bg }, + LspInfoBorder = { fg = colors.fg }, + LspReferenceText = { bg = "#3b4261" }, + LspReferenceRead = { bg = "#3b4261" }, + LspReferenceWrite = { bg = "#3b4261" }, + WinBar = { bg = colors.bg }, + WinBarNC = { fg = colors.fg, bg = colors.bg }, + }, + transparent_bg = false, + } + end, + config = function(_, opts) + require("dracula").setup(opts) + local colorscheme = pcode.themes.dracula or "dracula" + vim.cmd("colorscheme " .. colorscheme) + end, } diff --git a/lua/pcode/plugins/theme/jetbrains.lua b/lua/pcode/plugins/theme/jetbrains.lua index 8b2e558..e877813 100644 --- a/lua/pcode/plugins/theme/jetbrains.lua +++ b/lua/pcode/plugins/theme/jetbrains.lua @@ -1,41 +1,41 @@ return { - "pojokcodeid/darcula-dark.nvim", - priority = 1000, - lazy = false, - config = function() - require("darcula").setup({ - colors = { - lavender = "#9876AA", - statusline = "NONE", - }, - }) - vim.api.nvim_create_autocmd("ColorScheme", { - pattern = "*", - callback = function() - local colors = require("darcula").colors() - local hi = vim.api.nvim_set_hl - hi(0, "@property.json", { fg = colors.lavender }) - hi(0, "@property.jsonc", { fg = colors.lavender }) - hi(0, "LineNr", { ctermfg = 11, fg = colors._39 }) - -- hi(0, "@variable.member.sql", { fg = colors.olive_green }) - -- telescope - hi(0, "TelescopePromptBorder", { fg = colors.medium_gray }) - hi(0, "TelescopeResultsBorder", { fg = colors.medium_gray }) - hi(0, "TelescopePreviewBorder", { fg = colors.medium_gray }) - hi(0, "TelescopeSelection", { bg = colors.dark_charcoal_gray }) - hi(0, "TelescopeMultiSelection", { bg = colors.dark_charcoal_gray }) - hi(0, "TelescopeNormal", { bg = colors.dark }) - hi(0, "TelescopeMatching", { fg = colors.olive_green }) - hi(0, "TelescopePromptPrefix", { fg = colors.red }) - hi(0, "TelescopeResultsDiffDelete", { fg = colors.red }) - hi(0, "TelescopeResultsDiffChange", { fg = colors.bright_cyan }) - hi(0, "TelescopeResultsDiffAdd", { fg = colors.olive_green }) - hi(0, "TelescopePromptNormal", { bg = colors.dark, fg = colors.grey }) - hi(0, "TelescopePromptPrefix", { bg = colors.dark, fg = colors.red }) - hi(0, "TelescopeResultsTitle", { bg = colors.olive_green, fg = colors.very_dark_gray }) - end, - }) - local colorscheme = pcode.themes.jetbrains or "darcula-dark" - vim.cmd("colorscheme " .. colorscheme) - end, + "pojokcodeid/darcula-dark.nvim", + priority = 1000, + lazy = false, + config = function() + require("darcula").setup({ + colors = { + lavender = "#9876AA", + statusline = "NONE", + }, + }) + vim.api.nvim_create_autocmd("ColorScheme", { + pattern = "*", + callback = function() + local colors = require("darcula").colors() + local hi = vim.api.nvim_set_hl + hi(0, "@property.json", { fg = colors.lavender }) + hi(0, "@property.jsonc", { fg = colors.lavender }) + hi(0, "LineNr", { ctermfg = 11, fg = colors._39 }) + -- hi(0, "@variable.member.sql", { fg = colors.olive_green }) + -- telescope + hi(0, "TelescopePromptBorder", { fg = colors.medium_gray }) + hi(0, "TelescopeResultsBorder", { fg = colors.medium_gray }) + hi(0, "TelescopePreviewBorder", { fg = colors.medium_gray }) + hi(0, "TelescopeSelection", { bg = colors.dark_charcoal_gray }) + hi(0, "TelescopeMultiSelection", { bg = colors.dark_charcoal_gray }) + hi(0, "TelescopeNormal", { bg = colors.dark }) + hi(0, "TelescopeMatching", { fg = colors.olive_green }) + hi(0, "TelescopePromptPrefix", { fg = colors.red }) + hi(0, "TelescopeResultsDiffDelete", { fg = colors.red }) + hi(0, "TelescopeResultsDiffChange", { fg = colors.bright_cyan }) + hi(0, "TelescopeResultsDiffAdd", { fg = colors.olive_green }) + hi(0, "TelescopePromptNormal", { bg = colors.dark, fg = colors.grey }) + hi(0, "TelescopePromptPrefix", { bg = colors.dark, fg = colors.red }) + hi(0, "TelescopeResultsTitle", { bg = colors.olive_green, fg = colors.very_dark_gray }) + end, + }) + local colorscheme = pcode.themes.jetbrains or "darcula-dark" + vim.cmd("colorscheme " .. colorscheme) + end, } diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index de13c93..49ca510 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -47,18 +47,19 @@ pcode.extras = { zenmode = true, lspsignatur = false, telescopetreesiterinfo = true, + fidget = false, } -- activate config themes pcode.themes = { -- note: open remark only one -- **:: Eva Theme ::** -- - evatheme = "Eva-Dark", + -- evatheme = "Eva-Dark", -- evatheme = "Eva-Dark-Italic", -- evatheme = "Eva-Dark-Bold", -- evatheme = "Eva-Light", -- -- **:: Dracula Theme ::** -- - -- dracula = "dracula", + dracula = "dracula", -- dracula = "dracula-soft", -- -- **:: Onedarkpro Theme ::** -- @@ -92,6 +93,6 @@ pcode.themes = { -- github = "github_dark_dimmed", } -- activate config transparent_bg -pcode.transparent = false +pcode.transparent = true pcode.localcode = true pcode.snippets_path = vim.fn.stdpath("config") .. "/mysnippets" From 56982c3434a96fe79f4413ed55ce250467888811 Mon Sep 17 00:00:00 2001 From: pojok code Date: Tue, 10 Jun 2025 21:41:41 +0700 Subject: [PATCH 03/28] enc: add uninstall prosedure --- README.md | 26 ++++++++++++++++---------- lazy-lock.json | 6 +++--- lua/pcode/user/default.lua | 4 ++-- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 56c3c43..5b9bbb4 100644 --- a/README.md +++ b/README.md @@ -67,14 +67,14 @@ ## Basic Requirement 2. Install Neovim 0.95+ https://github.com/neovim/neovim/releases/tag/stable -3. C++ https://www.msys2.org/ -4. GIT https://git-scm.com/download/win -5. NodeJs https://nodejs.org/en/ -6. Ripgrep https://github.com/BurntSushi/ripgrep -7. Lazygit https://github.com/jesseduffield/lazygit -8. Nerd Font https://www.nerdfonts.com/ or https://github.com/ryanoasis/nerd-fonts -9. Windows Terminal (Windows) https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-id&gl=id -10. Powershell (windows) https://apps.microsoft.com/store/detail/powershell/9MZ1SNWT0N5D?hl=en-id&gl=id +1. C++ https://www.msys2.org/ +1. GIT https://git-scm.com/download/win +1. NodeJs https://nodejs.org/en/ +1. Ripgrep https://github.com/BurntSushi/ripgrep +1. Lazygit https://github.com/jesseduffield/lazygit +1. Nerd Font https://www.nerdfonts.com/ or https://github.com/ryanoasis/nerd-fonts +1. Windows Terminal (Windows) https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-id&gl=id +1. Powershell (windows) https://apps.microsoft.com/store/detail/powershell/9MZ1SNWT0N5D?hl=en-id&gl=id # Windows @@ -92,15 +92,21 @@ git clone https://github.com/pojokcodeid/neovim-starter.git ~/.config/nvim # Uninstall ```bash -# Linux / Macos (unix) +# Linux / MacOS (unix) rm -rf ~/.config/nvim +rm -rf ~/.local/state/nvim rm -rf ~/.local/share/nvim +# Flatpak (linux) +rm -rf ~/.var/app/io.neovim.nvim/config/nvim +rm -rf ~/.var/app/io.neovim.nvim/data/nvim +rm -rf ~/.var/app/io.neovim.nvim/.local/state/nvim + # Windows CMD rd -r ~\AppData\Local\nvim rd -r ~\AppData\Local\nvim-data -# Window PowerShell +# Windows PowerShell rm -Force ~\AppData\Local\nvim rm -Force ~\AppData\Local\nvim-data ``` diff --git a/lazy-lock.json b/lazy-lock.json index 0eae901..eccf21c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,7 +1,8 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "5271933f7cea9f6b1c7de953379469010ed4553a" }, + "LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" }, "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, "auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, @@ -19,7 +20,6 @@ "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, - "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" }, @@ -47,7 +47,7 @@ "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-lint": { "branch": "master", "commit": "cc26ae6a620298bb3f33b0e0681f99a10ae57781" }, - "nvim-lspconfig": { "branch": "master", "commit": "a182334ba933e58240c2c45e6ae2d9c7ae313e00" }, + "nvim-lspconfig": { "branch": "master", "commit": "77d3fdfb3554632c7a3b101ded643d422de7626f" }, "nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 49ca510..6213a17 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -53,13 +53,13 @@ pcode.extras = { pcode.themes = { -- note: open remark only one -- **:: Eva Theme ::** -- - -- evatheme = "Eva-Dark", + evatheme = "Eva-Dark", -- evatheme = "Eva-Dark-Italic", -- evatheme = "Eva-Dark-Bold", -- evatheme = "Eva-Light", -- -- **:: Dracula Theme ::** -- - dracula = "dracula", + -- dracula = "dracula", -- dracula = "dracula-soft", -- -- **:: Onedarkpro Theme ::** -- From 04f3bfc8a31e78be91353953386f523740556cac Mon Sep 17 00:00:00 2001 From: pojok code Date: Tue, 10 Jun 2025 22:57:15 +0700 Subject: [PATCH 04/28] enc: update config transparant --- lazy-lock.json | 2 +- lua/pcode/plugins/cmp.lua | 2 ++ lua/pcode/plugins/extras/transparent.lua | 4 ++++ lua/pcode/user/options.lua | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index eccf21c..20e1ed8 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,7 +2,7 @@ "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "fb525166ccc30296fb3457441eb979113de46b00" }, + "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, "auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, diff --git a/lua/pcode/plugins/cmp.lua b/lua/pcode/plugins/cmp.lua index bb23ff7..2046a29 100644 --- a/lua/pcode/plugins/cmp.lua +++ b/lua/pcode/plugins/cmp.lua @@ -2,6 +2,8 @@ return { { "L3MON4D3/LuaSnip", event = "InsertEnter", + version = "v2.*", + build = "make install_jsregexp", opts = { history = true, delete_check_events = "TextChanged", diff --git a/lua/pcode/plugins/extras/transparent.lua b/lua/pcode/plugins/extras/transparent.lua index 2241527..137aa4c 100644 --- a/lua/pcode/plugins/extras/transparent.lua +++ b/lua/pcode/plugins/extras/transparent.lua @@ -55,6 +55,10 @@ return { -- create auto command to set transparent vim.cmd("TransparentDisable") vim.cmd("TransparentEnable") + vim.api.nvim_set_hl(0, "MasonHeader", { bold = true, bg = "NONE", fg = "#838FA7" }) + vim.api.nvim_set_hl(0, "MasonMutedBlock", { bg = "NONE", fg = "#838FA7" }) + vim.api.nvim_set_hl(0, "MasonHighlightBlockBold", { bold = true, bg = "NONE", fg = "#ABB2BF" }) + vim.api.nvim_set_hl(0, "LazyH1", { bold = true, bg = "NONE", fg = "#ABB2BF" }) end, }, { diff --git a/lua/pcode/user/options.lua b/lua/pcode/user/options.lua index 7f8888c..19d30d8 100644 --- a/lua/pcode/user/options.lua +++ b/lua/pcode/user/options.lua @@ -61,7 +61,7 @@ vim.loader.enable() -- Disable statusline in dashboard vim.api.nvim_create_autocmd("FileType", { - pattern = { "dbout", "dbui", "http", "httpResult" }, + pattern = { "dbout", "dbui", "http", "httpResult", "checkhealth", "qf", "help", "lazy" }, callback = function() local opt = vim.opt opt.number = false -- Print line number From f3761c699af5fc1d1dedabdfcdcf540f19bde40e Mon Sep 17 00:00:00 2001 From: pojok code Date: Wed, 11 Jun 2025 21:13:56 +0700 Subject: [PATCH 05/28] enc: update config mason backdrop --- lazy-lock.json | 9 +- lua/pcode/plugins/dressing.lua | 34 --- lua/pcode/plugins/extras/dressing.lua | 34 +++ lua/pcode/plugins/extras/nvimmenu.lua | 13 +- lua/pcode/plugins/extras/tinydignostic.lua | 11 + lua/pcode/plugins/nvimtree.lua | 235 +++++++++++--------- lua/pcode/plugins/theme/catppuccin.lua | 1 + lua/pcode/plugins/theme/dracula.lua | 1 + lua/pcode/plugins/theme/evatheme.lua | 1 + lua/pcode/plugins/theme/github.lua | 1 + lua/pcode/plugins/theme/gruvbox.lua | 1 + lua/pcode/plugins/theme/jetbrains.lua | 1 + lua/pcode/plugins/theme/onedarkpro.lua | 245 +++++++++++---------- lua/pcode/plugins/theme/sublimetext.lua | 1 + lua/pcode/plugins/theme/tokyonight.lua | 1 + lua/pcode/user/default.lua | 4 +- 16 files changed, 316 insertions(+), 277 deletions(-) delete mode 100644 lua/pcode/plugins/dressing.lua create mode 100644 lua/pcode/plugins/extras/dressing.lua create mode 100644 lua/pcode/plugins/extras/tinydignostic.lua diff --git a/lazy-lock.json b/lazy-lock.json index 20e1ed8..9aae565 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -20,9 +20,8 @@ "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, - "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" }, + "gitsigns.nvim": { "branch": "main", "commit": "731b581428ec6c1ccb451b95190ebbc6d7006db7" }, "inc-rename.nvim": { "branch": "main", "commit": "a3e31af13844534c66041ce92f29af7745883875" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, @@ -34,7 +33,7 @@ "mini.indentscope": { "branch": "main", "commit": "8af2569a7d7fd37300dfa760e44e71efbbf322fd" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" }, - "neotest-golang": { "branch": "main", "commit": "c452301848418baf244e2da34491157bca7614c1" }, + "neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, @@ -61,16 +60,16 @@ "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "refactoring.nvim": { "branch": "master", "commit": "9cd0186ffe76fe6abc64c0aafb775c8f776ab5ee" }, + "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, "smart-splits.nvim": { "branch": "master", "commit": "9af865e451e55a9835fae6862dd7c55396870ecb" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, - "transparent.nvim": { "branch": "main", "commit": "d41ae9b56ac2706cb3db4b16afe5cd6903013937" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, - "volt": { "branch": "main", "commit": "c45d5f48da8e802e608b5c6da471ca4d84276dfb" }, + "volt": { "branch": "main", "commit": "2aa99a4e388c840597441a901209cbdafe8472ed" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }, "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } diff --git a/lua/pcode/plugins/dressing.lua b/lua/pcode/plugins/dressing.lua deleted file mode 100644 index ad00f44..0000000 --- a/lua/pcode/plugins/dressing.lua +++ /dev/null @@ -1,34 +0,0 @@ -return { - "stevearc/dressing.nvim", - lazy = true, - init = function() - ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.select = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.select(...) - end - ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.input = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.input(...) - end - end, - opts = { - input = { - title_pos = "center", - relative = "editor", - default_prompt = "➤ ", - win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" }, - prefer_width = 30, - max_width = { 140, 0.9 }, - min_width = { 50, 0.2 }, - }, - select = { - backend = { "telescope", "builtin" }, - builtin = { win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" } }, - }, - }, - config = function(_, opts) - require("dressing").setup(opts) - end, -} diff --git a/lua/pcode/plugins/extras/dressing.lua b/lua/pcode/plugins/extras/dressing.lua new file mode 100644 index 0000000..c881169 --- /dev/null +++ b/lua/pcode/plugins/extras/dressing.lua @@ -0,0 +1,34 @@ +return { + "stevearc/dressing.nvim", + lazy = true, + init = function() + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.select = function(...) + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.select(...) + end + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.input = function(...) + require("lazy").load({ plugins = { "dressing.nvim" } }) + return vim.ui.input(...) + end + end, + opts = { + input = { + title_pos = "center", + relative = "editor", + default_prompt = "➤ ", + win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" }, + prefer_width = 30, + max_width = { 140, 0.9 }, + min_width = { 50, 0.2 }, + }, + select = { + backend = { "telescope", "builtin" }, + builtin = { win_options = { winhighlight = "Normal:Normal,NormalNC:Normal" } }, + }, + }, + config = function(_, opts) + require("dressing").setup(opts) + end, +} diff --git a/lua/pcode/plugins/extras/nvimmenu.lua b/lua/pcode/plugins/extras/nvimmenu.lua index a9dbf00..e2d1506 100644 --- a/lua/pcode/plugins/extras/nvimmenu.lua +++ b/lua/pcode/plugins/extras/nvimmenu.lua @@ -1,12 +1,13 @@ return { { - "nvchad/menu", + "nvzone/menu", lazy = true, event = { "VeryLazy" }, dependencies = { - { "nvchad/volt", lazy = true }, + { "nvzone/volt", lazy = true }, + { "nvzone/showkeys", cmd = "ShowkeysToggle", lazy = true }, { - "nvchad/minty", + "nvzone/minty", cmd = { "Shades", "Huefy" }, lazy = true, }, @@ -22,10 +23,12 @@ return { end, {}) -- mouse users + nvimtree users! - vim.keymap.set("n", "", function() + vim.keymap.set({ "n", "v" }, "", function() + require("menu.utils").delete_old_menus() vim.cmd.exec('"normal! \\"') - local options = vim.bo.ft == "NvimTree" and "nvimtree" or "default" + local buf = vim.api.nvim_win_get_buf(vim.fn.getmousepos().winid) + local options = vim.bo[buf].ft == "NvimTree" and "nvimtree" or "default" require("menu").open(options, opts) end, {}) end, diff --git a/lua/pcode/plugins/extras/tinydignostic.lua b/lua/pcode/plugins/extras/tinydignostic.lua new file mode 100644 index 0000000..60d864d --- /dev/null +++ b/lua/pcode/plugins/extras/tinydignostic.lua @@ -0,0 +1,11 @@ +return { + "rachartier/tiny-inline-diagnostic.nvim", + event = "VeryLazy", -- Or `LspAttach` + priority = 1000, -- needs to be loaded in first + config = function() + require("tiny-inline-diagnostic").setup({ + preset = "powerline", + }) + vim.diagnostic.config({ virtual_text = false }) -- Only if needed in your configuration, if you already have native LSP diagnostics + end, +} diff --git a/lua/pcode/plugins/nvimtree.lua b/lua/pcode/plugins/nvimtree.lua index 47a4bc4..e845450 100644 --- a/lua/pcode/plugins/nvimtree.lua +++ b/lua/pcode/plugins/nvimtree.lua @@ -1,45 +1,60 @@ return { - "nvim-tree/nvim-tree.lua", - cmd = { "NvimTreeFindFileToggle", "NvimTree", "NvimTreeOpen", "NvimTreeToggle", "NvimTreeFocus", "NvimTreeClose" }, - keys = { - { "e", "NvimTreeToggle", desc = "󰙅 Explorer" }, - }, - opts = function(_, opts) - local icons = require("pcode.user.icons") - opts.disable_netrw = true - opts.hijack_cursor = true - opts.sync_root_with_cwd = true - opts.update_focused_file = { - enable = true, - update_root = false, - } - opts.view = { - adaptive_size = false, - centralize_selection = true, - width = 30, - side = "left", - preserve_window_proportions = false, - number = false, - relativenumber = false, - signcolumn = "yes", - float = { - enable = false, - quit_on_focus_loss = true, - open_win_config = { - relative = "editor", - border = "rounded", - width = 30, - height = 30, - row = 1, - col = 1, - }, - }, - } - opts.renderer = { - root_folder_label = false, - highlight_git = true, - indent_markers = { enable = true }, - --[[ indent_markers = { + "nvim-tree/nvim-tree.lua", + cmd = { "NvimTreeFindFileToggle", "NvimTree", "NvimTreeOpen", "NvimTreeToggle", "NvimTreeFocus", "NvimTreeClose" }, + keys = { + { "e", "NvimTreeToggle", desc = "󰙅 Explorer" }, + }, + opts = function(_, opts) + local icons = require("pcode.user.icons") + opts.auto_reload_on_write = false + opts.disable_netrw = false + opts.hijack_cursor = false + opts.hijack_netrw = true + opts.hijack_unnamed_buffer_when_opening = false + opts.sync_root_with_cwd = true + opts.sort = { + sorter = "name", + folders_first = true, + files_first = false, + } + opts.root_dirs = {} + opts.prefer_startup_root = false + opts.sync_root_with_cwd = true + opts.reload_on_bufenter = false + opts.respect_buf_cwd = false + opts.on_attach = "default" + opts.select_prompts = false + opts.update_focused_file = { + enable = true, + update_root = false, + } + opts.view = { + adaptive_size = false, + centralize_selection = true, + width = 30, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + float = { + enable = false, + quit_on_focus_loss = true, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, + }, + }, + } + opts.renderer = { + root_folder_label = false, + highlight_git = true, + indent_markers = { enable = true }, + --[[ indent_markers = { enable = true, inline_arrows = true, icons = { @@ -49,73 +64,73 @@ return { 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.ChevronShortRight, - 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, - } - opts.filters = { - dotfiles = false, - git_clean = false, - no_buffer = false, - custom = { "node_modules", "\\.cache", "\\.git" }, - exclude = { - ".gitignore", - ".prettierignore", - }, - } - opts.notify = { - threshold = vim.log.levels.INFO, - } - opts.git = { - enable = true, - ignore = false, - show_on_dirs = true, - show_on_open_dirs = true, - disable_for_dirs = {}, - timeout = 400, - } - return opts - 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, + 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.ChevronShortRight, + 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, + } + opts.filters = { + dotfiles = false, + git_clean = false, + no_buffer = false, + custom = { "node_modules", "\\.cache", "\\.git" }, + exclude = { + ".gitignore", + ".prettierignore", + }, + } + opts.notify = { + threshold = vim.log.levels.INFO, + } + opts.git = { + enable = true, + ignore = false, + show_on_dirs = true, + show_on_open_dirs = true, + disable_for_dirs = {}, + timeout = 400, + } + return opts + 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, } diff --git a/lua/pcode/plugins/theme/catppuccin.lua b/lua/pcode/plugins/theme/catppuccin.lua index e9afeee..b4e5c68 100644 --- a/lua/pcode/plugins/theme/catppuccin.lua +++ b/lua/pcode/plugins/theme/catppuccin.lua @@ -49,6 +49,7 @@ return { Normal = { fg = colors.text, bg = transparent and colors.none or colors.base }, NormalNC = { fg = colors.text, bg = transparent and colors.none or colors.base }, StatusLine = { fg = colors.text, bg = colors.none }, + MasonBackdrop = { link = "NormalFloat" }, } end, highlight_overrides = { diff --git a/lua/pcode/plugins/theme/dracula.lua b/lua/pcode/plugins/theme/dracula.lua index 21d5a22..095ac32 100644 --- a/lua/pcode/plugins/theme/dracula.lua +++ b/lua/pcode/plugins/theme/dracula.lua @@ -50,6 +50,7 @@ return { LspReferenceWrite = { bg = "#3b4261" }, WinBar = { bg = colors.bg }, WinBarNC = { fg = colors.fg, bg = colors.bg }, + MasonBackdrop = { link = "NormalFloat" }, }, transparent_bg = false, } diff --git a/lua/pcode/plugins/theme/evatheme.lua b/lua/pcode/plugins/theme/evatheme.lua index ce04a2d..4c441b6 100644 --- a/lua/pcode/plugins/theme/evatheme.lua +++ b/lua/pcode/plugins/theme/evatheme.lua @@ -23,6 +23,7 @@ return { hi(0, "NormalFloat", { bg = color.background }) hi(0, "TabLine", { bg = color.background }) hi(0, "NormalNC", { bg = color.background }) + hi(0, "MasonBackdrop", { link = "NormalFloat" }) hi(0, "@tag.delimiter.javascript", { fg = color.punctuation }) hi(0, "@tag.delimiter.tsx", { fg = color.punctuation }) -- git diff --git a/lua/pcode/plugins/theme/github.lua b/lua/pcode/plugins/theme/github.lua index 99f226c..dd346b2 100644 --- a/lua/pcode/plugins/theme/github.lua +++ b/lua/pcode/plugins/theme/github.lua @@ -53,6 +53,7 @@ return { specs = {}, groups = { all = { + MasonBackdrop = { link = "NormalFloat" }, illuminatedWord = { bg = "#3b4261" }, illuminatedCurWord = { bg = "#3b4261" }, IlluminatedWordText = { bg = "#3b4261" }, diff --git a/lua/pcode/plugins/theme/gruvbox.lua b/lua/pcode/plugins/theme/gruvbox.lua index 909d896..f1856cc 100644 --- a/lua/pcode/plugins/theme/gruvbox.lua +++ b/lua/pcode/plugins/theme/gruvbox.lua @@ -18,6 +18,7 @@ return { ["FoldColumn"] = { bg = "NONE" }, ["Folded"] = { bg = "NONE" }, ["SignColumn"] = { bg = "NONE" }, + ["MasonBackdrop"] = { link = "NormalFloat" }, }, } end, diff --git a/lua/pcode/plugins/theme/jetbrains.lua b/lua/pcode/plugins/theme/jetbrains.lua index e877813..b35ec37 100644 --- a/lua/pcode/plugins/theme/jetbrains.lua +++ b/lua/pcode/plugins/theme/jetbrains.lua @@ -33,6 +33,7 @@ return { hi(0, "TelescopePromptNormal", { bg = colors.dark, fg = colors.grey }) hi(0, "TelescopePromptPrefix", { bg = colors.dark, fg = colors.red }) hi(0, "TelescopeResultsTitle", { bg = colors.olive_green, fg = colors.very_dark_gray }) + hi(0, "MasonBackdrop", { link = "NormalFloat" }) end, }) local colorscheme = pcode.themes.jetbrains or "darcula-dark" diff --git a/lua/pcode/plugins/theme/onedarkpro.lua b/lua/pcode/plugins/theme/onedarkpro.lua index 1298d91..1687b3e 100644 --- a/lua/pcode/plugins/theme/onedarkpro.lua +++ b/lua/pcode/plugins/theme/onedarkpro.lua @@ -1,124 +1,125 @@ return { - "olimorris/onedarkpro.nvim", - priority = 1000, - config = function() - local is_transparent = false - require("onedarkpro").setup({ - styles = { - types = "NONE", - methods = "NONE", - numbers = "NONE", - strings = "NONE", - comments = "italic", - keywords = "bold,italic", - constants = "NONE", - functions = "italic", - operators = "NONE", - variables = "NONE", - parameters = "NONE", - conditionals = "italic", - virtual_text = "NONE", - tags = "italic", - }, - colors = { - bg_statusline = "#282c34", - onedark = { - green = "#99c379", - gray = "#8094b4", - red = "#e06c75", - purple = "#c678dd", - yellow = "#e5c07a", - blue = "#61afef", - cyan = "#56b6c2", - indentline = "#3b4261", - float_bg = "#282c34", - }, - onedark_dark = { - bg_statusline = "#000", - }, - }, - options = { - cursorline = true, - transparency = is_transparent, - terminal_colors = true, - }, - highlights = { - -- overide cursor line fill colors - LineNr = { fg = "#49505E" }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. - CursorLineNr = { fg = "${blue}" }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. - CursorLine = { bg = "#333842" }, - Cursor = { fg = "${bg}", bg = "${fg}" }, -- character under the cursor - lCursor = { fg = "${bg}", bg = "${fg}" }, -- the character under the cursor when |language-mapping| is used (see 'guicursor') - CursorIM = { fg = "${bg}", bg = "${fg}" }, -- like Cursor, but used when in IME mode |CursorIM| - CursorColumn = { bg = "#333842" }, -- Screen-column at the cursor, when 'cursorcolumn' is set. - -- overide nvimtree folder icon fill color - NvimTreeFolderIcon = { fg = "${gray}" }, - -- overide nvimtree text fill color folder opened - NvimTreeOpenedFolderName = { fg = "${blue}" }, - -- overide nvimtree text fill color root folder - NvimTreeRootFolder = { fg = "${yellow}" }, - NvimTreeSpecialFile = { fg = "${orange}" }, - NvimTreeWinSeparator = { fg = "#202329" }, - NvimTreeIndentMarker = { fg = "#3E4450" }, - -- overide nvimtree cursorline - NvimTreeCursorLine = { bg = "#333842" }, - -- overide indenline fill color - IblIndent = { fg = "#3E4450" }, - -- overide cmp cursorline fill color with #333842 - PmenuSel = { bg = "#333842" }, - illuminatedWord = { bg = "#3b4261" }, - illuminatedCurWord = { bg = "#3b4261" }, - IlluminatedWordText = { bg = "#3b4261" }, - IlluminatedWordRead = { bg = "#3b4261" }, - IlluminatedWordWrite = { bg = "#3b4261" }, - StatusLine = { fg = "#f8f8f2", bg = is_transparent and "NONE" or "${bg}" }, - StatusLineTerm = { fg = "#f8f8f2", bg = "${bg}" }, - BufferLineFill = { bg = is_transparent and "NONE" or "${bg}" }, - ["@string.special.url.html"] = { fg = "${green}" }, - ["@lsp.type.parameter"] = { fg = "${gray}" }, - -- ["@text.uri.html"] = { fg = "${green}" }, - -- ["@tag.javascript"] = { fg = "${red}" }, - -- ["@tag.attribute"] = { fg = "${orange}", style = "italic" }, - -- ["@constructor.javascript"] = { fg = "${red}" }, - -- ["@variable"] = { fg = "${fg}", style = "NONE" }, -- various variable names - -- ["@variable.builtin"] = { fg = "${red}", style = "NONE" }, - -- ["@variable.member"] = "${cyan}", - -- ["@variable.parameter"] = "${red}", - -- ["@property"] = { fg = "${cyan}" }, -- similar to `@field` - ["@property.lua"] = { fg = "${red}", bg = "NONE" }, - ["@lsp.type.property.lua"] = { fg = "${cyan}", bg = "NONE" }, - ["@lsp.type.variable.lua"] = { fg = "${red}", bg = "NONE" }, - NvimTreeGitDirty = { fg = "${yellow}" }, - Pmenu = { fg = "${fg}", bg = "${bg}" }, - PmenuThumb = { bg = "${gray}" }, -- Popup menu: Thumb of the scrollbar. - -- overide lualine fill color with bg color - LualineNormal = { bg = "${bg}" }, - -- overide lualine_c fill color with bg color - LualineC = { bg = "${bg}" }, - -- overide lualine_x fill color with bg color - LualineX = { bg = "${bg}" }, - -- overide which-key fill color with bg color - -- WhichKey = { bg = "${bg}" }, - -- -- overide which-key fill color with bg color - -- WhichKeySeperator = { bg = "${bg}" }, - -- -- overide which-key fill color with bg color - -- WhichKeyDesc = { fg = "${red}" }, - -- -- overide which-key fill color with bg color - -- WhichKeyFloat = { bg = "${bg}" }, - WhichKeyFloat = { bg = is_transparent and "NONE" or "${bg}" }, - -- -- overide which-key fill color with bg color - -- WhichKeyValue = { bg = "${bg}" }, - -- -- overide which-key fill color with bg color - -- WhichKeyBorder = { bg = "${bg}" }, - LspInfoBorder = { fg = "${fg}" }, - NormalFloat = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, - Normal = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, - NormalNC = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, - FloatBorder = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, - NonText = { bg = "NONE", fg = "#3E4450" }, - }, - }) - local colorscheme = pcode.themes.onedarkpro or "onedark" - vim.cmd("colorscheme " .. colorscheme) - end, + "olimorris/onedarkpro.nvim", + priority = 1000, + config = function() + local is_transparent = false + require("onedarkpro").setup({ + styles = { + types = "NONE", + methods = "NONE", + numbers = "NONE", + strings = "NONE", + comments = "italic", + keywords = "bold,italic", + constants = "NONE", + functions = "italic", + operators = "NONE", + variables = "NONE", + parameters = "NONE", + conditionals = "italic", + virtual_text = "NONE", + tags = "italic", + }, + colors = { + bg_statusline = "#282c34", + onedark = { + green = "#99c379", + gray = "#8094b4", + red = "#e06c75", + purple = "#c678dd", + yellow = "#e5c07a", + blue = "#61afef", + cyan = "#56b6c2", + indentline = "#3b4261", + float_bg = "#282c34", + }, + onedark_dark = { + bg_statusline = "#000", + }, + }, + options = { + cursorline = true, + transparency = is_transparent, + terminal_colors = true, + }, + highlights = { + -- overide cursor line fill colors + LineNr = { fg = "#49505E" }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set. + CursorLineNr = { fg = "${blue}" }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line. + CursorLine = { bg = "#333842" }, + Cursor = { fg = "${bg}", bg = "${fg}" }, -- character under the cursor + lCursor = { fg = "${bg}", bg = "${fg}" }, -- the character under the cursor when |language-mapping| is used (see 'guicursor') + CursorIM = { fg = "${bg}", bg = "${fg}" }, -- like Cursor, but used when in IME mode |CursorIM| + CursorColumn = { bg = "#333842" }, -- Screen-column at the cursor, when 'cursorcolumn' is set. + -- overide nvimtree folder icon fill color + NvimTreeFolderIcon = { fg = "${gray}" }, + -- overide nvimtree text fill color folder opened + NvimTreeOpenedFolderName = { fg = "${blue}" }, + -- overide nvimtree text fill color root folder + NvimTreeRootFolder = { fg = "${yellow}" }, + NvimTreeSpecialFile = { fg = "${orange}" }, + NvimTreeWinSeparator = { fg = "#202329" }, + NvimTreeIndentMarker = { fg = "#3E4450" }, + -- overide nvimtree cursorline + NvimTreeCursorLine = { bg = "#333842" }, + -- overide indenline fill color + IblIndent = { fg = "#3E4450" }, + -- overide cmp cursorline fill color with #333842 + PmenuSel = { bg = "#333842" }, + illuminatedWord = { bg = "#3b4261" }, + illuminatedCurWord = { bg = "#3b4261" }, + IlluminatedWordText = { bg = "#3b4261" }, + IlluminatedWordRead = { bg = "#3b4261" }, + IlluminatedWordWrite = { bg = "#3b4261" }, + StatusLine = { fg = "#f8f8f2", bg = is_transparent and "NONE" or "${bg}" }, + StatusLineTerm = { fg = "#f8f8f2", bg = "${bg}" }, + BufferLineFill = { bg = is_transparent and "NONE" or "${bg}" }, + ["@string.special.url.html"] = { fg = "${green}" }, + ["@lsp.type.parameter"] = { fg = "${gray}" }, + -- ["@text.uri.html"] = { fg = "${green}" }, + -- ["@tag.javascript"] = { fg = "${red}" }, + -- ["@tag.attribute"] = { fg = "${orange}", style = "italic" }, + -- ["@constructor.javascript"] = { fg = "${red}" }, + -- ["@variable"] = { fg = "${fg}", style = "NONE" }, -- various variable names + -- ["@variable.builtin"] = { fg = "${red}", style = "NONE" }, + -- ["@variable.member"] = "${cyan}", + -- ["@variable.parameter"] = "${red}", + -- ["@property"] = { fg = "${cyan}" }, -- similar to `@field` + ["@property.lua"] = { fg = "${red}", bg = "NONE" }, + ["@lsp.type.property.lua"] = { fg = "${cyan}", bg = "NONE" }, + ["@lsp.type.variable.lua"] = { fg = "${red}", bg = "NONE" }, + NvimTreeGitDirty = { fg = "${yellow}" }, + Pmenu = { fg = "${fg}", bg = "${bg}" }, + PmenuThumb = { bg = "${gray}" }, -- Popup menu: Thumb of the scrollbar. + -- overide lualine fill color with bg color + LualineNormal = { bg = "${bg}" }, + -- overide lualine_c fill color with bg color + LualineC = { bg = "${bg}" }, + -- overide lualine_x fill color with bg color + LualineX = { bg = "${bg}" }, + -- overide which-key fill color with bg color + -- WhichKey = { bg = "${bg}" }, + -- -- overide which-key fill color with bg color + -- WhichKeySeperator = { bg = "${bg}" }, + -- -- overide which-key fill color with bg color + -- WhichKeyDesc = { fg = "${red}" }, + -- -- overide which-key fill color with bg color + -- WhichKeyFloat = { bg = "${bg}" }, + WhichKeyFloat = { bg = is_transparent and "NONE" or "${bg}" }, + -- -- overide which-key fill color with bg color + -- WhichKeyValue = { bg = "${bg}" }, + -- -- overide which-key fill color with bg color + -- WhichKeyBorder = { bg = "${bg}" }, + LspInfoBorder = { fg = "${fg}" }, + NormalFloat = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, + Normal = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, + NormalNC = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, + FloatBorder = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" }, + NonText = { bg = "NONE", fg = "#3E4450" }, + MasonBackdrop = { link = "NormalFloat" }, + }, + }) + local colorscheme = pcode.themes.onedarkpro or "onedark" + vim.cmd("colorscheme " .. colorscheme) + end, } diff --git a/lua/pcode/plugins/theme/sublimetext.lua b/lua/pcode/plugins/theme/sublimetext.lua index e49479e..9546d40 100644 --- a/lua/pcode/plugins/theme/sublimetext.lua +++ b/lua/pcode/plugins/theme/sublimetext.lua @@ -12,6 +12,7 @@ return { -- custom hilights local hi = vim.api.nvim_set_hl hi(0, "FoldColumn", { bg = colors.bg2 }) + hi(0, "MasonBackdrop", { link = "NormalFloat" }) end, }) end, diff --git a/lua/pcode/plugins/theme/tokyonight.lua b/lua/pcode/plugins/theme/tokyonight.lua index 5dd30a3..bb519af 100644 --- a/lua/pcode/plugins/theme/tokyonight.lua +++ b/lua/pcode/plugins/theme/tokyonight.lua @@ -71,6 +71,7 @@ return { highlights["@tag.attribute"] = { fg = colors.green1, italic = true } -- highlights["@keyword.function"] = { fg = colors.blue, italic = true } -- highlights["@function"] = { fg = colors.blue, italic = true } + highlights.MasonBackdrop = { link = "NormalFloat" } end, }) end, diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 6213a17..7f3e7d8 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -48,6 +48,8 @@ pcode.extras = { lspsignatur = false, telescopetreesiterinfo = true, fidget = false, + tinydignostic = false, + dressing = false, } -- activate config themes pcode.themes = { @@ -93,6 +95,6 @@ pcode.themes = { -- github = "github_dark_dimmed", } -- activate config transparent_bg -pcode.transparent = true +pcode.transparent = false pcode.localcode = true pcode.snippets_path = vim.fn.stdpath("config") .. "/mysnippets" From d41d9b4cf5b7981bbe86847433cd572400df8f54 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 14 Jun 2025 16:17:17 +0700 Subject: [PATCH 06/28] fix: nvim menu create new file --- lazy-lock.json | 17 +++++++++-------- lua/pcode/plugins/extras/dressing.lua | 8 ++++---- lua/pcode/plugins/extras/tinydignostic.lua | 13 ++++++++++++- lua/pcode/user/custom.lua | 18 +++++++++++++++++- lua/pcode/user/default.lua | 2 +- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 9aae565..c7b5a32 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -20,6 +20,7 @@ "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "731b581428ec6c1ccb451b95190ebbc6d7006db7" }, "inc-rename.nvim": { "branch": "main", "commit": "a3e31af13844534c66041ce92f29af7745883875" }, @@ -30,7 +31,7 @@ "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, - "mini.indentscope": { "branch": "main", "commit": "8af2569a7d7fd37300dfa760e44e71efbbf322fd" }, + "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" }, "neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" }, @@ -41,18 +42,18 @@ "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "ea82027c3447dc1a022be9a9884de276c05cd33a" }, + "nvim-dap": { "branch": "master", "commit": "40a8189b8a57664a1850b0823fdcb3ac95b9f635" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, - "nvim-lint": { "branch": "master", "commit": "cc26ae6a620298bb3f33b0e0681f99a10ae57781" }, - "nvim-lspconfig": { "branch": "master", "commit": "77d3fdfb3554632c7a3b101ded643d422de7626f" }, + "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, + "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, "nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, - "nvim-scrollview": { "branch": "main", "commit": "b65192ef2e39c456e8dc5f8f5cdd9b8d13f121e4" }, - "nvim-tree.lua": { "branch": "master", "commit": "1c733e8c1957dc67f47580fe9c458a13b5612d5b" }, + "nvim-scrollview": { "branch": "main", "commit": "a313032d62ee630aeac9d5408817f2e834bc9aa9" }, + "nvim-tree.lua": { "branch": "master", "commit": "6b5b36659688767fb9f133bb83024ab1466fe5cd" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, @@ -61,7 +62,7 @@ "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "refactoring.nvim": { "branch": "master", "commit": "9cd0186ffe76fe6abc64c0aafb775c8f776ab5ee" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, - "smart-splits.nvim": { "branch": "master", "commit": "9af865e451e55a9835fae6862dd7c55396870ecb" }, + "smart-splits.nvim": { "branch": "master", "commit": "dcc9a886ac7214db6dd67d27044b8388b628dcb6" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, @@ -69,7 +70,7 @@ "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, - "volt": { "branch": "main", "commit": "2aa99a4e388c840597441a901209cbdafe8472ed" }, + "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }, "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } diff --git a/lua/pcode/plugins/extras/dressing.lua b/lua/pcode/plugins/extras/dressing.lua index c881169..a7a750e 100644 --- a/lua/pcode/plugins/extras/dressing.lua +++ b/lua/pcode/plugins/extras/dressing.lua @@ -8,10 +8,10 @@ return { return vim.ui.select(...) end ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.input = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.input(...) - end + -- vim.ui.input = function(...) + -- require("lazy").load({ plugins = { "dressing.nvim" } }) + -- return vim.ui.input(...) + -- end end, opts = { input = { diff --git a/lua/pcode/plugins/extras/tinydignostic.lua b/lua/pcode/plugins/extras/tinydignostic.lua index 60d864d..42a20ab 100644 --- a/lua/pcode/plugins/extras/tinydignostic.lua +++ b/lua/pcode/plugins/extras/tinydignostic.lua @@ -5,7 +5,18 @@ return { config = function() require("tiny-inline-diagnostic").setup({ preset = "powerline", + -- signs = { + -- left = "", + -- right = "", + -- diag = "●", + -- arrow = "  ", + -- up_arrow = "  ", + -- vertical = " │", + -- vertical_end = " └", + -- }, + blend = { + factor = 0.22, + }, }) - vim.diagnostic.config({ virtual_text = false }) -- Only if needed in your configuration, if you already have native LSP diagnostics end, } diff --git a/lua/pcode/user/custom.lua b/lua/pcode/user/custom.lua index cd0e85c..d370589 100644 --- a/lua/pcode/user/custom.lua +++ b/lua/pcode/user/custom.lua @@ -47,7 +47,23 @@ return { "williamboman/mason-lspconfig.nvim", opts = function(_, opts) vim.list_extend(opts.skip_config, {}) - opts.virtual_text = true + opts.virtual_text = false + vim.diagnostic.config({ virtual_lines = { current_line = true } }) + -- sample custom diagnostic icon + vim.diagnostic.config({ + underline = false, + virtual_text = false, + update_in_insert = false, + severity_sort = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = " ", + [vim.diagnostic.severity.WARN] = " ", + [vim.diagnostic.severity.HINT] = " ", + [vim.diagnostic.severity.INFO] = " ", + }, + }, + }) end, }, -- add whichkey mappings diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 7f3e7d8..0d8c0d0 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -49,7 +49,7 @@ pcode.extras = { telescopetreesiterinfo = true, fidget = false, tinydignostic = false, - dressing = false, + dressing = true, } -- activate config themes pcode.themes = { From d31ffccdca8aa4ceab9c9f30c4aaf2638e2974d3 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 14 Jun 2025 19:46:00 +0700 Subject: [PATCH 07/28] enc: overide command TSInstallInfo --- lua/pcode/plugins/_treesitter.lua | 93 ++++++++++++++++--------------- lua/pcode/user/keymaps.lua | 77 +++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 45 deletions(-) diff --git a/lua/pcode/plugins/_treesitter.lua b/lua/pcode/plugins/_treesitter.lua index 335be0e..dd80401 100644 --- a/lua/pcode/plugins/_treesitter.lua +++ b/lua/pcode/plugins/_treesitter.lua @@ -1,47 +1,50 @@ return { - { "nvim-lua/plenary.nvim", event = "VeryLazy" }, - { - "nvim-treesitter/nvim-treesitter", - event = { "BufRead", "VeryLazy" }, - version = false, - build = ":TSUpdate", - lazy = true, - cmd = { - "TSInstall", - "TSInstallInfo", - "TSInstallSync", - "TSUpdate", - "TSUpdateSync", - "TSUninstall", - "TSUninstallInfo", - "TSInstallFromGrammar", - }, - opts = function() - return { - highlight = { enable = true }, - indent = { enable = true }, - ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, - incremental_selection = { - enable = true, - }, - autopairs = { - enable = true, - }, - } - end, - config = function(_, opts) - if type(opts.ensure_installed) == "table" then - ---@type table - local added = {} - opts.ensure_installed = vim.tbl_filter(function(lang) - if added[lang] then - return false - end - added[lang] = true - return true - end, opts.ensure_installed) - end - require("nvim-treesitter.configs").setup(opts) - end, - }, + { "nvim-lua/plenary.nvim", event = "VeryLazy" }, + { + "nvim-treesitter/nvim-treesitter", + event = { "BufRead", "VeryLazy" }, + version = false, + build = ":TSUpdate", + lazy = true, + cmd = { + "TSInstall", + -- "TSInstallInfo", + "TSInstallSync", + "TSUpdate", + "TSUpdateSync", + "TSUninstall", + "TSUninstallInfo", + "TSInstallFromGrammar", + }, + opts = function() + return { + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, + incremental_selection = { + enable = true, + }, + autopairs = { + enable = true, + }, + } + end, + config = function(_, opts) + if type(opts.ensure_installed) == "table" then + ---@type table + local added = {} + opts.ensure_installed = vim.tbl_filter(function(lang) + if added[lang] then + return false + end + added[lang] = true + return true + end, opts.ensure_installed) + end + require("nvim-treesitter.configs").setup(opts) + vim.api.nvim_create_user_command("TSInstallInfo", function() + vim.cmd("Telescope treesitter_info") + end, {}) + end, + }, } diff --git a/lua/pcode/user/keymaps.lua b/lua/pcode/user/keymaps.lua index 39f8c5f..a260663 100644 --- a/lua/pcode/user/keymaps.lua +++ b/lua/pcode/user/keymaps.lua @@ -91,3 +91,80 @@ keymap("n", "", "terminal live-server", opts) -- close current buffer keymap("n", "", "lua require('auto-bufferline.configs.utils').bufremove()", opts) + +-- vim.keymap.set("n", "ti", function() +-- local api = vim.api +-- local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() +-- local parsers = vim.tbl_keys(parser_configs) +-- table.sort(parsers) +-- +-- local choices = {} +-- local lookup = {} +-- +-- for _, parser in ipairs(parsers) do +-- local is_installed = #api.nvim_get_runtime_file("parser/" .. parser .. ".so", false) > 0 +-- +-- local label = (is_installed and "[✓] " or "[✗] ") .. parser +-- table.insert(choices, label) +-- lookup[label] = parser +-- end +-- +-- vim.ui.select(choices, { +-- prompt = "Treesitter ([✓]= installed, [✗] = not installed)", +-- }, function(choice) +-- if choice then +-- local parser_name = lookup[choice] +-- if parser_name then +-- vim.cmd("TSInstall " .. parser_name) +-- end +-- end +-- end) +-- end, { desc = "Install Treesitter" }) +-- +-- vim.keymap.set("n", "tu", function() +-- local parsers = require("nvim-treesitter.info").installed_parsers() +-- table.sort(parsers) +-- local choices = {} +-- local lookup = {} +-- +-- for _, parser in ipairs(parsers) do +-- local label = "[✓] " .. parser +-- table.insert(choices, label) +-- lookup[label] = parser +-- end +-- +-- vim.ui.select(choices, { +-- prompt = "Uninstall Treesitter", +-- }, function(choice) +-- if choice then +-- local parser_name = lookup[choice] +-- if parser_name then +-- vim.cmd("TSUninstall " .. parser_name) +-- end +-- end +-- end) +-- end, { desc = "Uninstall Treesitter" }) + +vim.api.nvim_create_user_command("TSIsInstalled", function() + local parsers = require("nvim-treesitter.info").installed_parsers() + table.sort(parsers) + local choices = {} + local lookup = {} + + for _, parser in ipairs(parsers) do + local label = "[✓] " .. parser + table.insert(choices, label) + lookup[label] = parser + end + + vim.ui.select(choices, { + prompt = "Uninstall Treesitter", + }, function(choice) + if choice then + local parser_name = lookup[choice] + if parser_name then + vim.cmd("TSUninstall " .. parser_name) + end + end + end) +end, {}) From bf60de3aa1997e5b65d67d5a7793d923b6f6a1f0 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 14 Jun 2025 21:13:57 +0700 Subject: [PATCH 08/28] fix:disable dressing input --- lua/pcode/plugins/extras/dressing.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/pcode/plugins/extras/dressing.lua b/lua/pcode/plugins/extras/dressing.lua index a7a750e..cafd8c9 100644 --- a/lua/pcode/plugins/extras/dressing.lua +++ b/lua/pcode/plugins/extras/dressing.lua @@ -1,5 +1,5 @@ return { - "stevearc/dressing.nvim", + "pojokcodeid/dressing.nvim", lazy = true, init = function() ---@diagnostic disable-next-line: duplicate-set-field @@ -15,6 +15,7 @@ return { end, opts = { input = { + enabled = false, title_pos = "center", relative = "editor", default_prompt = "➤ ", From 82d6ba288902c4422f737343ebb0fb785a7f5ea6 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 14 Jun 2025 21:37:42 +0700 Subject: [PATCH 09/28] enc: add telescope diff file --- lazy-lock.json | 1 + lua/pcode/plugins/extras/telescopediff.lua | 26 ++++++++++++++++++++++ lua/pcode/user/default.lua | 1 + 3 files changed, 28 insertions(+) create mode 100644 lua/pcode/plugins/extras/telescopediff.lua diff --git a/lazy-lock.json b/lazy-lock.json index c7b5a32..7b99297 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -63,6 +63,7 @@ "refactoring.nvim": { "branch": "master", "commit": "9cd0186ffe76fe6abc64c0aafb775c8f776ab5ee" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, "smart-splits.nvim": { "branch": "master", "commit": "dcc9a886ac7214db6dd67d27044b8388b628dcb6" }, + "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, diff --git a/lua/pcode/plugins/extras/telescopediff.lua b/lua/pcode/plugins/extras/telescopediff.lua new file mode 100644 index 0000000..c122598 --- /dev/null +++ b/lua/pcode/plugins/extras/telescopediff.lua @@ -0,0 +1,26 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "jemag/telescope-diff.nvim", + }, + config = function() + require("telescope").load_extension("diff") + end, + keys = { + { + "sd", + function() + require("telescope").extensions.diff.diff_files({ hidden = true }) + end, + desc = "Diff 2 Files", + }, + { + "sD", + function() + require("telescope").extensions.diff.diff_current({ hidden = true }) + end, + desc = "Diff Current File", + }, + }, +} diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 0d8c0d0..8c8ee5f 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -50,6 +50,7 @@ pcode.extras = { fidget = false, tinydignostic = false, dressing = true, + telescopediff = true, } -- activate config themes pcode.themes = { From 5df3f7b2abd023db94c3330d44962bcde164a001 Mon Sep 17 00:00:00 2001 From: pojok code Date: Mon, 16 Jun 2025 05:54:53 +0700 Subject: [PATCH 10/28] enc: add new command --- lazy-lock.json | 6 +- lua/pcode/plugins/lang/golang.lua | 4 + lua/pcode/user/autocmd.lua | 231 ++++++++++++++++++++++++++++++ 3 files changed, 238 insertions(+), 3 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 7b99297..7ba420e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -27,7 +27,7 @@ "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "bef29b653ba71d442816bf56286c2a686210be04" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f17d02b928a18ab88a50d374be036ab5f499fde4" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, @@ -52,8 +52,8 @@ "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, - "nvim-scrollview": { "branch": "main", "commit": "a313032d62ee630aeac9d5408817f2e834bc9aa9" }, - "nvim-tree.lua": { "branch": "master", "commit": "6b5b36659688767fb9f133bb83024ab1466fe5cd" }, + "nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" }, + "nvim-tree.lua": { "branch": "master", "commit": "d87b41ca537e2131622d48a6c25ccf2fbe0e5d62" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, diff --git a/lua/pcode/plugins/lang/golang.lua b/lua/pcode/plugins/lang/golang.lua index aceb426..9f6a0ba 100644 --- a/lua/pcode/plugins/lang/golang.lua +++ b/lua/pcode/plugins/lang/golang.lua @@ -11,6 +11,10 @@ return { opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} vim.list_extend(opts.ensure_installed, { "gopls" }) + -- add run command for current filebuffer + vim.api.nvim_create_user_command("RunGo", function() + vim.cmd("term go run " .. vim.fn.expand("%")) + end, {}) end, }, { diff --git a/lua/pcode/user/autocmd.lua b/lua/pcode/user/autocmd.lua index 8ecb083..b2eacb0 100644 --- a/lua/pcode/user/autocmd.lua +++ b/lua/pcode/user/autocmd.lua @@ -124,3 +124,234 @@ vim.api.nvim_create_autocmd("ExitPre", { -- vim.api.nvim_set_keymap("n", "rg", "terminalgradle run", { noremap = true, silent = true }) -- end, -- }) + +-- Extras +local function lsp_status() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + if #clients == 0 then + print("󰅚 No LSP clients attached") + return + end + + print("󰒋 LSP Status for buffer " .. bufnr .. ":") + print("─────────────────────────────────") + + for i, client in ipairs(clients) do + print(string.format("󰌘 Client %d: %s (ID: %d)", i, client.name, client.id)) + print(" Root: " .. (client.config.root_dir or "N/A")) + print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", ")) + + -- Check capabilities + local caps = client.server_capabilities + local features = {} + if caps.completionProvider then + table.insert(features, "completion") + end + if caps.hoverProvider then + table.insert(features, "hover") + end + if caps.definitionProvider then + table.insert(features, "definition") + end + if caps.referencesProvider then + table.insert(features, "references") + end + if caps.renameProvider then + table.insert(features, "rename") + end + if caps.codeActionProvider then + table.insert(features, "code_action") + end + if caps.documentFormattingProvider then + table.insert(features, "formatting") + end + + print(" Features: " .. table.concat(features, ", ")) + print("") + end +end + +vim.api.nvim_create_user_command("LspStatus", lsp_status, { desc = "Show detailed LSP status" }) + +local function check_lsp_capabilities() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + if #clients == 0 then + print("No LSP clients attached") + return + end + + for _, client in ipairs(clients) do + print("Capabilities for " .. client.name .. ":") + local caps = client.server_capabilities + + local capability_list = { + { "Completion", caps.completionProvider }, + { "Hover", caps.hoverProvider }, + { "Signature Help", caps.signatureHelpProvider }, + { "Go to Definition", caps.definitionProvider }, + { "Go to Declaration", caps.declarationProvider }, + { "Go to Implementation", caps.implementationProvider }, + { "Go to Type Definition", caps.typeDefinitionProvider }, + { "Find References", caps.referencesProvider }, + { "Document Highlight", caps.documentHighlightProvider }, + { "Document Symbol", caps.documentSymbolProvider }, + { "Workspace Symbol", caps.workspaceSymbolProvider }, + { "Code Action", caps.codeActionProvider }, + { "Code Lens", caps.codeLensProvider }, + { "Document Formatting", caps.documentFormattingProvider }, + { "Document Range Formatting", caps.documentRangeFormattingProvider }, + { "Rename", caps.renameProvider }, + { "Folding Range", caps.foldingRangeProvider }, + { "Selection Range", caps.selectionRangeProvider }, + } + + for _, cap in ipairs(capability_list) do + local status = cap[2] and "✓" or "✗" + print(string.format(" %s %s", status, cap[1])) + end + print("") + end +end + +vim.api.nvim_create_user_command("LspCapabilities", check_lsp_capabilities, { desc = "Show LSP capabilities" }) + +local function lsp_diagnostics_info() + local bufnr = vim.api.nvim_get_current_buf() + local diagnostics = vim.diagnostic.get(bufnr) + + local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 } + + for _, diagnostic in ipairs(diagnostics) do + local severity = vim.diagnostic.severity[diagnostic.severity] + counts[severity] = counts[severity] + 1 + end + + print("󰒡 Diagnostics for current buffer:") + print(" Errors: " .. counts.ERROR) + print(" Warnings: " .. counts.WARN) + print(" Info: " .. counts.INFO) + print(" Hints: " .. counts.HINT) + print(" Total: " .. #diagnostics) +end + +vim.api.nvim_create_user_command("LspDiagnostics", lsp_diagnostics_info, { desc = "Show LSP diagnostics count" }) + +local function lsp_info() + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr }) + or vim.lsp.get_active_clients({ bufnr = bufnr }) + + print("═══════════════════════════════════") + print(" LSP INFORMATION ") + print("═══════════════════════════════════") + print("") + + -- Basic info + print("󰈙 Language client log: " .. vim.lsp.get_log_path()) + print("󰈔 Detected filetype: " .. vim.bo.filetype) + print("󰈮 Buffer: " .. bufnr) + print("󰈔 Root directory: " .. (vim.fn.getcwd() or "N/A")) + print("") + + if #clients == 0 then + print("󰅚 No LSP clients attached to buffer " .. bufnr) + print("") + print("Possible reasons:") + print(" • No language server installed for " .. vim.bo.filetype) + print(" • Language server not configured") + print(" • Not in a project root directory") + print(" • File type not recognized") + return + end + + print("󰒋 LSP clients attached to buffer " .. bufnr .. ":") + print("─────────────────────────────────") + + for i, client in ipairs(clients) do + print(string.format("󰌘 Client %d: %s", i, client.name)) + print(" ID: " .. client.id) + print(" Root dir: " .. (client.config.root_dir or "Not set")) + print(" Command: " .. table.concat(client.config.cmd or {}, " ")) + print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", ")) + + -- Server status + if client.is_stopped() then + print(" Status: 󰅚 Stopped") + else + print(" Status: 󰄬 Running") + end + + -- Workspace folders + if client.workspace_folders and #client.workspace_folders > 0 then + print(" Workspace folders:") + for _, folder in ipairs(client.workspace_folders) do + print(" • " .. folder.name) + end + end + + -- Attached buffers count + local attached_buffers = {} + for buf, _ in pairs(client.attached_buffers or {}) do + table.insert(attached_buffers, buf) + end + print(" Attached buffers: " .. #attached_buffers) + + -- Key capabilities + local caps = client.server_capabilities + local key_features = {} + if caps.completionProvider then + table.insert(key_features, "completion") + end + if caps.hoverProvider then + table.insert(key_features, "hover") + end + if caps.definitionProvider then + table.insert(key_features, "definition") + end + if caps.documentFormattingProvider then + table.insert(key_features, "formatting") + end + if caps.codeActionProvider then + table.insert(key_features, "code_action") + end + + if #key_features > 0 then + print(" Key features: " .. table.concat(key_features, ", ")) + end + + print("") + end + + -- Diagnostics summary + local diagnostics = vim.diagnostic.get(bufnr) + if #diagnostics > 0 then + print("󰒡 Diagnostics Summary:") + local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 } + + for _, diagnostic in ipairs(diagnostics) do + local severity = vim.diagnostic.severity[diagnostic.severity] + counts[severity] = counts[severity] + 1 + end + + print(" 󰅚 Errors: " .. counts.ERROR) + print(" 󰀪 Warnings: " .. counts.WARN) + print(" 󰋽 Info: " .. counts.INFO) + print(" 󰌶 Hints: " .. counts.HINT) + print(" Total: " .. #diagnostics) + else + print("󰄬 No diagnostics") + end + + print("") + print("Use :LspLog to view detailed logs") + print("Use :LspCapabilities for full capability list") +end + +-- Create command +vim.api.nvim_create_user_command("LspInfo2", lsp_info, { desc = "Show comprehensive LSP information" }) From dc19ff45d805953a6bb92d5c77bc9b3ef81a775c Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 21 Jun 2025 13:33:57 +0700 Subject: [PATCH 11/28] enc: update default config --- lazy-lock.json | 21 +++---- lua/pcode/plugins/coderunner.lua | 96 +++++++++++++++++-------------- lua/pcode/plugins/lang/golang.lua | 42 +++++++++++++- lua/pcode/plugins/nvimtree.lua | 38 ++++++++++++ lua/pcode/user/default.lua | 7 ++- 5 files changed, 144 insertions(+), 60 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 7ba420e..1608a3f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -22,12 +22,11 @@ "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "731b581428ec6c1ccb451b95190ebbc6d7006db7" }, - "inc-rename.nvim": { "branch": "main", "commit": "a3e31af13844534c66041ce92f29af7745883875" }, + "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "f17d02b928a18ab88a50d374be036ab5f499fde4" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f54e3c11fc9ebfcfc27e696182b0295b071d0811" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, @@ -39,30 +38,29 @@ "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, + "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "40a8189b8a57664a1850b0823fdcb3ac95b9f635" }, + "nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "7ad4a11cc5742774877c529fcfb2702f7caf75e4" }, + "nvim-lspconfig": { "branch": "master", "commit": "0112e1f77983141e1453bd37d124302f1c876c46" }, "nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, "nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" }, - "nvim-tree.lua": { "branch": "master", "commit": "d87b41ca537e2131622d48a6c25ccf2fbe0e5d62" }, + "nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, - "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, - "refactoring.nvim": { "branch": "master", "commit": "9cd0186ffe76fe6abc64c0aafb775c8f776ab5ee" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, - "smart-splits.nvim": { "branch": "master", "commit": "dcc9a886ac7214db6dd67d27044b8388b628dcb6" }, + "smart-splits.nvim": { "branch": "master", "commit": "0098e376638602bc6aaf779bb8531b840a3fe26e" }, "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, @@ -73,6 +71,5 @@ "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, - "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }, - "zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" } + "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" } } diff --git a/lua/pcode/plugins/coderunner.lua b/lua/pcode/plugins/coderunner.lua index f3e21ef..f614432 100644 --- a/lua/pcode/plugins/coderunner.lua +++ b/lua/pcode/plugins/coderunner.lua @@ -2,51 +2,63 @@ -- cpp="gcc $fileName -lstdc++ -o $fileNameWithoutExt && $fileNameWithoutExt" local pyrun = "python -u" if vim.fn.has("win32") == 0 then - pyrun = "python3 -u" + pyrun = "python3 -u" end local rfile = { - java = "cd $dir && javac $fileName && java $fileNameWithoutExt", - python = pyrun, - typescript = "ts-node $dir/$fileName", - rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt", - cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt", - scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css", - javascript = 'node "$dir/$fileName"', - go = "go run .", + java = "cd $dir && javac $fileName && java $fileNameWithoutExt", + python = pyrun, + typescript = "ts-node $dir/$fileName", + rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt", + cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt", + scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css", + javascript = 'node "$dir/$fileName"', + -- go = "go run .", + go = "go run $fileName", } +local runProject = {} +local cwd = vim.fn.getcwd() +local go_mod_path = cwd .. "/go.mod" +if vim.fn.filereadable(go_mod_path) ~= 0 then + runProject[cwd] = { + name = "Go Project (cwd)", + command = "go run .", + } +end + return { - "CRAG666/code_runner.nvim", - lazy = true, - cmd = { "RunCode", "RunFile", "RunProject", "RunClose" }, - opts = { - filetype = rfile, - mode = "float", - focus = true, - startinsert = true, - term = { - position = "bot", - size = 50, - }, - float = { - close_key = "", - border = "rounded", - height = 0.8, - width = 0.8, - x = 0.5, - y = 0.5, - border_hl = "FloatBorder", - float_hl = "Normal", - blend = 0, - }, - }, - config = function(_, opts) - require("code_runner").setup(opts) - end, - keys = { - { "r", "", desc = "  Run", mode = "n" }, - { "rr", "RunCode", desc = "Run Code", mode = "n" }, - { "rf", "RunFile", desc = "Run File", mode = "n" }, - { "rp", "RunProject", desc = "Run Project", mode = "n" }, - }, + "CRAG666/code_runner.nvim", + lazy = true, + cmd = { "RunCode", "RunFile", "RunProject", "RunClose" }, + opts = { + filetype = rfile, + project = runProject, + mode = "float", + focus = true, + startinsert = true, + term = { + position = "bot", + size = 50, + }, + float = { + close_key = "", + border = "rounded", + height = 0.8, + width = 0.8, + x = 0.5, + y = 0.5, + border_hl = "FloatBorder", + float_hl = "Normal", + blend = 0, + }, + }, + config = function(_, opts) + require("code_runner").setup(opts) + end, + keys = { + { "r", "", desc = "  Run", mode = "n" }, + { "rr", "RunCode", desc = "Run Code", mode = "n" }, + { "rf", "RunFile", desc = "Run File", mode = "n" }, + { "rp", "RunProject", desc = "Run Project", mode = "n" }, + }, } diff --git a/lua/pcode/plugins/lang/golang.lua b/lua/pcode/plugins/lang/golang.lua index 9f6a0ba..a5cf93c 100644 --- a/lua/pcode/plugins/lang/golang.lua +++ b/lua/pcode/plugins/lang/golang.lua @@ -11,9 +11,45 @@ return { opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} vim.list_extend(opts.ensure_installed, { "gopls" }) - -- add run command for current filebuffer - vim.api.nvim_create_user_command("RunGo", function() - vim.cmd("term go run " .. vim.fn.expand("%")) + vim.api.nvim_create_user_command("GoRun", function() + local filename = vim.fn.expand("%:p") -- path lengkap file aktif + if not filename:match("%.go$") then + vim.notify("current file is not a go file.", vim.log.levels.WARN, { title = "GoRun" }) + return + end + + local Terminal = require("toggleterm.terminal").Terminal + local go_runner = Terminal:new({ + cmd = "go run " .. filename, + direction = "float", + close_on_exit = false, + hidden = true, + }) + + go_runner:toggle() + end, {}) + vim.api.nvim_create_user_command("GoBuild", function() + local cwd = vim.fn.getcwd() + local go_mod_path = cwd .. "/go.mod" + if vim.fn.filereadable(go_mod_path) == 0 then + vim.notify("current project is not a go project.", vim.log.levels.WARN, { title = "GoBuild" }) + return + end + + local Terminal = require("toggleterm.terminal").Terminal + -- create file exe jika os adalah windows + local filename = "output" + if vim.fn.has("win32") == 1 then + filename = "output.exe" + end + local go_runner = Terminal:new({ + cmd = "go build -o " .. filename .. " && ./" .. filename, + direction = "float", + close_on_exit = false, + hidden = true, + }) + + go_runner:toggle() end, {}) end, }, diff --git a/lua/pcode/plugins/nvimtree.lua b/lua/pcode/plugins/nvimtree.lua index e845450..8227fc3 100644 --- a/lua/pcode/plugins/nvimtree.lua +++ b/lua/pcode/plugins/nvimtree.lua @@ -127,6 +127,44 @@ return { return opts end, config = function(_, opts) + if pcode.nvimtree_float then + -- set nvimtree float view (default left side) + opts.view = { + adaptive_size = false, + centralize_selection = true, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + float = { + enable = true, + open_win_config = function() + local screen_w = vim.opt.columns:get() + ---@diagnostic disable-next-line: undefined-field + local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() + local window_w = screen_w * 0.5 + local window_h = screen_h * 0.9 + local window_w_int = math.floor(window_w) + local window_h_int = math.floor(window_h) + local center_x = (screen_w - window_w) / 2 + ---@diagnostic disable-next-line: undefined-field + local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() + return { + border = "rounded", + relative = "editor", + row = center_y, + col = center_x, + width = window_w_int, + height = window_h_int, + } + end, + }, + width = function() + return math.floor(vim.opt.columns:get() * 0.5) + end, + } + end require("nvim-tree").setup(opts) local api = require("nvim-tree.api") api.events.subscribe(api.events.Event.FileCreated, function(file) diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 8c8ee5f..9bac5ae 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -27,12 +27,12 @@ pcode.extras = { minianimate = false, neoscroll = false, nvimufo = false, - refactoring = true, + refactoring = false, rest = false, treesittercontex = false, codeium = true, colorizer = true, - dap = true, + dap = false, deviconcolor = true, illuminate = true, indentscupe = true, @@ -44,7 +44,7 @@ pcode.extras = { verticalcolumn = true, visualmulti = true, yanky = true, - zenmode = true, + zenmode = false, lspsignatur = false, telescopetreesiterinfo = true, fidget = false, @@ -99,3 +99,4 @@ pcode.themes = { pcode.transparent = false pcode.localcode = true pcode.snippets_path = vim.fn.stdpath("config") .. "/mysnippets" +pcode.nvimtree_float = false From c1e9e57f17bd4d0175230fae0e6d0bee2f1c3839 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 21 Jun 2025 19:19:34 +0700 Subject: [PATCH 12/28] enc: add npm dev runner for vite --- lazy-lock.json | 5 +- lua/pcode/plugins/extras/indentscupe.lua | 3 + lua/pcode/plugins/lang/javascript.lua | 361 +++++++++++------------ lua/pcode/user/default.lua | 2 +- lua/pcode/user/npmrun.lua | 171 +++++++++++ 5 files changed, 358 insertions(+), 184 deletions(-) create mode 100644 lua/pcode/user/npmrun.lua diff --git a/lazy-lock.json b/lazy-lock.json index 1608a3f..9b8df1b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -34,6 +34,7 @@ "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" }, "neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" }, + "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, @@ -45,8 +46,9 @@ "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, + "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "0112e1f77983141e1453bd37d124302f1c876c46" }, + "nvim-lspconfig": { "branch": "master", "commit": "69a1624aff5dc30dddd0c59d99a947b63c80bf2a" }, "nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, @@ -70,6 +72,7 @@ "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, + "vscode-js-debug": { "branch": "main", "commit": "a3279c2abc1162069b0f5c014542b8b849cefa70" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" } } diff --git a/lua/pcode/plugins/extras/indentscupe.lua b/lua/pcode/plugins/extras/indentscupe.lua index 6bde87b..ad4a10a 100644 --- a/lua/pcode/plugins/extras/indentscupe.lua +++ b/lua/pcode/plugins/extras/indentscupe.lua @@ -23,6 +23,9 @@ return { "toggleterm", "Trouble", "trouble", + "term", + "terminal", + "zsh", }, callback = function() vim.b.miniindentscope_disable = true diff --git a/lua/pcode/plugins/lang/javascript.lua b/lua/pcode/plugins/lang/javascript.lua index 6996fe6..fd637a3 100644 --- a/lua/pcode/plugins/lang/javascript.lua +++ b/lua/pcode/plugins/lang/javascript.lua @@ -1,104 +1,101 @@ local config_file = "jest.config.ts" local M = { - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend( - opts.ensure_installed, - { "html", "javascript", "typescript", "tsx", "css", "json", "jsonc" } - ) - end, - }, - { - "williamboman/mason-lspconfig.nvim", - opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "html", "eslint", "cssls", "emmet_ls", "jsonls", "ts_ls" }) - end, - }, - { - "pojokcodeid/auto-conform.nvim", - event = "VeryLazy", - opts = function(_, opts) - opts.formatters_by_ft = opts.formatters_by_ft or {} - local package = "prettier" - vim.list_extend(opts.ensure_installed, { package }) - opts.formatters_by_ft.javascript = { package } - end, - }, - { - "nvim-neotest/neotest", - dependencies = { - "antoinemadec/FixCursorHold.nvim", - "nvim-neotest/neotest-jest", - "nvim-neotest/nvim-nio", - }, - opts = { - adapters = { - ["neotest-jest"] = { - jestCommand = "npm test -- ", - jestConfigFile = function() - local file = vim.fn.expand("%:p") - if string.find(file, "/packages/") then - return string.match(file, "(.-/[^/]+/)src") .. config_file - end - return vim.fn.getcwd() .. "/" .. config_file - end, - cwd = function() - local file = vim.fn.expand("%:p") - if string.find(file, "/packages/") then - return string.match(file, "(.-/[^/]+/)src") - end - return vim.fn.getcwd() - end, - }, - }, - status = { virtual_text = true }, - output = { open_on_run = true }, - }, - config = function(_, opts) - local neotest_ns = vim.api.nvim_create_namespace("neotest") - vim.diagnostic.config({ - virtual_text = { - format = function(diagnostic) - -- Replace newline and tab characters with space for more compact diagnostics - local message = - diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") - return message - end, - }, - }, neotest_ns) + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "html", "javascript", "typescript", "tsx", "css", "json", "jsonc" }) + end, + }, + { + "williamboman/mason-lspconfig.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "html", "eslint", "cssls", "emmet_ls", "jsonls", "ts_ls" }) + end, + }, + { + "pojokcodeid/auto-conform.nvim", + event = "VeryLazy", + opts = function(_, opts) + opts.formatters_by_ft = opts.formatters_by_ft or {} + local package = "prettier" + vim.list_extend(opts.ensure_installed, { package }) + opts.formatters_by_ft.javascript = { package } + end, + }, + { + "nvim-neotest/neotest", + dependencies = { + "antoinemadec/FixCursorHold.nvim", + "nvim-neotest/neotest-jest", + "nvim-neotest/nvim-nio", + }, + opts = { + adapters = { + ["neotest-jest"] = { + jestCommand = "npm test -- ", + jestConfigFile = function() + local file = vim.fn.expand("%:p") + if string.find(file, "/packages/") then + return string.match(file, "(.-/[^/]+/)src") .. config_file + end + return vim.fn.getcwd() .. "/" .. config_file + end, + cwd = function() + local file = vim.fn.expand("%:p") + if string.find(file, "/packages/") then + return string.match(file, "(.-/[^/]+/)src") + end + return vim.fn.getcwd() + end, + }, + }, + status = { virtual_text = true }, + output = { open_on_run = true }, + }, + config = function(_, opts) + local neotest_ns = vim.api.nvim_create_namespace("neotest") + vim.diagnostic.config({ + virtual_text = { + format = function(diagnostic) + -- Replace newline and tab characters with space for more compact diagnostics + local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "") + return message + end, + }, + }, neotest_ns) - opts.consumers = opts.consumers or {} - if opts.adapters then - local adapters = {} - for name, config in pairs(opts.adapters or {}) do - if type(name) == "number" then - if type(config) == "string" then - config = require(config) - end - adapters[#adapters + 1] = config - elseif config ~= false then - local adapter = require(name) - if type(config) == "table" and not vim.tbl_isempty(config) then - local meta = getmetatable(adapter) - if adapter.setup then - adapter.setup(config) - elseif meta and meta.__call then - adapter(config) - else - error("Adapter " .. name .. " does not support setup") - end - end - adapters[#adapters + 1] = adapter - end - end - opts.adapters = adapters - end + opts.consumers = opts.consumers or {} + if opts.adapters then + local adapters = {} + for name, config in pairs(opts.adapters or {}) do + if type(name) == "number" then + if type(config) == "string" then + config = require(config) + end + adapters[#adapters + 1] = config + elseif config ~= false then + local adapter = require(name) + if type(config) == "table" and not vim.tbl_isempty(config) then + local meta = getmetatable(adapter) + if adapter.setup then + adapter.setup(config) + elseif meta and meta.__call then + adapter(config) + else + error("Adapter " .. name .. " does not support setup") + end + end + adapters[#adapters + 1] = adapter + end + end + opts.adapters = adapters + end - require("neotest").setup(opts) - end, + require("neotest").setup(opts) + require("pcode.user.npmrun").setup("npm run dev") + end, -- stylua: ignore keys = { { "T","",desc="  Test"}, @@ -111,92 +108,92 @@ local M = { { "TO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, { "TS", function() require("neotest").run.stop() end, desc = "Stop" }, }, - }, - { - "rcarriga/nvim-dap-ui", - lazy = true, - event = "BufRead", - dependencies = { - { "mfussenegger/nvim-dap", lazy = true }, - { "nvim-neotest/nvim-nio", lazy = true }, - { - "mxsdev/nvim-dap-vscode-js", - dependencies = { - "microsoft/vscode-js-debug", - version = "1.x", - build = "npm i && npm run compile vsDebugServerBundle && mv dist out", - }, - config = function() - require("dap-vscode-js").setup({ - -- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node" - debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug", - -- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`. - adapters = { - "chrome", - "pwa-node", - "pwa-chrome", - "pwa-msedge", - "node-terminal", - "pwa-extensionHost", - "node", - "chrome", - }, -- which adapters to register in nvim-dap - -- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging - -- log_file_level = false -- Logging level for output to file. Set to false to disable file logging. - -- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output. - }) - end, - }, - }, - config = function() - require("pcode.user.dapui") - local js_based_languages = { "typescript", "javascript", "typescriptreact" } + }, + { + "rcarriga/nvim-dap-ui", + lazy = true, + event = "BufRead", + dependencies = { + { "mfussenegger/nvim-dap", lazy = true }, + { "nvim-neotest/nvim-nio", lazy = true }, + { + "mxsdev/nvim-dap-vscode-js", + dependencies = { + "microsoft/vscode-js-debug", + version = "1.x", + build = "npm i && npm run compile vsDebugServerBundle && mv dist out", + }, + config = function() + require("dap-vscode-js").setup({ + -- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node" + debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug", + -- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`. + adapters = { + "chrome", + "pwa-node", + "pwa-chrome", + "pwa-msedge", + "node-terminal", + "pwa-extensionHost", + "node", + "chrome", + }, -- which adapters to register in nvim-dap + -- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging + -- log_file_level = false -- Logging level for output to file. Set to false to disable file logging. + -- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output. + }) + end, + }, + }, + config = function() + require("pcode.user.dapui") + local js_based_languages = { "typescript", "javascript", "typescriptreact" } - for _, language in ipairs(js_based_languages) do - require("dap").configurations[language] = { - { - type = "pwa-node", - request = "launch", - name = "Launch file", - program = "${file}", - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "attach", - name = "Attach", - processId = require("dap.utils").pick_process, - cwd = "${workspaceFolder}", - }, - { - type = "pwa-chrome", - request = "launch", - name = 'Start Chrome with "localhost"', - url = "http://localhost:3000", - webRoot = "${workspaceFolder}", - userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir", - }, - } - end - end, - keys = { - { "d", "", desc = "  Debug" }, - { "dt", "lua require'dap'.toggle_breakpoint()", desc = "Toggle Breakpoint" }, - { "db", "lua require'dap'.step_back()", desc = "Step Back" }, - { "dc", "lua require'dap'.continue()", desc = "Continue" }, - { "dC", "lua require'dap'.run_to_cursor()", desc = "Run To Cursor" }, - { "dd", "lua require'dap'.disconnect()", desc = "Disconnect" }, - { "dg", "lua require'dap'.session()", desc = "Get Session" }, - { "di", "lua require'dap'.step_into()", desc = "Step Into" }, - { "do", "lua require'dap'.step_over()", desc = "Step Over" }, - { "du", "lua require'dap'.step_out()", desc = "Step Out" }, - { "dp", "lua require'dap'.pause()", desc = "Pause" }, - { "dr", "lua require'dap'.repl.toggle()", desc = "Toggle Repl" }, - { "ds", "lua require'dap'.continue()", desc = "Start" }, - { "dq", "lua require'dap'.close()", desc = "Quit" }, - { "dU", "lua require'dapui'.toggle({reset = true})", desc = "Toggle UI" }, - }, - }, + for _, language in ipairs(js_based_languages) do + require("dap").configurations[language] = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + { + type = "pwa-node", + request = "attach", + name = "Attach", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + { + type = "pwa-chrome", + request = "launch", + name = 'Start Chrome with "localhost"', + url = "http://localhost:3000", + webRoot = "${workspaceFolder}", + userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir", + }, + } + end + end, + keys = { + { "d", "", desc = "  Debug" }, + { "dt", "lua require'dap'.toggle_breakpoint()", desc = "Toggle Breakpoint" }, + { "db", "lua require'dap'.step_back()", desc = "Step Back" }, + { "dc", "lua require'dap'.continue()", desc = "Continue" }, + { "dC", "lua require'dap'.run_to_cursor()", desc = "Run To Cursor" }, + { "dd", "lua require'dap'.disconnect()", desc = "Disconnect" }, + { "dg", "lua require'dap'.session()", desc = "Get Session" }, + { "di", "lua require'dap'.step_into()", desc = "Step Into" }, + { "do", "lua require'dap'.step_over()", desc = "Step Over" }, + { "du", "lua require'dap'.step_out()", desc = "Step Out" }, + { "dp", "lua require'dap'.pause()", desc = "Pause" }, + { "dr", "lua require'dap'.repl.toggle()", desc = "Toggle Repl" }, + { "ds", "lua require'dap'.continue()", desc = "Start" }, + { "dq", "lua require'dap'.close()", desc = "Quit" }, + { "dU", "lua require'dapui'.toggle({reset = true})", desc = "Toggle UI" }, + }, + }, } return M diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 9bac5ae..d151a30 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -9,7 +9,7 @@ pcode.lang = { java2 = false, java3 = false, java4 = false, - javascript = false, + javascript = true, kotlin = false, markdown = false, php = false, diff --git a/lua/pcode/user/npmrun.lua b/lua/pcode/user/npmrun.lua new file mode 100644 index 0000000..e510cf1 --- /dev/null +++ b/lua/pcode/user/npmrun.lua @@ -0,0 +1,171 @@ +local function open_new_buffer(name) + local buf = vim.api.nvim_create_buf(true, false) + vim.api.nvim_set_current_buf(buf) + vim.api.nvim_buf_set_option(buf, "modifiable", true) + if name then + vim.api.nvim_buf_set_name(buf, name) + end + return buf +end + +local M = {} + +local main_cmd = "npm run dev" -- default + +local function log(message, level) + vim.notify(string.format("npm-dev-runner: %s", message), vim.log.levels[level]) +end + +-- Cache: dir -> { job_id=..., buf=... } +local job_cache = {} + +local function find_cached_dir(dir) + if not dir then + vim.notify("npm-dev-runner: No directory provided to find_cached_dir()", vim.log.levels.ERROR) + return + end + + local cur = dir + while not job_cache[cur] do + if cur == "/" or string.match(cur, "^[A-Z]:\\$") then + return + end + cur = vim.fn.fnamemodify(cur, ":h") + end + return cur +end + +local function is_running(dir) + local cached_dir = find_cached_dir(dir) + return cached_dir and job_cache[cached_dir] +end + +local function is_windows() + return vim.loop.os_uname().version:match("Windows") +end + +M.toggle = function(dir) + local running = is_running(dir) + if not running then + M.start(dir) + return + end + M.stop(dir) +end + +--- Fungsi setup menerima argumen command utama, contoh: require("npmrun").setup("pnpm dev") +M.setup = function(cmd) + main_cmd = cmd or "npm run dev" + if not vim.fn.executable(main_cmd:match("%S+")) then + log(main_cmd .. " is not executable. Make sure it is installed and in PATH.", "ERROR") + return + end + + local function find_dir(args) + local dir = args ~= "" and args or "%:p:h" + return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ":p")) + end + + vim.api.nvim_create_user_command("DevStart", function(opts) + M.start(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command("DevStop", function(opts) + M.stop(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command("DevToggle", function(opts) + M.toggle(find_dir(opts.args)) + end, { nargs = "?" }) +end + +M.start = function(dir) + if is_running(dir) then + log(main_cmd .. " already running", "INFO") + return + end + + local cmd + if is_windows() then + cmd = { "cmd.exe", "/C" } + for word in main_cmd:gmatch("%S+") do + table.insert(cmd, word) + end + else + cmd = {} + for word in main_cmd:gmatch("%S+") do + table.insert(cmd, word) + end + end + + local buffer_name = "npmrun.txt" + local output_buf = open_new_buffer(buffer_name) + vim.api.nvim_buf_set_lines(output_buf, 0, -1, false, {}) + + local function append_to_buffer(lines) + if not lines then + return + end + if not vim.api.nvim_buf_is_valid(output_buf) then + return + end + local filtered = {} + for _, l in ipairs(lines) do + if l ~= "" then + table.insert(filtered, l) + end + end + if #filtered > 0 then + local line_count = vim.api.nvim_buf_line_count(output_buf) + vim.api.nvim_buf_set_lines(output_buf, line_count, line_count, false, filtered) + end + end + + local function close_output_buffer() + if output_buf and vim.api.nvim_buf_is_valid(output_buf) then + vim.api.nvim_buf_delete(output_buf, { force = true }) + end + end + + local job_id = vim.fn.jobstart(cmd, { + cwd = dir, + stdout_buffered = false, -- streaming mode + stderr_buffered = false, + on_stdout = function(_, data) + append_to_buffer(data) + end, + on_stderr = function(_, data) + append_to_buffer(vim.tbl_map(function(l) + return "[ERR] " .. l + end, data)) + end, + on_exit = function(_, code) + append_to_buffer({ string.format(main_cmd .. " exited with code %d", code) }) + close_output_buffer() + job_cache[dir] = nil + end, + }) + + job_cache[dir] = { job_id = job_id, buf = output_buf } + log(main_cmd .. " started", "INFO") +end + +M.stop = function(dir) + local running = is_running(dir) + if running then + local cached_dir = find_cached_dir(dir) + if cached_dir then + local job_entry = job_cache[cached_dir] + if job_entry then + vim.fn.jobstop(job_entry.job_id) + if job_entry.buf and vim.api.nvim_buf_is_valid(job_entry.buf) then + vim.api.nvim_buf_delete(job_entry.buf, { force = true }) + end + end + job_cache[cached_dir] = nil + log(main_cmd .. " stopped", "INFO") + end + end +end + +return M From 23a8cf07bf256ab9aafa6e603440af6f181a8c84 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sun, 22 Jun 2025 00:37:23 +0700 Subject: [PATCH 13/28] enc: add npm runner with popup modal --- lua/pcode/user/npmrun.lua | 75 ++++++++-------- lua/pcode/user/npmrun2.lua | 171 +++++++++++++++++++++++++++++++++++++ 2 files changed, 210 insertions(+), 36 deletions(-) create mode 100644 lua/pcode/user/npmrun2.lua diff --git a/lua/pcode/user/npmrun.lua b/lua/pcode/user/npmrun.lua index e510cf1..79b0724 100644 --- a/lua/pcode/user/npmrun.lua +++ b/lua/pcode/user/npmrun.lua @@ -1,11 +1,31 @@ -local function open_new_buffer(name) - local buf = vim.api.nvim_create_buf(true, false) - vim.api.nvim_set_current_buf(buf) - vim.api.nvim_buf_set_option(buf, "modifiable", true) - if name then - vim.api.nvim_buf_set_name(buf, name) - end - return buf +local function show_modal(text) + local buf = vim.api.nvim_create_buf(false, true) -- buffer untuk modal + + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { text, "", "Press q to close" }) + + local width = 50 + local height = 5 + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = width, + height = height, + row = row, + col = col, + style = "minimal", + border = "rounded", + }) + + -- keymap untuk menutup modal dengan 'q' + vim.api.nvim_buf_set_keymap(buf, "n", "q", "", { + noremap = true, + silent = true, + callback = function() + vim.api.nvim_win_close(win, true) + end, + }) end local M = {} @@ -98,32 +118,20 @@ M.start = function(dir) end end - local buffer_name = "npmrun.txt" - local output_buf = open_new_buffer(buffer_name) - vim.api.nvim_buf_set_lines(output_buf, 0, -1, false, {}) - local function append_to_buffer(lines) if not lines then return end - if not vim.api.nvim_buf_is_valid(output_buf) then - return - end - local filtered = {} - for _, l in ipairs(lines) do - if l ~= "" then - table.insert(filtered, l) - end - end - if #filtered > 0 then - local line_count = vim.api.nvim_buf_line_count(output_buf) - vim.api.nvim_buf_set_lines(output_buf, line_count, line_count, false, filtered) - end - end - local function close_output_buffer() - if output_buf and vim.api.nvim_buf_is_valid(output_buf) then - vim.api.nvim_buf_delete(output_buf, { force = true }) + for _, line in ipairs(lines) do + if line ~= "" then + line = tostring(line) + line = line:gsub("^%s*(.-)%s*$", "%1") + if string.find(line, "http") then + show_modal(line) + break + end + end end end @@ -139,14 +147,12 @@ M.start = function(dir) return "[ERR] " .. l end, data)) end, - on_exit = function(_, code) - append_to_buffer({ string.format(main_cmd .. " exited with code %d", code) }) - close_output_buffer() + on_exit = function(_, _) job_cache[dir] = nil end, }) - job_cache[dir] = { job_id = job_id, buf = output_buf } + job_cache[dir] = { job_id = job_id } log(main_cmd .. " started", "INFO") end @@ -158,9 +164,6 @@ M.stop = function(dir) local job_entry = job_cache[cached_dir] if job_entry then vim.fn.jobstop(job_entry.job_id) - if job_entry.buf and vim.api.nvim_buf_is_valid(job_entry.buf) then - vim.api.nvim_buf_delete(job_entry.buf, { force = true }) - end end job_cache[cached_dir] = nil log(main_cmd .. " stopped", "INFO") diff --git a/lua/pcode/user/npmrun2.lua b/lua/pcode/user/npmrun2.lua new file mode 100644 index 0000000..e510cf1 --- /dev/null +++ b/lua/pcode/user/npmrun2.lua @@ -0,0 +1,171 @@ +local function open_new_buffer(name) + local buf = vim.api.nvim_create_buf(true, false) + vim.api.nvim_set_current_buf(buf) + vim.api.nvim_buf_set_option(buf, "modifiable", true) + if name then + vim.api.nvim_buf_set_name(buf, name) + end + return buf +end + +local M = {} + +local main_cmd = "npm run dev" -- default + +local function log(message, level) + vim.notify(string.format("npm-dev-runner: %s", message), vim.log.levels[level]) +end + +-- Cache: dir -> { job_id=..., buf=... } +local job_cache = {} + +local function find_cached_dir(dir) + if not dir then + vim.notify("npm-dev-runner: No directory provided to find_cached_dir()", vim.log.levels.ERROR) + return + end + + local cur = dir + while not job_cache[cur] do + if cur == "/" or string.match(cur, "^[A-Z]:\\$") then + return + end + cur = vim.fn.fnamemodify(cur, ":h") + end + return cur +end + +local function is_running(dir) + local cached_dir = find_cached_dir(dir) + return cached_dir and job_cache[cached_dir] +end + +local function is_windows() + return vim.loop.os_uname().version:match("Windows") +end + +M.toggle = function(dir) + local running = is_running(dir) + if not running then + M.start(dir) + return + end + M.stop(dir) +end + +--- Fungsi setup menerima argumen command utama, contoh: require("npmrun").setup("pnpm dev") +M.setup = function(cmd) + main_cmd = cmd or "npm run dev" + if not vim.fn.executable(main_cmd:match("%S+")) then + log(main_cmd .. " is not executable. Make sure it is installed and in PATH.", "ERROR") + return + end + + local function find_dir(args) + local dir = args ~= "" and args or "%:p:h" + return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ":p")) + end + + vim.api.nvim_create_user_command("DevStart", function(opts) + M.start(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command("DevStop", function(opts) + M.stop(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command("DevToggle", function(opts) + M.toggle(find_dir(opts.args)) + end, { nargs = "?" }) +end + +M.start = function(dir) + if is_running(dir) then + log(main_cmd .. " already running", "INFO") + return + end + + local cmd + if is_windows() then + cmd = { "cmd.exe", "/C" } + for word in main_cmd:gmatch("%S+") do + table.insert(cmd, word) + end + else + cmd = {} + for word in main_cmd:gmatch("%S+") do + table.insert(cmd, word) + end + end + + local buffer_name = "npmrun.txt" + local output_buf = open_new_buffer(buffer_name) + vim.api.nvim_buf_set_lines(output_buf, 0, -1, false, {}) + + local function append_to_buffer(lines) + if not lines then + return + end + if not vim.api.nvim_buf_is_valid(output_buf) then + return + end + local filtered = {} + for _, l in ipairs(lines) do + if l ~= "" then + table.insert(filtered, l) + end + end + if #filtered > 0 then + local line_count = vim.api.nvim_buf_line_count(output_buf) + vim.api.nvim_buf_set_lines(output_buf, line_count, line_count, false, filtered) + end + end + + local function close_output_buffer() + if output_buf and vim.api.nvim_buf_is_valid(output_buf) then + vim.api.nvim_buf_delete(output_buf, { force = true }) + end + end + + local job_id = vim.fn.jobstart(cmd, { + cwd = dir, + stdout_buffered = false, -- streaming mode + stderr_buffered = false, + on_stdout = function(_, data) + append_to_buffer(data) + end, + on_stderr = function(_, data) + append_to_buffer(vim.tbl_map(function(l) + return "[ERR] " .. l + end, data)) + end, + on_exit = function(_, code) + append_to_buffer({ string.format(main_cmd .. " exited with code %d", code) }) + close_output_buffer() + job_cache[dir] = nil + end, + }) + + job_cache[dir] = { job_id = job_id, buf = output_buf } + log(main_cmd .. " started", "INFO") +end + +M.stop = function(dir) + local running = is_running(dir) + if running then + local cached_dir = find_cached_dir(dir) + if cached_dir then + local job_entry = job_cache[cached_dir] + if job_entry then + vim.fn.jobstop(job_entry.job_id) + if job_entry.buf and vim.api.nvim_buf_is_valid(job_entry.buf) then + vim.api.nvim_buf_delete(job_entry.buf, { force = true }) + end + end + job_cache[cached_dir] = nil + log(main_cmd .. " stopped", "INFO") + end + end +end + +return M From 7450625ba86949afbe5932bbe7798a4d5a2b75a1 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sun, 22 Jun 2025 08:43:35 +0700 Subject: [PATCH 14/28] enc: update modal npm runner --- lua/pcode/plugins/conform.lua | 79 +++---- lua/pcode/plugins/lang/javascript.lua | 21 +- lua/pcode/plugins/notify.lua | 1 + lua/pcode/user/npmrun.lua | 316 ++++++++++++++++---------- lua/pcode/user/npmrun3.lua | 174 ++++++++++++++ lua/pcode/user/npmrun4.lua | 158 +++++++++++++ 6 files changed, 588 insertions(+), 161 deletions(-) create mode 100644 lua/pcode/user/npmrun3.lua create mode 100644 lua/pcode/user/npmrun4.lua diff --git a/lua/pcode/plugins/conform.lua b/lua/pcode/plugins/conform.lua index a674af9..7d4d5a3 100644 --- a/lua/pcode/plugins/conform.lua +++ b/lua/pcode/plugins/conform.lua @@ -1,40 +1,43 @@ return { - "pojokcodeid/auto-conform.nvim", - dependencies = { - "williamboman/mason.nvim", - "stevearc/conform.nvim", - }, - event = "VeryLazy", - opts = function(_, opts) - opts.formatters = opts.formatters or {} - opts.formatters_by_ft = opts.formatters_by_ft or {} - opts.ensure_installed = opts.ensure_installed or {} - -- vim.list_extend(opts.ensure_installed, { "stylua" }) - opts.lang_maps = opts.lang_maps or {} - opts.name_maps = opts.name_maps or {} - opts.add_new = opts.add_new or {} - opts.ignore = opts.ignore or {} - opts.format_on_save = opts.format_on_save or true - opts.format_timeout_ms = opts.format_timeout_ms or 5000 - end, - config = function(_, opts) - require("auto-conform").setup(opts) - -- other conform config - local conform = require("conform") - if opts.format_on_save then - conform.setup({ - format_on_save = { - lsp_fallback = true, - timeout_ms = opts.format_timeout_ms or 5000, - }, - }) - end - vim.keymap.set({ "n", "v" }, "lF", function() - conform.format({ - lsp_fallback = true, - async = false, - timeout_ms = opts.format_timeout_ms or 5000, - }) - end, { desc = "Format file or range (in visual mode)" }) - end, + "pojokcodeid/auto-conform.nvim", + dependencies = { + "williamboman/mason.nvim", + "stevearc/conform.nvim", + }, + event = "VeryLazy", + opts = function(_, opts) + opts.formatters = opts.formatters or {} + opts.formatters_by_ft = opts.formatters_by_ft or {} + opts.ensure_installed = opts.ensure_installed or {} + -- vim.list_extend(opts.ensure_installed, { "stylua" }) + opts.lang_maps = opts.lang_maps or {} + opts.name_maps = opts.name_maps or {} + opts.add_new = opts.add_new or {} + opts.ignore = opts.ignore or {} + opts.format_on_save = opts.format_on_save or true + opts.format_timeout_ms = opts.format_timeout_ms or 5000 + end, + config = function(_, opts) + require("auto-conform").setup(opts) + -- other conform config + local conform = require("conform") + if opts.format_on_save then + conform.setup({ + format_on_save = { + lsp_fallback = true, + timeout_ms = opts.format_timeout_ms or 5000, + }, + }) + end + vim.keymap.set({ "n", "v" }, "lF", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = opts.format_timeout_ms or 5000, + }) + end, { desc = "Format file or range (in visual mode)" }) + end, + keys = { + { "l", "", desc = " 󰘦 Lsp" }, + }, } diff --git a/lua/pcode/plugins/lang/javascript.lua b/lua/pcode/plugins/lang/javascript.lua index fd637a3..271f8bc 100644 --- a/lua/pcode/plugins/lang/javascript.lua +++ b/lua/pcode/plugins/lang/javascript.lua @@ -94,10 +94,29 @@ local M = { end require("neotest").setup(opts) - require("pcode.user.npmrun").setup("npm run dev") + local command = pcode.npm_commad + or { + dev = { + start = "NpmRunDev", + stop = "NpmStopDev", + cmd = "npm run dev", + }, + prod = { + start = "NpmStart", + stop = "NpmStop", + cmd = "npm start", + }, + } + require("pcode.user.npmrun").setup(command, { + show_mapping = "nm", + hide_mapping = "nh", + width = 70, + height = 20, + }) end, -- stylua: ignore keys = { + {"n","",desc="  Npm"}, { "T","",desc="  Test"}, { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, { "Tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, diff --git a/lua/pcode/plugins/notify.lua b/lua/pcode/plugins/notify.lua index ba74835..9030dec 100644 --- a/lua/pcode/plugins/notify.lua +++ b/lua/pcode/plugins/notify.lua @@ -3,6 +3,7 @@ return { lazy = true, event = "VeryLazy", keys = { + { "u", "", desc = " 󰀦 Notify" }, { "uN", function() diff --git a/lua/pcode/user/npmrun.lua b/lua/pcode/user/npmrun.lua index 79b0724..495468a 100644 --- a/lua/pcode/user/npmrun.lua +++ b/lua/pcode/user/npmrun.lua @@ -1,52 +1,112 @@ -local function show_modal(text) - local buf = vim.api.nvim_create_buf(false, true) -- buffer untuk modal +local last_modal = nil -- global modal manager instance - vim.api.nvim_buf_set_lines(buf, 0, -1, false, { text, "", "Press q to close" }) +local function modal_manager(opts) + opts = opts or {} + local win_id = nil + local buf_id = nil + local last_content = "" + local is_shown = false - local width = 50 - local height = 5 - local row = math.floor((vim.o.lines - height) / 2) - local col = math.floor((vim.o.columns - width) / 2) + local function close() + if win_id and vim.api.nvim_win_is_valid(win_id) then + vim.api.nvim_win_close(win_id, true) + win_id = nil + end + is_shown = false + end - local win = vim.api.nvim_open_win(buf, true, { - relative = "editor", - width = width, - height = height, - row = row, - col = col, - style = "minimal", - border = "rounded", - }) + local function open(content) + local lines = vim.split(content or "", "\n") + local width = opts.width or 70 + local height = math.min(opts.height or 15, #lines + 6) + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + if not buf_id or not vim.api.nvim_buf_is_valid(buf_id) then + buf_id = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_keymap(buf_id, "n", "q", "", { + noremap = true, + silent = true, + callback = function() + close() + end, + }) + end + -- Pastikan buffer modifiable sebelum update, abaikan jika error (buffer deleted) + pcall(vim.api.nvim_buf_set_option, buf_id, "modifiable", true) + pcall(vim.api.nvim_buf_set_lines, buf_id, 0, -1, false, lines) + pcall(vim.api.nvim_buf_set_option, buf_id, "modifiable", false) + if not win_id or not vim.api.nvim_win_is_valid(win_id) then + win_id = vim.api.nvim_open_win(buf_id, true, { + relative = "editor", + width = width, + height = height, + row = row, + col = col, + style = "minimal", + border = "rounded", + }) + end + is_shown = true + end - -- keymap untuk menutup modal dengan 'q' - vim.api.nvim_buf_set_keymap(buf, "n", "q", "", { - noremap = true, - silent = true, - callback = function() - vim.api.nvim_win_close(win, true) + local function show() + if is_shown then + return + end + if last_content ~= "" then + open(last_content) + end + end + + local function hide() + close() + end + + local function update(content) + last_content = content + if is_shown and buf_id and vim.api.nvim_buf_is_valid(buf_id) then + local lines = vim.split(content or "", "\n") + pcall(vim.api.nvim_buf_set_option, buf_id, "modifiable", true) + pcall(vim.api.nvim_buf_set_lines, buf_id, 0, -1, false, lines) + pcall(vim.api.nvim_buf_set_option, buf_id, "modifiable", false) + end + end + + local function set_content(content) + last_content = content + if is_shown then + update(content) + else + open(content) + end + end + + return { + show = show, + hide = hide, + update = update, + close = close, + set_content = set_content, + is_shown = function() + return is_shown end, - }) + } end local M = {} - -local main_cmd = "npm run dev" -- default +M._last_modal = nil local function log(message, level) vim.notify(string.format("npm-dev-runner: %s", message), vim.log.levels[level]) end --- Cache: dir -> { job_id=..., buf=... } -local job_cache = {} - -local function find_cached_dir(dir) +local function find_cached_dir(dir, cache) if not dir then vim.notify("npm-dev-runner: No directory provided to find_cached_dir()", vim.log.levels.ERROR) return end - local cur = dir - while not job_cache[cur] do + while not cache[cur] do if cur == "/" or string.match(cur, "^[A-Z]:\\$") then return end @@ -55,119 +115,131 @@ local function find_cached_dir(dir) return cur end -local function is_running(dir) - local cached_dir = find_cached_dir(dir) - return cached_dir and job_cache[cached_dir] +local function is_running(dir, cache) + local cached_dir = find_cached_dir(dir, cache) + return cached_dir and cache[cached_dir] end local function is_windows() return vim.loop.os_uname().version:match("Windows") end -M.toggle = function(dir) - local running = is_running(dir) - if not running then - M.start(dir) - return - end - M.stop(dir) -end +local default_opts = { + show_mapping = "nm", + hide_mapping = "nh", +} ---- Fungsi setup menerima argumen command utama, contoh: require("npmrun").setup("pnpm dev") -M.setup = function(cmd) - main_cmd = cmd or "npm run dev" - if not vim.fn.executable(main_cmd:match("%S+")) then - log(main_cmd .. " is not executable. Make sure it is installed and in PATH.", "ERROR") - return +M.setup = function(command_table, opts) + opts = vim.tbl_deep_extend("force", {}, default_opts, opts or {}) + command_table = command_table or {} + + -- Keymap global, pakai modal terakhir yang aktif + if opts.show_mapping then + vim.keymap.set("n", opts.show_mapping, function() + if last_modal then + last_modal.show() + end + end, { desc = "Show last NPM modal output" }) + end + if opts.hide_mapping then + vim.keymap.set("n", opts.hide_mapping, function() + if last_modal then + last_modal.hide() + end + end, { desc = "Hide last NPM modal output" }) end - local function find_dir(args) - local dir = args ~= "" and args or "%:p:h" - return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ":p")) - end + for key, conf in pairs(command_table) do + local start_cmd = conf.start or ("NpmRun" .. key) + local stop_cmd = conf.stop or ("NpmStop" .. key) + local cmd_str = conf.cmd or "npm run dev" + local cache = {} - vim.api.nvim_create_user_command("DevStart", function(opts) - M.start(find_dir(opts.args)) - end, { nargs = "?" }) + local function do_start(dir) + if is_running(dir, cache) then + log(cmd_str .. " already running", "INFO") + return + end - vim.api.nvim_create_user_command("DevStop", function(opts) - M.stop(find_dir(opts.args)) - end, { nargs = "?" }) + local all_output = {} + local modal = modal_manager(opts) + last_modal = modal + M._last_modal = modal - vim.api.nvim_create_user_command("DevToggle", function(opts) - M.toggle(find_dir(opts.args)) - end, { nargs = "?" }) -end + local cmd + if is_windows() then + cmd = { "cmd.exe", "/C" } + for word in cmd_str:gmatch("%S+") do + table.insert(cmd, word) + end + else + cmd = {} + for word in cmd_str:gmatch("%S+") do + table.insert(cmd, word) + end + end -M.start = function(dir) - if is_running(dir) then - log(main_cmd .. " already running", "INFO") - return - end + local function process_lines(lines) + if not lines then + return + end + for _, l in ipairs(lines) do + table.insert(all_output, tostring(l)) + end + modal.set_content(table.concat(all_output, "\n")) + end - local cmd - if is_windows() then - cmd = { "cmd.exe", "/C" } - for word in main_cmd:gmatch("%S+") do - table.insert(cmd, word) - end - else - cmd = {} - for word in main_cmd:gmatch("%S+") do - table.insert(cmd, word) - end - end + local job_id = vim.fn.jobstart(cmd, { + cwd = dir, + stdout_buffered = false, + stderr_buffered = false, + on_stdout = function(_, data) + process_lines(data) + end, + on_stderr = function(_, data) + process_lines(data) + end, + on_exit = function(_, code) + table.insert(all_output, ("Process exited with code: %d"):format(code)) + modal.set_content(table.concat(all_output, "\n")) + cache[dir] = nil + end, + }) - local function append_to_buffer(lines) - if not lines then - return + cache[dir] = { job_id = job_id, modal = modal } + log(cmd_str .. " started", "INFO") end - for _, line in ipairs(lines) do - if line ~= "" then - line = tostring(line) - line = line:gsub("^%s*(.-)%s*$", "%1") - if string.find(line, "http") then - show_modal(line) - break + local function do_stop(dir) + local running = is_running(dir, cache) + if running then + local cached_dir = find_cached_dir(dir, cache) + if cached_dir then + local job_entry = cache[cached_dir] + if job_entry then + vim.fn.jobstop(job_entry.job_id) + if job_entry.modal then + job_entry.modal.close() + end + end + cache[cached_dir] = nil + log(cmd_str .. " stopped", "INFO") end end end - end - local job_id = vim.fn.jobstart(cmd, { - cwd = dir, - stdout_buffered = false, -- streaming mode - stderr_buffered = false, - on_stdout = function(_, data) - append_to_buffer(data) - end, - on_stderr = function(_, data) - append_to_buffer(vim.tbl_map(function(l) - return "[ERR] " .. l - end, data)) - end, - on_exit = function(_, _) - job_cache[dir] = nil - end, - }) - - job_cache[dir] = { job_id = job_id } - log(main_cmd .. " started", "INFO") -end - -M.stop = function(dir) - local running = is_running(dir) - if running then - local cached_dir = find_cached_dir(dir) - if cached_dir then - local job_entry = job_cache[cached_dir] - if job_entry then - vim.fn.jobstop(job_entry.job_id) - end - job_cache[cached_dir] = nil - log(main_cmd .. " stopped", "INFO") + local function find_dir(args) + local dir = args ~= "" and args or "%:p:h" + return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ":p")) end + + vim.api.nvim_create_user_command(start_cmd, function(opts) + do_start(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command(stop_cmd, function(opts) + do_stop(find_dir(opts.args)) + end, { nargs = "?" }) end end diff --git a/lua/pcode/user/npmrun3.lua b/lua/pcode/user/npmrun3.lua new file mode 100644 index 0000000..79b0724 --- /dev/null +++ b/lua/pcode/user/npmrun3.lua @@ -0,0 +1,174 @@ +local function show_modal(text) + local buf = vim.api.nvim_create_buf(false, true) -- buffer untuk modal + + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { text, "", "Press q to close" }) + + local width = 50 + local height = 5 + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = width, + height = height, + row = row, + col = col, + style = "minimal", + border = "rounded", + }) + + -- keymap untuk menutup modal dengan 'q' + vim.api.nvim_buf_set_keymap(buf, "n", "q", "", { + noremap = true, + silent = true, + callback = function() + vim.api.nvim_win_close(win, true) + end, + }) +end + +local M = {} + +local main_cmd = "npm run dev" -- default + +local function log(message, level) + vim.notify(string.format("npm-dev-runner: %s", message), vim.log.levels[level]) +end + +-- Cache: dir -> { job_id=..., buf=... } +local job_cache = {} + +local function find_cached_dir(dir) + if not dir then + vim.notify("npm-dev-runner: No directory provided to find_cached_dir()", vim.log.levels.ERROR) + return + end + + local cur = dir + while not job_cache[cur] do + if cur == "/" or string.match(cur, "^[A-Z]:\\$") then + return + end + cur = vim.fn.fnamemodify(cur, ":h") + end + return cur +end + +local function is_running(dir) + local cached_dir = find_cached_dir(dir) + return cached_dir and job_cache[cached_dir] +end + +local function is_windows() + return vim.loop.os_uname().version:match("Windows") +end + +M.toggle = function(dir) + local running = is_running(dir) + if not running then + M.start(dir) + return + end + M.stop(dir) +end + +--- Fungsi setup menerima argumen command utama, contoh: require("npmrun").setup("pnpm dev") +M.setup = function(cmd) + main_cmd = cmd or "npm run dev" + if not vim.fn.executable(main_cmd:match("%S+")) then + log(main_cmd .. " is not executable. Make sure it is installed and in PATH.", "ERROR") + return + end + + local function find_dir(args) + local dir = args ~= "" and args or "%:p:h" + return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ":p")) + end + + vim.api.nvim_create_user_command("DevStart", function(opts) + M.start(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command("DevStop", function(opts) + M.stop(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command("DevToggle", function(opts) + M.toggle(find_dir(opts.args)) + end, { nargs = "?" }) +end + +M.start = function(dir) + if is_running(dir) then + log(main_cmd .. " already running", "INFO") + return + end + + local cmd + if is_windows() then + cmd = { "cmd.exe", "/C" } + for word in main_cmd:gmatch("%S+") do + table.insert(cmd, word) + end + else + cmd = {} + for word in main_cmd:gmatch("%S+") do + table.insert(cmd, word) + end + end + + local function append_to_buffer(lines) + if not lines then + return + end + + for _, line in ipairs(lines) do + if line ~= "" then + line = tostring(line) + line = line:gsub("^%s*(.-)%s*$", "%1") + if string.find(line, "http") then + show_modal(line) + break + end + end + end + end + + local job_id = vim.fn.jobstart(cmd, { + cwd = dir, + stdout_buffered = false, -- streaming mode + stderr_buffered = false, + on_stdout = function(_, data) + append_to_buffer(data) + end, + on_stderr = function(_, data) + append_to_buffer(vim.tbl_map(function(l) + return "[ERR] " .. l + end, data)) + end, + on_exit = function(_, _) + job_cache[dir] = nil + end, + }) + + job_cache[dir] = { job_id = job_id } + log(main_cmd .. " started", "INFO") +end + +M.stop = function(dir) + local running = is_running(dir) + if running then + local cached_dir = find_cached_dir(dir) + if cached_dir then + local job_entry = job_cache[cached_dir] + if job_entry then + vim.fn.jobstop(job_entry.job_id) + end + job_cache[cached_dir] = nil + log(main_cmd .. " stopped", "INFO") + end + end +end + +return M diff --git a/lua/pcode/user/npmrun4.lua b/lua/pcode/user/npmrun4.lua new file mode 100644 index 0000000..1c8c4f1 --- /dev/null +++ b/lua/pcode/user/npmrun4.lua @@ -0,0 +1,158 @@ +local function show_modal(text) + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(buf, 0, -1, false, { text, "", "Press q to close" }) + + local width = 50 + local height = 5 + local row = math.floor((vim.o.lines - height) / 2) + local col = math.floor((vim.o.columns - width) / 2) + + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = width, + height = height, + row = row, + col = col, + style = "minimal", + border = "rounded", + }) + + vim.api.nvim_buf_set_keymap(buf, "n", "q", "", { + noremap = true, + silent = true, + callback = function() + vim.api.nvim_win_close(win, true) + end, + }) +end + +local M = {} + +local function log(message, level) + vim.notify(string.format("npm-dev-runner: %s", message), vim.log.levels[level]) +end + +-- Fungsi untuk mencari cache dir (supaya stop/start tetap per dir/project) +local function find_cached_dir(dir, cache) + if not dir then + vim.notify("npm-dev-runner: No directory provided to find_cached_dir()", vim.log.levels.ERROR) + return + end + local cur = dir + while not cache[cur] do + if cur == "/" or string.match(cur, "^[A-Z]:\\$") then + return + end + cur = vim.fn.fnamemodify(cur, ":h") + end + return cur +end + +-- Fungsi cek proses running +local function is_running(dir, cache) + local cached_dir = find_cached_dir(dir, cache) + return cached_dir and cache[cached_dir] +end + +local function is_windows() + return vim.loop.os_uname().version:match("Windows") +end + +M.setup = function(command_table) + command_table = command_table or {} + for key, conf in pairs(command_table) do + local start_cmd = conf.start or ("NpmRun" .. key) + local stop_cmd = conf.stop or ("NpmStop" .. key) + local cmd_str = conf.cmd or "npm run dev" + + -- cache khusus untuk mode ini + local cache = {} + + -- Fungsi Start + local function do_start(dir) + if is_running(dir, cache) then + log(cmd_str .. " already running", "INFO") + return + end + + local cmd + if is_windows() then + cmd = { "cmd.exe", "/C" } + for word in cmd_str:gmatch("%S+") do + table.insert(cmd, word) + end + else + cmd = {} + for word in cmd_str:gmatch("%S+") do + table.insert(cmd, word) + end + end + + local function process_lines(lines) + if not lines then + return + end + for _, line in ipairs(lines) do + if line ~= "" then + local str = tostring(line):gsub("^%s*(.-)%s*$", "%1") + if string.find(str, "http") then + show_modal(str) + end + end + end + end + + local job_id = vim.fn.jobstart(cmd, { + cwd = dir, + stdout_buffered = false, + stderr_buffered = false, + on_stdout = function(_, data) + process_lines(data) + end, + on_stderr = function(_, data) + process_lines(vim.tbl_map(function(l) + return "[ERR] " .. l + end, data)) + end, + on_exit = function(_, _) + cache[dir] = nil + end, + }) + + cache[dir] = { job_id = job_id } + log(cmd_str .. " started", "INFO") + end + + -- Fungsi Stop + local function do_stop(dir) + local running = is_running(dir, cache) + if running then + local cached_dir = find_cached_dir(dir, cache) + if cached_dir then + local job_entry = cache[cached_dir] + if job_entry then + vim.fn.jobstop(job_entry.job_id) + end + cache[cached_dir] = nil + log(cmd_str .. " stopped", "INFO") + end + end + end + + local function find_dir(args) + local dir = args ~= "" and args or "%:p:h" + return vim.fn.expand(vim.fn.fnamemodify(vim.fn.expand(dir), ":p")) + end + + -- Register Perintah + vim.api.nvim_create_user_command(start_cmd, function(opts) + do_start(find_dir(opts.args)) + end, { nargs = "?" }) + + vim.api.nvim_create_user_command(stop_cmd, function(opts) + do_stop(find_dir(opts.args)) + end, { nargs = "?" }) + end +end + +return M From 339f818e4a6b4cbfd052217963104a236d114131 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sun, 22 Jun 2025 18:29:49 +0700 Subject: [PATCH 15/28] add: user command for runner cmd --- lazy-lock.json | 3 +- lua/pcode/plugins/lang/javascript.lua | 73 +++++++++++++++++++-------- lua/pcode/user/npmrun.lua | 24 +++++++-- 3 files changed, 75 insertions(+), 25 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 9b8df1b..70ecf68 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -26,7 +26,7 @@ "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "f54e3c11fc9ebfcfc27e696182b0295b071d0811" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, @@ -38,6 +38,7 @@ "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, + "npm-runner.nvim": { "branch": "main", "commit": "4acc407e07e16eb42e356b10bc17886b21744606" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, diff --git a/lua/pcode/plugins/lang/javascript.lua b/lua/pcode/plugins/lang/javascript.lua index 271f8bc..25b8585 100644 --- a/lua/pcode/plugins/lang/javascript.lua +++ b/lua/pcode/plugins/lang/javascript.lua @@ -94,29 +94,28 @@ local M = { end require("neotest").setup(opts) - local command = pcode.npm_commad - or { - dev = { - start = "NpmRunDev", - stop = "NpmStopDev", - cmd = "npm run dev", - }, - prod = { - start = "NpmStart", - stop = "NpmStop", - cmd = "npm start", - }, - } - require("pcode.user.npmrun").setup(command, { - show_mapping = "nm", - hide_mapping = "nh", - width = 70, - height = 20, - }) + -- local command = pcode.npm_commad + -- or { + -- dev = { + -- start = "NpmRunDev", + -- stop = "NpmStopDev", + -- cmd = "npm run dev", + -- }, + -- prod = { + -- start = "NpmStart", + -- stop = "NpmStop", + -- cmd = "npm start", + -- }, + -- } + -- require("pcode.user.npmrun").setup(command, { + -- show_mapping = "nm", + -- hide_mapping = "nh", + -- width = 70, + -- height = 20, + -- }) end, -- stylua: ignore keys = { - {"n","",desc="  Npm"}, { "T","",desc="  Test"}, { "Tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, { "Tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, @@ -128,6 +127,40 @@ local M = { { "TS", function() require("neotest").run.stop() end, desc = "Stop" }, }, }, + { + "pojokcodeid/npm-runner.nvim", + event = "VeryLazy", + dependencies = { + "rcarriga/nvim-notify", + }, + -- your opts go here + opts = { + command = { + dev = { + start = "NpmRunDev", + stop = "NpmStopDev", + cmd = "npm run dev", + }, + prod = { + start = "NpmStart", + stop = "NpmStop", + cmd = "npm start", + }, + }, + opt = { + show_mapping = "nm", + hide_mapping = "nh", + width = 70, + height = 20, + }, + }, + keys = { + { "n", "", desc = "  Npm" }, + }, + config = function(_, opts) + require("npm-runner").setup(opts.command, opts.opt) + end, + }, { "rcarriga/nvim-dap-ui", lazy = true, diff --git a/lua/pcode/user/npmrun.lua b/lua/pcode/user/npmrun.lua index 495468a..ab88fb7 100644 --- a/lua/pcode/user/npmrun.lua +++ b/lua/pcode/user/npmrun.lua @@ -6,6 +6,7 @@ local function modal_manager(opts) local buf_id = nil local last_content = "" local is_shown = false + local ever_shown = false local function close() if win_id and vim.api.nvim_win_is_valid(win_id) then @@ -31,7 +32,6 @@ local function modal_manager(opts) end, }) end - -- Pastikan buffer modifiable sebelum update, abaikan jika error (buffer deleted) pcall(vim.api.nvim_buf_set_option, buf_id, "modifiable", true) pcall(vim.api.nvim_buf_set_lines, buf_id, 0, -1, false, lines) pcall(vim.api.nvim_buf_set_option, buf_id, "modifiable", false) @@ -47,6 +47,7 @@ local function modal_manager(opts) }) end is_shown = true + ever_shown = true end local function show() @@ -72,13 +73,15 @@ local function modal_manager(opts) end end + -- Hanya auto open saat pertama kali, tidak auto open setelah pernah di-close/hide local function set_content(content) last_content = content - if is_shown then - update(content) - else + if not ever_shown then open(content) + elseif is_shown then + update(content) end + -- jika ever_shown dan !is_shown, cukup simpan output saja end return { @@ -149,6 +152,19 @@ M.setup = function(command_table, opts) end, { desc = "Hide last NPM modal output" }) end + -- Tambah user command global untuk show/hide modal + vim.api.nvim_create_user_command("NpmModalShow", function() + if last_modal then + last_modal.show() + end + end, { desc = "Show last NPM modal output" }) + + vim.api.nvim_create_user_command("NpmModalHide", function() + if last_modal then + last_modal.hide() + end + end, { desc = "Hide last NPM modal output" }) + for key, conf in pairs(command_table) do local start_cmd = conf.start or ("NpmRun" .. key) local stop_cmd = conf.stop or ("NpmStop" .. key) From 68cf1f8bc4670bc2dfd19ea03a931ed75d0cc25a Mon Sep 17 00:00:00 2001 From: pojok code Date: Sun, 22 Jun 2025 18:48:16 +0700 Subject: [PATCH 16/28] enc: add user command OpenBrowser --- lua/pcode/user/autocmd.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lua/pcode/user/autocmd.lua b/lua/pcode/user/autocmd.lua index b2eacb0..54cccc1 100644 --- a/lua/pcode/user/autocmd.lua +++ b/lua/pcode/user/autocmd.lua @@ -355,3 +355,33 @@ end -- Create command vim.api.nvim_create_user_command("LspInfo2", lsp_info, { desc = "Show comprehensive LSP information" }) + +vim.api.nvim_create_user_command("OpenBrowser", function(opts) + local url = opts.args + -- Jika tidak ada URL, pakai about:blank sebagai default + if url == "" then + url = "http://google.com" + end + + -- Deteksi jika dijalankan di WSL + local is_wsl = vim.fn.system("uname -r"):find("WSL") + if is_wsl then + vim.fn.jobstart({ "/mnt/c/Windows/System32/cmd.exe", "/c", "start", url }, { detach = true }) + return + end + + -- Jika bukan WSL, gunakan cara biasa + local open_cmd + if vim.fn.has("mac") == 1 then + open_cmd = "open" + elseif vim.fn.has("unix") == 1 then + open_cmd = "xdg-open" + elseif vim.fn.has("win32") == 1 then + open_cmd = "start" + else + print("OS tidak didukung.") + return + end + + vim.fn.jobstart({ open_cmd, url }, { detach = true }) +end, { nargs = "?", complete = "file" }) From 82392943e240917774a01a8d016721a73ff4f53a Mon Sep 17 00:00:00 2001 From: pojok code Date: Thu, 26 Jun 2025 19:06:22 +0700 Subject: [PATCH 17/28] enc: add create go project whijart --- lazy-lock.json | 7 +- lua/pcode/plugins/lang/golang.lua | 221 ++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+), 3 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 70ecf68..729ae58 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -32,7 +32,7 @@ "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, - "neotest": { "branch": "master", "commit": "ef492755730e59e1d8122c461abbd086bee4c76b" }, + "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, "neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" }, "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, @@ -49,11 +49,11 @@ "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "69a1624aff5dc30dddd0c59d99a947b63c80bf2a" }, + "nvim-lspconfig": { "branch": "master", "commit": "6bba673aa8993eceec233be17b42ddfb9540794b" }, "nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, + "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, "nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" }, "nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, @@ -69,6 +69,7 @@ "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "transparent.nvim": { "branch": "main", "commit": "8ac59883de84e9cd1850ea25cf087031c5ba7d54" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, diff --git a/lua/pcode/plugins/lang/golang.lua b/lua/pcode/plugins/lang/golang.lua index a5cf93c..4c277ac 100644 --- a/lua/pcode/plugins/lang/golang.lua +++ b/lua/pcode/plugins/lang/golang.lua @@ -51,6 +51,227 @@ return { go_runner:toggle() end, {}) + + -- Fungsi untuk membuat proyek Go + local function go_new_project() + local function create_notif(message, level) + local notif_ok, notify = pcall(require, "notify") + if notif_ok then + notify(message, level) + else + print(message) + end + end + + local function get_user_input(prompt, default_value) + vim.fn.inputsave() + local result = vim.fn.input(prompt, default_value) + vim.fn.inputrestore() + + if result == "" then + create_notif("Input canceled.", "info") + return nil, true + end + return result, false + end + + local project_name, canceled = get_user_input("Enter project name: ", "myapp") + if canceled then + return + end + + local file_name, canceled = get_user_input("Enter file name (without .go): ", "main") + if canceled then + return + end + + local function_name, canceled = get_user_input("Enter function name: ", "main") + if canceled then + return + end + + local cwd = vim.fn.getcwd() + local project_path = cwd .. "/" .. project_name + if vim.fn.isdirectory(project_path) == 1 then + create_notif("Project directory already exists: " .. project_path, "error") + return + end + + local mkdir_cmd = string.format("mkdir -p '%s'", project_path) + local gomod_cmd = string.format("cd '%s' && go mod init %s", project_path, project_name) + local entry_file = string.format("%s/%s.go", project_path, file_name) + local main_code = string.format( + [[ +package main + +import "fmt" + +func %s() { + fmt.Println("Hello, world!") +} +]], + function_name + ) + + vim.fn.system(mkdir_cmd) + vim.fn.system(gomod_cmd) + + local file = io.open(entry_file, "w") + if file then + file:write(main_code) + file:close() + create_notif("Go project created at " .. project_path, "info") + vim.cmd("cd " .. project_path) + + -- Jika ada NvimTreeOpen, jalankan lalu kembalikan fokus ke file + if vim.fn.exists(":NvimTreeOpen") == 2 then + vim.cmd("NvimTreeOpen") + -- Penjadwalan agar kembali ke buffer file Go setelah NvimTree terbuka + vim.schedule(function() + vim.cmd("edit " .. entry_file) + -- Cari baris function + local lines = {} + for line in main_code:gmatch("([^\n]*)\n?") do + table.insert(lines, line) + end + local func_line = 1 + for i, line in ipairs(lines) do + if line:find("func%s+" .. function_name .. "%s*%(") then + func_line = i + break + end + end + local target_line = func_line + 1 + vim.api.nvim_win_set_cursor(0, { target_line, 4 }) + vim.cmd("startinsert") + end) + else + vim.cmd("edit " .. entry_file) + local lines = {} + for line in main_code:gmatch("([^\n]*)\n?") do + table.insert(lines, line) + end + local func_line = 1 + for i, line in ipairs(lines) do + if line:find("func%s+" .. function_name .. "%s*%(") then + func_line = i + break + end + end + local target_line = func_line + 1 + vim.api.nvim_win_set_cursor(0, { target_line, 4 }) + vim.cmd("startinsert") + end + else + create_notif("Failed to create file: " .. entry_file, "error") + end + end + + vim.api.nvim_create_user_command("GoNewProject", go_new_project, {}) + + -- Fungsi untuk membuat file Go + local function go_new_file() + local function create_notif(message, level) + local notif_ok, notify = pcall(require, "notify") + if notif_ok then + notify(message, level) + else + print(message) + end + end + + local function get_user_input(prompt, default_value) + vim.fn.inputsave() + local result = vim.fn.input(prompt, default_value) + vim.fn.inputrestore() + if result == "" then + create_notif("Input canceled.", "info") + return nil, true + end + return result, false + end + + -- Ambil nama folder + local folder_name, canceled = get_user_input("Enter folder name (dot for current folder): ", ".") + if canceled then + return + end + + -- Ambil nama file (tanpa .go) + local file_name, canceled = get_user_input("Enter file name (without .go): ", "newfile") + if canceled then + return + end + + -- Ambil nama package + local package_name, canceled = get_user_input("Enter package name: ", "main") + if canceled then + return + end + + -- Ambil nama function + local function_name, canceled = get_user_input("Enter function name: ", "main") + if canceled then + return + end + + local cwd = vim.fn.getcwd() + local folder_path = (folder_name == "." or folder_name == "") and cwd or cwd .. "/" .. folder_name + + -- Cek dan buat folder jika perlu + if vim.fn.isdirectory(folder_path) == 0 then + local mkdir_cmd = string.format("mkdir -p '%s'", folder_path) + vim.fn.system(mkdir_cmd) + end + + local file_path = string.format("%s/%s.go", folder_path, file_name) + + if vim.fn.filereadable(file_path) == 1 then + create_notif("File already exists: " .. file_path, "error") + return + end + + local code = string.format( + [[ +package %s + +func %s() { + +} +]], + package_name, + function_name + ) + + -- Buat file dan isi konten + local file = io.open(file_path, "w") + if file then + file:write(code) + file:close() + create_notif("Go file created: " .. file_path, "info") + + -- Buka file dan tempatkan kursor di bawah function, mode insert + vim.cmd("edit " .. file_path) + local lines = {} + for line in code:gmatch("([^\n]*)\n?") do + table.insert(lines, line) + end + local func_line = 1 + for i, line in ipairs(lines) do + if line:find("func%s+" .. function_name .. "%s*%(") then + func_line = i + break + end + end + local target_line = func_line + 1 + vim.api.nvim_win_set_cursor(0, { target_line, 4 }) + vim.cmd("startinsert") + else + create_notif("Failed to create file: " .. file_path, "error") + end + end + + vim.api.nvim_create_user_command("GoNewFile", go_new_file, {}) end, }, { From bf0a8b2f9b0530a38cc4f696ab4fc91b886791ae Mon Sep 17 00:00:00 2001 From: pojok code Date: Thu, 26 Jun 2025 21:58:09 +0700 Subject: [PATCH 18/28] enc: add user command for create new project javascript --- lazy-lock.json | 3 +- lua/pcode/plugins/lang/javascript.lua | 214 ++++++++++++++++++++++++++ 2 files changed, 215 insertions(+), 2 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 729ae58..0040d49 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -50,7 +50,7 @@ "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, "nvim-lspconfig": { "branch": "master", "commit": "6bba673aa8993eceec233be17b42ddfb9540794b" }, - "nvim-material-icon": { "branch": "main", "commit": "38fc13fe4811c4bf62533180ff5e7bbd237c5ef5" }, + "nvim-material-icon": { "branch": "main", "commit": "149cdb10d91491021c47fe17a0d7a8b8bf45784e" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, @@ -69,7 +69,6 @@ "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, - "transparent.nvim": { "branch": "main", "commit": "8ac59883de84e9cd1850ea25cf087031c5ba7d54" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, diff --git a/lua/pcode/plugins/lang/javascript.lua b/lua/pcode/plugins/lang/javascript.lua index 25b8585..b92aa7d 100644 --- a/lua/pcode/plugins/lang/javascript.lua +++ b/lua/pcode/plugins/lang/javascript.lua @@ -159,6 +159,220 @@ local M = { }, config = function(_, opts) require("npm-runner").setup(opts.command, opts.opt) + -- js new project + local function js_new_project() + local function create_notif(message, level) + local notif_ok, notify = pcall(require, "notify") + if notif_ok then + notify(message, level) + else + print(message) + end + end + + local function get_user_input(prompt, default_value) + vim.fn.inputsave() + local result = vim.fn.input(prompt, default_value) + vim.fn.inputrestore() + if result == "" then + create_notif("Input canceled.", "info") + return nil, true + end + return result, false + end + + -- Input nama project + local project_name, canceled = get_user_input("Enter project name: ", "my-js-app") + if canceled then + return + end + + -- Input file entry point (bisa src/index.js, index.js, src/main/index.js, dsb) + local file_path_input, canceled = get_user_input( + "Enter entry file name \n(\nindex.js, \nsrc/index.js, \nsrc/main/index.js\n): ", + "src/index.js" + ) + if canceled then + return + end + + -- Input nama function utama + local function_name, canceled = get_user_input("Enter main function name: ", "main") + if canceled then + return + end + + local cwd = vim.fn.getcwd() + local project_path = cwd .. "/" .. project_name + + if vim.fn.isdirectory(project_path) == 1 then + create_notif("Project directory already exists: " .. project_path, "error") + return + end + + -- Dapatkan folder dan filename dari file_path_input + local folder_part = file_path_input:match("(.+)/[^/]+%.js$") or "" -- e.g. "src/main" or "" + local file_name_part = file_path_input:match("([^/]+)%.js$") -- e.g. "index" + + -- Buat project folder dan subfolder jika ada + local full_folder_path = (folder_part ~= "") and (project_path .. "/" .. folder_part) or project_path + vim.fn.system(string.format("mkdir -p '%s'", full_folder_path)) + + -- path file entry point absolut + local entry_file = string.format("%s/%s.js", full_folder_path, file_name_part) + + -- Buat package.json dengan "main" dan scripts dinamis + local package_json = string.format( + [[ +{ + "name": "%s", + "version": "1.0.0", + "main": "%s", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node %s", + "dev": "nodemon %s" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "nodemon": "^3.1.0" + } +} +]], + project_name, + file_path_input, + file_path_input, + file_path_input + ) + local package_json_path = project_path .. "/package.json" + local pkg_file = io.open(package_json_path, "w") + if pkg_file then + pkg_file:write(package_json) + pkg_file:close() + end + + -- Tambahkan generate jsconfig.json + local jsconfig = [[ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "allowSyntheticDefaultImports": true + }, + "exclude": ["node_modules"], + "include": ["**/*.js"] +} +]] + local jsconfig_path = project_path .. "/jsconfig.json" + local jsconfig_file = io.open(jsconfig_path, "w") + if jsconfig_file then + jsconfig_file:write(jsconfig) + jsconfig_file:close() + end + + -- Template kode JS + local js_code = string.format( + [[ +function %s() { + +} + +%s(); +]], + function_name, + function_name + ) + + local file = io.open(entry_file, "w") + if file then + file:write(js_code) + file:close() + create_notif("JavaScript project created at " .. project_path, "info") + vim.cmd("cd " .. project_path) + + -- Jalankan npm install (async, biar tidak blok nvim) + vim.fn.jobstart("npm install", { + cwd = project_path, + detach = false, + on_stdout = function(_, data) + if data and type(data) == "table" then + local msg = table.concat( + vim.tbl_filter(function(line) + return line and line ~= "" + end, data), + "\n" + ) + if msg ~= "" then + create_notif("npm install: " .. msg, "info") + end + end + end, + on_stderr = function(_, data) + if data and type(data) == "table" then + local msg = table.concat( + vim.tbl_filter(function(line) + return line and line ~= "" + end, data), + "\n" + ) + if msg ~= "" then + create_notif("npm install error: " .. msg, "error") + end + end + end, + on_exit = function(_, code) + if code == 0 then + create_notif("npm install finished", "info") + else + create_notif("npm install failed", "error") + end + end, + }) + + -- Jika ada NvimTreeOpen, jalankan lalu fokus ke file JS + if vim.fn.exists(":NvimTreeOpen") == 2 then + vim.cmd("NvimTreeOpen") + vim.schedule(function() + vim.cmd("edit " .. entry_file) + local lines = {} + for line in js_code:gmatch("([^\n]*)\n?") do + table.insert(lines, line) + end + local func_line = 1 + for i, line in ipairs(lines) do + if line:find("function%s+" .. function_name .. "%s*%(") then + func_line = i + break + end + end + local target_line = func_line + 1 + vim.api.nvim_win_set_cursor(0, { target_line, 2 }) + vim.cmd("startinsert") + end) + else + vim.cmd("edit " .. entry_file) + local lines = {} + for line in js_code:gmatch("([^\n]*)\n?") do + table.insert(lines, line) + end + local func_line = 1 + for i, line in ipairs(lines) do + if line:find("function%s+" .. function_name .. "%s*%(") then + func_line = i + break + end + end + local target_line = func_line + 1 + vim.api.nvim_win_set_cursor(0, { target_line, 2 }) + vim.cmd("startinsert") + end + else + create_notif("Failed to create file: " .. entry_file, "error") + end + end + + vim.api.nvim_create_user_command("JsNewProject", js_new_project, {}) end, }, { From 1167f053e4a59b35731029da57e7ed41fb521e1b Mon Sep 17 00:00:00 2001 From: pojok code Date: Fri, 27 Jun 2025 15:52:23 +0700 Subject: [PATCH 19/28] enc: add vitest config --- lazy-lock.json | 5 +- lua/pcode/plugins/lang/golang.lua | 1 + lua/pcode/plugins/lang/javascript.lua | 236 +------------------------- 3 files changed, 7 insertions(+), 235 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 0040d49..3f4aa5e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -37,8 +37,9 @@ "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, + "neotest-vitest": { "branch": "main", "commit": "a6099e1fb55a2c2851da3dd0f4d510af9a234c92" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "npm-runner.nvim": { "branch": "main", "commit": "4acc407e07e16eb42e356b10bc17886b21744606" }, + "npm-runner.nvim": { "branch": "main", "commit": "06d303e0a8ba384cd5fc35de6ba62d3500c99148" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, @@ -50,7 +51,7 @@ "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, "nvim-lspconfig": { "branch": "master", "commit": "6bba673aa8993eceec233be17b42ddfb9540794b" }, - "nvim-material-icon": { "branch": "main", "commit": "149cdb10d91491021c47fe17a0d7a8b8bf45784e" }, + "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, diff --git a/lua/pcode/plugins/lang/golang.lua b/lua/pcode/plugins/lang/golang.lua index 4c277ac..db8cf0a 100644 --- a/lua/pcode/plugins/lang/golang.lua +++ b/lua/pcode/plugins/lang/golang.lua @@ -294,6 +294,7 @@ func %s() { { "nvim-neotest/neotest", event = "VeryLazy", + ft = "go", dependencies = { "nvim-lua/plenary.nvim", "antoinemadec/FixCursorHold.nvim", diff --git a/lua/pcode/plugins/lang/javascript.lua b/lua/pcode/plugins/lang/javascript.lua index b92aa7d..4dfa494 100644 --- a/lua/pcode/plugins/lang/javascript.lua +++ b/lua/pcode/plugins/lang/javascript.lua @@ -30,7 +30,9 @@ local M = { "antoinemadec/FixCursorHold.nvim", "nvim-neotest/neotest-jest", "nvim-neotest/nvim-nio", + "marilari88/neotest-vitest", }, + ft = { "javascript", "typescript", "javascriptreact", "typescriptreact" }, opts = { adapters = { ["neotest-jest"] = { @@ -50,6 +52,7 @@ local M = { return vim.fn.getcwd() end, }, + ["neotest-vitest"] = {}, }, status = { virtual_text = true }, output = { open_on_run = true }, @@ -94,25 +97,6 @@ local M = { end require("neotest").setup(opts) - -- local command = pcode.npm_commad - -- or { - -- dev = { - -- start = "NpmRunDev", - -- stop = "NpmStopDev", - -- cmd = "npm run dev", - -- }, - -- prod = { - -- start = "NpmStart", - -- stop = "NpmStop", - -- cmd = "npm start", - -- }, - -- } - -- require("pcode.user.npmrun").setup(command, { - -- show_mapping = "nm", - -- hide_mapping = "nh", - -- width = 70, - -- height = 20, - -- }) end, -- stylua: ignore keys = { @@ -159,220 +143,6 @@ local M = { }, config = function(_, opts) require("npm-runner").setup(opts.command, opts.opt) - -- js new project - local function js_new_project() - local function create_notif(message, level) - local notif_ok, notify = pcall(require, "notify") - if notif_ok then - notify(message, level) - else - print(message) - end - end - - local function get_user_input(prompt, default_value) - vim.fn.inputsave() - local result = vim.fn.input(prompt, default_value) - vim.fn.inputrestore() - if result == "" then - create_notif("Input canceled.", "info") - return nil, true - end - return result, false - end - - -- Input nama project - local project_name, canceled = get_user_input("Enter project name: ", "my-js-app") - if canceled then - return - end - - -- Input file entry point (bisa src/index.js, index.js, src/main/index.js, dsb) - local file_path_input, canceled = get_user_input( - "Enter entry file name \n(\nindex.js, \nsrc/index.js, \nsrc/main/index.js\n): ", - "src/index.js" - ) - if canceled then - return - end - - -- Input nama function utama - local function_name, canceled = get_user_input("Enter main function name: ", "main") - if canceled then - return - end - - local cwd = vim.fn.getcwd() - local project_path = cwd .. "/" .. project_name - - if vim.fn.isdirectory(project_path) == 1 then - create_notif("Project directory already exists: " .. project_path, "error") - return - end - - -- Dapatkan folder dan filename dari file_path_input - local folder_part = file_path_input:match("(.+)/[^/]+%.js$") or "" -- e.g. "src/main" or "" - local file_name_part = file_path_input:match("([^/]+)%.js$") -- e.g. "index" - - -- Buat project folder dan subfolder jika ada - local full_folder_path = (folder_part ~= "") and (project_path .. "/" .. folder_part) or project_path - vim.fn.system(string.format("mkdir -p '%s'", full_folder_path)) - - -- path file entry point absolut - local entry_file = string.format("%s/%s.js", full_folder_path, file_name_part) - - -- Buat package.json dengan "main" dan scripts dinamis - local package_json = string.format( - [[ -{ - "name": "%s", - "version": "1.0.0", - "main": "%s", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "start": "node %s", - "dev": "nodemon %s" - }, - "author": "", - "license": "ISC", - "devDependencies": { - "nodemon": "^3.1.0" - } -} -]], - project_name, - file_path_input, - file_path_input, - file_path_input - ) - local package_json_path = project_path .. "/package.json" - local pkg_file = io.open(package_json_path, "w") - if pkg_file then - pkg_file:write(package_json) - pkg_file:close() - end - - -- Tambahkan generate jsconfig.json - local jsconfig = [[ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "allowSyntheticDefaultImports": true - }, - "exclude": ["node_modules"], - "include": ["**/*.js"] -} -]] - local jsconfig_path = project_path .. "/jsconfig.json" - local jsconfig_file = io.open(jsconfig_path, "w") - if jsconfig_file then - jsconfig_file:write(jsconfig) - jsconfig_file:close() - end - - -- Template kode JS - local js_code = string.format( - [[ -function %s() { - -} - -%s(); -]], - function_name, - function_name - ) - - local file = io.open(entry_file, "w") - if file then - file:write(js_code) - file:close() - create_notif("JavaScript project created at " .. project_path, "info") - vim.cmd("cd " .. project_path) - - -- Jalankan npm install (async, biar tidak blok nvim) - vim.fn.jobstart("npm install", { - cwd = project_path, - detach = false, - on_stdout = function(_, data) - if data and type(data) == "table" then - local msg = table.concat( - vim.tbl_filter(function(line) - return line and line ~= "" - end, data), - "\n" - ) - if msg ~= "" then - create_notif("npm install: " .. msg, "info") - end - end - end, - on_stderr = function(_, data) - if data and type(data) == "table" then - local msg = table.concat( - vim.tbl_filter(function(line) - return line and line ~= "" - end, data), - "\n" - ) - if msg ~= "" then - create_notif("npm install error: " .. msg, "error") - end - end - end, - on_exit = function(_, code) - if code == 0 then - create_notif("npm install finished", "info") - else - create_notif("npm install failed", "error") - end - end, - }) - - -- Jika ada NvimTreeOpen, jalankan lalu fokus ke file JS - if vim.fn.exists(":NvimTreeOpen") == 2 then - vim.cmd("NvimTreeOpen") - vim.schedule(function() - vim.cmd("edit " .. entry_file) - local lines = {} - for line in js_code:gmatch("([^\n]*)\n?") do - table.insert(lines, line) - end - local func_line = 1 - for i, line in ipairs(lines) do - if line:find("function%s+" .. function_name .. "%s*%(") then - func_line = i - break - end - end - local target_line = func_line + 1 - vim.api.nvim_win_set_cursor(0, { target_line, 2 }) - vim.cmd("startinsert") - end) - else - vim.cmd("edit " .. entry_file) - local lines = {} - for line in js_code:gmatch("([^\n]*)\n?") do - table.insert(lines, line) - end - local func_line = 1 - for i, line in ipairs(lines) do - if line:find("function%s+" .. function_name .. "%s*%(") then - func_line = i - break - end - end - local target_line = func_line + 1 - vim.api.nvim_win_set_cursor(0, { target_line, 2 }) - vim.cmd("startinsert") - end - else - create_notif("Failed to create file: " .. entry_file, "error") - end - end - - vim.api.nvim_create_user_command("JsNewProject", js_new_project, {}) end, }, { From fa09a7248eb33413529e60068ce29296c06ce008 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 28 Jun 2025 23:42:52 +0700 Subject: [PATCH 20/28] enc: update key mapping for comment --- lazy-lock.json | 10 +-- lua/pcode/plugins/theme/catppuccin.lua | 12 ++- lua/pcode/user/default.lua | 4 +- lua/pcode/user/keymaps.lua | 102 ++++++++++--------------- mysnippets/go/snippets.json | 48 ++++++++++++ mysnippets/package.json | 7 +- 6 files changed, 109 insertions(+), 74 deletions(-) create mode 100644 mysnippets/go/snippets.json diff --git a/lazy-lock.json b/lazy-lock.json index 3f4aa5e..bdc86ce 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,10 +1,9 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, - "auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" }, + "auto-bufferline.nvim": { "branch": "main", "commit": "2766951c88e7fdf667b25799771d209fe1f025f3" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, "auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" }, "auto-lsp.nvim": { "branch": "main", "commit": "ea80aef3ac630d310c2643047aaa7d7747d207a1" }, @@ -20,6 +19,7 @@ "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, @@ -33,7 +33,7 @@ "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, - "neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" }, + "neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" }, "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, @@ -44,7 +44,7 @@ "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" }, + "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, @@ -64,7 +64,7 @@ "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, - "smart-splits.nvim": { "branch": "master", "commit": "0098e376638602bc6aaf779bb8531b840a3fe26e" }, + "smart-splits.nvim": { "branch": "master", "commit": "039b1c280b849cc23190e94285083af9c2020596" }, "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, diff --git a/lua/pcode/plugins/theme/catppuccin.lua b/lua/pcode/plugins/theme/catppuccin.lua index b4e5c68..d37df00 100644 --- a/lua/pcode/plugins/theme/catppuccin.lua +++ b/lua/pcode/plugins/theme/catppuccin.lua @@ -36,11 +36,15 @@ return { operators = {}, -- miscs = {}, -- Uncomment to turn off hard-coded styles }, - color_overrides = {}, + color_overrides = { + all = { + mantle = "#1e1e2e", + }, + }, custom_highlights = function(colors) return { NvimTreeNormal = { fg = colors.text, bg = transparent and colors.none or colors.base }, - NvimTreeWinSeparator = { fg = colors.mantle, bg = transparent and colors.none or colors.none }, + NvimTreeWinSeparator = { fg = "#181825", bg = transparent and colors.none or colors.none }, Pmenu = { fg = colors.text, bg = transparent and colors.none or colors.base }, WhichKeyFloat = { fg = colors.text, bg = transparent and colors.none or colors.base }, WhichKey = { fg = colors.text, bg = transparent and colors.none or colors.base }, @@ -48,7 +52,8 @@ return { NormalFloat = { fg = colors.text, bg = transparent and colors.none or colors.base }, Normal = { fg = colors.text, bg = transparent and colors.none or colors.base }, NormalNC = { fg = colors.text, bg = transparent and colors.none or colors.base }, - StatusLine = { fg = colors.text, bg = colors.none }, + TabLine = { fg = colors.text, bg = transparent and colors.none or colors.base }, + StatusLine = { fg = colors.text, bg = transparent and colors.none or colors.base }, MasonBackdrop = { link = "NormalFloat" }, } end, @@ -61,6 +66,7 @@ return { }, default_integrations = true, integrations = { + bufferline = true, cmp = true, gitsigns = true, nvimtree = true, diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index d151a30..570c4b2 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -56,13 +56,13 @@ pcode.extras = { pcode.themes = { -- note: open remark only one -- **:: Eva Theme ::** -- - evatheme = "Eva-Dark", + -- evatheme = "Eva-Dark", -- evatheme = "Eva-Dark-Italic", -- evatheme = "Eva-Dark-Bold", -- evatheme = "Eva-Light", -- -- **:: Dracula Theme ::** -- - -- dracula = "dracula", + dracula = "dracula", -- dracula = "dracula-soft", -- -- **:: Onedarkpro Theme ::** -- diff --git a/lua/pcode/user/keymaps.lua b/lua/pcode/user/keymaps.lua index a260663..6cbbc03 100644 --- a/lua/pcode/user/keymaps.lua +++ b/lua/pcode/user/keymaps.lua @@ -1,5 +1,6 @@ -- definiskanfunction name -local keymap = vim.api.nvim_set_keymap +-- local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap.set local opts = { noremap = true, silent = true } -- Remap space leader keys @@ -35,15 +36,43 @@ keymap("i", "", "m+", opts) keymap("n", "", "m-2", opts) keymap("i", "", "m-2", opts) --- create comment CTRL + / all mode -keymap("v", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("v", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise.current()", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise.current()", opts) -keymap("n", "", "lua require('Comment.api').toggle.linewise.current()", opts) -keymap("n", "", "lua require('Comment.api').toggle.linewise.current()", opts) +-- create comment CTRL + / visual block mode +keymap("x", "", function() + vim.api.nvim_feedkeys("gb", "v", true) +end, opts) +-- create comment CTRL + / normal mode +keymap("i", "", function() + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + -- Toggle comment baris + vim.api.nvim_feedkeys("gcc", "v", true) + + -- Tunggu sejenak agar komentar terbentuk + vim.schedule(function() + local row = vim.fn.line(".") - 1 -- index dimulai dari 0 + local col = #vim.fn.getline(".") -- panjang baris = akhir kalimat + + -- Geser 2 spasi dari akhir dan masuk insert mode + vim.api.nvim_win_set_cursor(0, { row + 1, col }) + vim.api.nvim_feedkeys("i", "v", true) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + end) +end, opts) +-- create comment CTRL + / normal mode +keymap("n", "", function() + -- Toggle comment baris + vim.api.nvim_feedkeys("gcc", "v", true) + + -- Tunggu sejenak agar komentar terbentuk + vim.schedule(function() + local row = vim.fn.line(".") - 1 -- index dimulai dari 0 + local col = #vim.fn.getline(".") -- panjang baris = akhir kalimat + + -- Geser 2 spasi dari akhir dan masuk insert mode + vim.api.nvim_win_set_cursor(0, { row + 1, col }) + vim.api.nvim_feedkeys("i", "v", true) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + end) +end, opts) -- close windows keymap("n", "q", "q", opts) @@ -92,59 +121,6 @@ keymap("n", "", "terminal live-server", opts) -- close current buffer keymap("n", "", "lua require('auto-bufferline.configs.utils').bufremove()", opts) --- vim.keymap.set("n", "ti", function() --- local api = vim.api --- local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() --- local parsers = vim.tbl_keys(parser_configs) --- table.sort(parsers) --- --- local choices = {} --- local lookup = {} --- --- for _, parser in ipairs(parsers) do --- local is_installed = #api.nvim_get_runtime_file("parser/" .. parser .. ".so", false) > 0 --- --- local label = (is_installed and "[✓] " or "[✗] ") .. parser --- table.insert(choices, label) --- lookup[label] = parser --- end --- --- vim.ui.select(choices, { --- prompt = "Treesitter ([✓]= installed, [✗] = not installed)", --- }, function(choice) --- if choice then --- local parser_name = lookup[choice] --- if parser_name then --- vim.cmd("TSInstall " .. parser_name) --- end --- end --- end) --- end, { desc = "Install Treesitter" }) --- --- vim.keymap.set("n", "tu", function() --- local parsers = require("nvim-treesitter.info").installed_parsers() --- table.sort(parsers) --- local choices = {} --- local lookup = {} --- --- for _, parser in ipairs(parsers) do --- local label = "[✓] " .. parser --- table.insert(choices, label) --- lookup[label] = parser --- end --- --- vim.ui.select(choices, { --- prompt = "Uninstall Treesitter", --- }, function(choice) --- if choice then --- local parser_name = lookup[choice] --- if parser_name then --- vim.cmd("TSUninstall " .. parser_name) --- end --- end --- end) --- end, { desc = "Uninstall Treesitter" }) - vim.api.nvim_create_user_command("TSIsInstalled", function() local parsers = require("nvim-treesitter.info").installed_parsers() table.sort(parsers) diff --git a/mysnippets/go/snippets.json b/mysnippets/go/snippets.json new file mode 100644 index 0000000..6732087 --- /dev/null +++ b/mysnippets/go/snippets.json @@ -0,0 +1,48 @@ +{ + "author": { + "prefix": "@author", + "body": [ + "/*", + "Author = Pojok Code", + "email = pojokcodeid@gmail.com", + "Github = https://github.com/pojokcodeid", + "Youtube = https://youtube.com/pojokcode", + "Date = $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}", + "File = $TM_FILENAME", + "note = Penyalahgunaan kode ini bukan tanggung jawab pojok code", + "*/", + "$1" + ], + "description": "Komentar Author" + }, + "/*": { + "prefix": "/*", + "body": ["/*", "* $1", "*/"], + "description": "Komentar" + }, + "/": { + "prefix": "/", + "body": "// $1", + "description": "Komentar" + }, + "main": { + "prefix": "main", + "body": [ + "package main", + "", + "import (", + "\t\"fmt\"", + ")", + "", + "func main() {", + "\tfmt.Println($1)", + "}" + ], + "description": "main" + }, + "func": { + "prefix": "func", + "body": ["func $1($2) {", "\t$3", "}"], + "description": "func" + } +} diff --git a/mysnippets/package.json b/mysnippets/package.json index c9dd02e..e566872 100644 --- a/mysnippets/package.json +++ b/mysnippets/package.json @@ -4,7 +4,12 @@ { "language": "html", "path": "./html/snippets.json" + }, + { + "language": "go", + "path": "./go/snippets.json" } ] } -} \ No newline at end of file +} + From 282733e5ea8fb0f84f3e9ad73e22e1bbc23ca086 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 28 Jun 2025 23:53:00 +0700 Subject: [PATCH 21/28] enc: add key maps SHIFT+ALT-UP/DOWN for duplicate code --- lua/pcode/user/keymaps.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/pcode/user/keymaps.lua b/lua/pcode/user/keymaps.lua index 6cbbc03..9ebb0d3 100644 --- a/lua/pcode/user/keymaps.lua +++ b/lua/pcode/user/keymaps.lua @@ -20,13 +20,17 @@ for _, mode in ipairs({ "i", "v", "n", "x" }) do -- duplicate line keymap(mode, "", "t.", opts) keymap(mode, "", "t -1", opts) + keymap(mode, "", "t.", opts) + keymap(mode, "", "t -1", opts) -- save file keymap(mode, "", "silent! w", opts) end -- duplicate line visual block keymap("x", "", ":'<,'>t'>", opts) +keymap("x", "", ":'<,'>t'>", opts) keymap("x", "", ":'<,'>t-1", opts) +keymap("x", "", ":'<,'>t-1", opts) -- move text up and down keymap("x", "", ":move '>+1gv-gv", opts) From 6087de87b03b409fe074d9440ea228281fcea7bc Mon Sep 17 00:00:00 2001 From: pojok code Date: Sun, 29 Jun 2025 08:32:10 +0700 Subject: [PATCH 22/28] enc: change visual multi lib --- lazy-lock.json | 2 +- lua/pcode/plugins/extras/visualmulti.lua | 51 +++++++++++++++++++++++- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index bdc86ce..3ceb019 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -32,6 +32,7 @@ "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, + "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" }, "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, "neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" }, "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, @@ -71,7 +72,6 @@ "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, - "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, "vscode-js-debug": { "branch": "main", "commit": "a3279c2abc1162069b0f5c014542b8b849cefa70" }, diff --git a/lua/pcode/plugins/extras/visualmulti.lua b/lua/pcode/plugins/extras/visualmulti.lua index 0717bfd..2e2a5cf 100644 --- a/lua/pcode/plugins/extras/visualmulti.lua +++ b/lua/pcode/plugins/extras/visualmulti.lua @@ -1,9 +1,12 @@ return { - "mg979/vim-visual-multi", + --[[ "mg979/vim-visual-multi", event = { "BufRead", "InsertEnter", "BufNewFile" }, branch = "master", lazy = true, init = function() + -- Nonaktifkan mapping default jika ingin custom + vim.g.VM_default_mappings = 0 + vim.g.VM_mouse_mappings = 1 -- equal CTRL + Left Click on VSCODE vim.g.VM_maps = { ["Find Under"] = "", -- equal CTRL+D on VSCODE @@ -13,5 +16,49 @@ return { ["Undo"] = "u", -- undo ["Redo"] = "", -- redo } - end, + end, ]] + { + "brenton-leighton/multiple-cursors.nvim", + version = "*", + opts = {}, + event = { "BufRead", "InsertEnter", "BufNewFile" }, + keys = { + -- 🧠 Seperti Ctrl + D di VS Code → pilih kata berikutnya yang sama + { + "", + function() + vim.cmd("MultipleCursorsAddJumpNextMatch") + vim.schedule(function() + vim.notify( + "🖊️ Multiple cursor: menambahkan seleksi berikutnya", + vim.log.levels.INFO, + { title = "MultipleCursors" } + ) + end) + end, + mode = { "n", "x" }, + desc = "Select next match", + }, + + -- 👇 Menambah kursor ke bawah seperti Ctrl + Alt + ↓ + { "", "MultipleCursorsAddDown", mode = { "n", "i", "x" }, desc = "Add cursor down" }, + + -- 👆 Menambah kursor ke atas seperti Ctrl + Alt + ↑ + { "", "MultipleCursorsAddUp", mode = { "n", "i", "x" }, desc = "Add cursor up" }, + + -- 🖱️ Tambah/hapus kursor dengan Ctrl + Klik mouse + { + "", + "MultipleCursorsMouseAddDelete", + mode = { "n", "i" }, + desc = "Add/remove cursor with mouse", + }, + + -- 🔲 Tambah kursor ke seluruh baris visual yang dipilih (pakai Leader + m) + { "m", "MultipleCursorsAddVisualArea", mode = { "x" }, desc = "Add cursors to visual lines" }, + + -- 🔒 Lock semua kursor supaya siap edit serentak + { "L", "MultipleCursorsLock", mode = { "n", "x" }, desc = "Lock cursors" }, + }, + }, } From 6d3f3dedad5e719cf650e9de811f493e5d36c4fe Mon Sep 17 00:00:00 2001 From: pojok code Date: Wed, 2 Jul 2025 07:09:44 +0700 Subject: [PATCH 23/28] enc: add keymap table documentastions --- lazy-lock.json | 14 +-- lua/pcode/core/init.lua | 2 + lua/pcode/core/keymaps.lua | 180 +++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 lua/pcode/core/keymaps.lua diff --git a/lazy-lock.json b/lazy-lock.json index 3ceb019..bcf2fbd 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,7 +6,7 @@ "auto-bufferline.nvim": { "branch": "main", "commit": "2766951c88e7fdf667b25799771d209fe1f025f3" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, "auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" }, - "auto-lsp.nvim": { "branch": "main", "commit": "ea80aef3ac630d310c2643047aaa7d7747d207a1" }, + "auto-lsp.nvim": { "branch": "main", "commit": "c0e6f49bcf789b476ee551279f5b3ec9a8081bbd" }, "auto-lualine.nvim": { "branch": "main", "commit": "c889473aef975bf3b17a770dfb2039bb2a0cd41c" }, "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, @@ -14,15 +14,15 @@ "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, - "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, + "cmp-path": { "branch": "main", "commit": "e52e640b7befd8113b3350f46e8cfcfe98fcf730" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, - "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "conform.nvim": { "branch": "master", "commit": "4c9003aab62879612c50136649baa1b8ed36cfa1" }, "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, + "gitsigns.nvim": { "branch": "main", "commit": "588264bee92993df92535b6742576f5655c91b1c" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, @@ -35,14 +35,14 @@ "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" }, "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, "neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" }, - "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, + "neotest-jest": { "branch": "main", "commit": "797515e113ac8e19c6855046d7f746d9c0c39c15" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "neotest-vitest": { "branch": "main", "commit": "a6099e1fb55a2c2851da3dd0f4d510af9a234c92" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "npm-runner.nvim": { "branch": "main", "commit": "06d303e0a8ba384cd5fc35de6ba62d3500c99148" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, @@ -51,7 +51,7 @@ "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "6bba673aa8993eceec233be17b42ddfb9540794b" }, + "nvim-lspconfig": { "branch": "master", "commit": "1cb30b1bafe5a63a5c6ac20dc39f83487df38855" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, diff --git a/lua/pcode/core/init.lua b/lua/pcode/core/init.lua index 7ef9ee4..b3b3091 100644 --- a/lua/pcode/core/init.lua +++ b/lua/pcode/core/init.lua @@ -3,3 +3,5 @@ require("pcode.user.default") require("pcode.config.lazy_lib") require("pcode.user.colorscheme") require("pcode.core.neovide") + +require("pcode.core.keymaps") diff --git a/lua/pcode/core/keymaps.lua b/lua/pcode/core/keymaps.lua new file mode 100644 index 0000000..16dca05 --- /dev/null +++ b/lua/pcode/core/keymaps.lua @@ -0,0 +1,180 @@ +local keymaps = { + ["LSP"] = { + { "LSP Code Action", "la" }, + { "LSP Code Format", "lf" }, + { "LSP Information", "li" }, + { "Mason Information", "lI" }, + { "LSP Next Diagnostic", "lj" }, + { "LSP Previous Diagnostic", "lk" }, + { "LSP Quickfix", "lr" }, + { "LSP Signature Help", "ls" }, + { "LSP Format On Range", "lF" }, + }, + ["Cmp"] = { + { "Scroll Next Documentation", "CTRL + f" }, + { "Scroll Previous Documentation", "CTRL + b" }, + { "Mapping Complete", "CTRL + space" }, + { "Abort Completion", "CTRL + e" }, + { "Accept Completion", "↵" }, + { "Next Autocompletion", "TAB" }, + { "Previous Autocompletion", "SHIFT + TAB" }, + }, + ["Terminal"] = { + { "Terminal Float", "tf" }, + { "Terminal Horizontal", "th" }, + { "Terminal new tab", "ts" }, + { "Terminal Vertical", "tv" }, + { "Terminal Close", "tx" }, + }, + ["Comment"] = { + { "Comment line toggle", "gcc or CTRL + /" }, + { "Comment block toggle", "gbc or CTRL + /" }, + { "Comment visual selection", "gc" }, + { "Comment visual selection using block delimiters", "gb" }, + { "Comment out text object line wise", "gc" }, + { "Comment out text object block wise", "gb" }, + { "Add comment on the line above", "gcO" }, + { "Add comment on the line below", "gco" }, + { "Add comment at the end of line", "gcA" }, + }, + ["Bufferline"] = { + { "Move Active Buffer Left", "SHIFT + h OR SHIFT + ArrowLeft" }, + { "Move Active Buffer Right", "SHIFT + l OR SHIFT + ArrowRight" }, + { "Reorder Bufferline", "SHIFT + PageUp/PageDown" }, + { "Close Current Buffer", "SHIFT + t" }, + }, + ["Window"] = { + { "Resize Window", "CTRL + ArrowLeft/ArrowRight/ArrowUp/ArrowDown" }, + { "Navigate Window", "CTRL + h/l" }, + }, +} + +-- Section title highlight setup +vim.api.nvim_set_hl(0, "KeymapsSectionOil", { bg = "#8fbcbb", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "KeymapsSectionCmp", { bg = "#b48ead", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "KeymapsSectionComment", { bg = "#bf616a", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Normal2", { bg = "#56B7C3", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color1", { bg = "#D6ACFF", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color2", { bg = "#F1FA8C", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color3", { bg = "#FF79C6", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color4", { bg = "#FF92DF", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color5", { bg = "#69ff94", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color6", { bg = "#FF6E6E", fg = "#1e1e1e", bold = true }) +vim.api.nvim_set_hl(0, "Color7", { bg = "#D6ACFF", fg = "#1e1e1e", bold = true }) + +local section_hl = { + "KeymapsSectionOil", + "KeymapsSectionCmp", + "KeymapsSectionComment", + "Normal2", + "Color1", + "Color2", + "Color3", + "Color4", + "Color5", + "Color6", + "Color7", +} + +local function pad(str, width) + local n = vim.fn.strdisplaywidth(str) + return str .. string.rep(" ", width - n) +end + +local function calc_widths(tbl) + local col1, col2 = 0, 0 + for _, group in pairs(tbl) do + for _, row in ipairs(group) do + col1 = math.max(col1, vim.fn.strdisplaywidth(row[1])) + col2 = math.max(col2, vim.fn.strdisplaywidth(row[2])) + end + end + return col1, col2 +end + +local function make_lines(tbl, max_width) + local col1, col2 = calc_widths(tbl) + if max_width then + local padding = max_width - (col1 + col2 + 3) + if padding > 0 then + col1 = col1 + math.floor(padding * 0.7) + col2 = col2 + padding - math.floor(padding * 0.7) + end + end + local lines = {} + local hls = {} + Random_index = 1 + + for section, rows in pairs(tbl) do + local section_title = (" %s "):format(section) + table.insert(lines, section_title) + table.insert(hls, { { 0, #section_title, section_hl[Random_index] or "Normal2" } }) + Random_index = Random_index + 1 + if Random_index > #section_hl then + Random_index = 1 + end + -- Hapus baris Description, hanya tampilkan garis bawah dan data + table.insert(lines, string.rep("─", col1) .. "─┬─" .. string.rep("─", col2)) + table.insert(hls, {}) + for _, row in ipairs(rows) do + table.insert(lines, pad(row[1], col1) .. " │ " .. pad(row[2], col2)) + table.insert(hls, {}) + end + table.insert(lines, "") + table.insert(hls, {}) + end + return lines, col1 + col2 + 3, hls +end + +local function show_keymaps_popup() + local ui = vim.api.nvim_list_uis()[1] + local win_width = math.floor(ui.width * 0.7) + local lines, width, hls = make_lines(keymaps, win_width) + width = win_width + local height = #lines + + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) + vim.api.nvim_buf_set_option(buf, "modifiable", false) + vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe") + + -- highlight section titles + for i, l in ipairs(hls) do + for _, v in ipairs(l) do + vim.api.nvim_buf_add_highlight(buf, -1, v[3], i - 1, v[1], v[2]) + end + end + + local row = math.floor((ui.height - height) / 2) + local col = math.floor((ui.width - width) / 2) + + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + row = row, + col = col, + width = width, + height = height, + style = "minimal", + border = "single", + title = "Keymaps", + title_pos = "center", + }) + + vim.keymap.set("n", "q", function() + vim.api.nvim_win_close(win, true) + end, { buffer = buf, nowait = true }) + vim.keymap.set("n", "", function() + vim.api.nvim_win_close(win, true) + end, { buffer = buf, nowait = true }) +end + +vim.api.nvim_create_user_command("KeymapsPopup", function() + show_keymaps_popup() +end, {}) + +vim.keymap.set("n", "", ":KeymapsPopup", { noremap = true, silent = true }) + +return { + show = show_keymaps_popup, +} From 2ab92b6e940f44d04415ccbf2783fa3a32ff1de2 Mon Sep 17 00:00:00 2001 From: pojok code Date: Wed, 2 Jul 2025 20:46:50 +0700 Subject: [PATCH 24/28] enc: add keymaps info --- lazy-lock.json | 2 +- lua/pcode/core/keymaps.lua | 149 +++++++++++++++++++++++-------------- 2 files changed, 94 insertions(+), 57 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index bcf2fbd..9b1eea1 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -18,7 +18,7 @@ "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, - "conform.nvim": { "branch": "master", "commit": "4c9003aab62879612c50136649baa1b8ed36cfa1" }, + "conform.nvim": { "branch": "master", "commit": "f54259518695178168fbad442468e25f121230d4" }, "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, diff --git a/lua/pcode/core/keymaps.lua b/lua/pcode/core/keymaps.lua index 16dca05..2ae9918 100644 --- a/lua/pcode/core/keymaps.lua +++ b/lua/pcode/core/keymaps.lua @@ -1,56 +1,73 @@ +local mode_info = { + "Mode:", + " n => normal i => insert v => visual x => visual block t => terminal", + "", +} + local keymaps = { ["LSP"] = { - { "LSP Code Action", "la" }, - { "LSP Code Format", "lf" }, - { "LSP Information", "li" }, - { "Mason Information", "lI" }, - { "LSP Next Diagnostic", "lj" }, - { "LSP Previous Diagnostic", "lk" }, - { "LSP Quickfix", "lr" }, - { "LSP Signature Help", "ls" }, - { "LSP Format On Range", "lF" }, + { "LSP Code Action", "n", "la" }, + { "LSP Code Format", "n", "lf" }, + { "LSP Information", "n", "li" }, + { "Mason Information", "n", "lI" }, + { "LSP Next Diagnostic", "n", "lj" }, + { "LSP Previous Diagnostic", "n", "lk" }, + { "LSP Quickfix", "n", "lr" }, + { "LSP Signature Help", "n", "ls" }, + { "LSP Format On Range", "v", "lF" }, }, ["Cmp"] = { - { "Scroll Next Documentation", "CTRL + f" }, - { "Scroll Previous Documentation", "CTRL + b" }, - { "Mapping Complete", "CTRL + space" }, - { "Abort Completion", "CTRL + e" }, - { "Accept Completion", "↵" }, - { "Next Autocompletion", "TAB" }, - { "Previous Autocompletion", "SHIFT + TAB" }, + { "Scroll Next Documentation", "i", "CTRL + f" }, + { "Scroll Previous Documentation", "i", "CTRL + b" }, + { "Mapping Complete", "i", "CTRL + space" }, + { "Abort Completion", "i", "CTRL + e" }, + { "Accept Completion", "i", "↵" }, + { "Next Autocompletion", "i", "TAB" }, + { "Previous Autocompletion", "i", "SHIFT + TAB" }, }, ["Terminal"] = { - { "Terminal Float", "tf" }, - { "Terminal Horizontal", "th" }, - { "Terminal new tab", "ts" }, - { "Terminal Vertical", "tv" }, - { "Terminal Close", "tx" }, + { "Terminal Float", "n", "tf" }, + { "Terminal Horizontal", "n", "th" }, + { "Terminal new tab", "n", "ts" }, + { "Terminal Vertical", "n", "tv" }, + { "Terminal Close", "n", "tx" }, }, ["Comment"] = { - { "Comment line toggle", "gcc or CTRL + /" }, - { "Comment block toggle", "gbc or CTRL + /" }, - { "Comment visual selection", "gc" }, - { "Comment visual selection using block delimiters", "gb" }, - { "Comment out text object line wise", "gc" }, - { "Comment out text object block wise", "gb" }, - { "Add comment on the line above", "gcO" }, - { "Add comment on the line below", "gco" }, - { "Add comment at the end of line", "gcA" }, + { "Comment line toggle", "n/v", "gcc or CTRL + /" }, + { "Comment block toggle", "n/v", "gbc or CTRL + /" }, + { "Comment visual selection", "v", "gc" }, + { "Comment visual selection using block delimiters", "v", "gb" }, + { "Comment out text object line wise", "v", "gc" }, + { "Comment out text object block wise", "v", "gb" }, + { "Add comment on the line above", "n", "gcO" }, + { "Add comment on the line below", "n", "gco" }, + { "Add comment at the end of line", "n", "gcA" }, }, ["Bufferline"] = { - { "Move Active Buffer Left", "SHIFT + h OR SHIFT + ArrowLeft" }, - { "Move Active Buffer Right", "SHIFT + l OR SHIFT + ArrowRight" }, - { "Reorder Bufferline", "SHIFT + PageUp/PageDown" }, - { "Close Current Buffer", "SHIFT + t" }, + { "Move Active Buffer Left", "n", "SHIFT + h/SHIFT + Left" }, + { "Move Active Buffer Right", "n", "SHIFT + l/SHIFT + Right" }, + { "Reorder Bufferline", "n", "SHIFT + PageUp/PageDown" }, + { "Close Current Buffer", "n", "SHIFT + t" }, }, ["Window"] = { - { "Resize Window", "CTRL + ArrowLeft/ArrowRight/ArrowUp/ArrowDown" }, - { "Navigate Window", "CTRL + h/l" }, + { "Resize Window", "n", "CTRL + Left/Right/Up/Down" }, + { "Navigate Window", "n", "CTRL + h/l" }, + }, + ["Text-Manipulation"] = { + { "Select Multiple Cursor Vertical", "n/i", "SHIFT + ALT + Up/Down" }, + { "Select text", "n", "CTRL + d" }, + { "Select Multiple Cursor", "i/n", "ALT + Left Click Mouse" }, + { "Duplicate Row", "i/n/v", "SHIFT + ALT + Up/Down" }, + { "Move Row", "i/n/v", "ALT + Up/Down" }, + }, + ["Ai"] = { + { "Approve AI Sugention", "i", "CTRL + g" }, + { "Change AI Option", "i", "CTRL + Up/Down" }, + { "Clear AI Sugention", "i", "CTRL + x" }, }, } --- Section title highlight setup vim.api.nvim_set_hl(0, "KeymapsSectionOil", { bg = "#8fbcbb", fg = "#1e1e1e", bold = true }) vim.api.nvim_set_hl(0, "KeymapsSectionCmp", { bg = "#b48ead", fg = "#1e1e1e", bold = true }) vim.api.nvim_set_hl(0, "KeymapsSectionComment", { bg = "#bf616a", fg = "#1e1e1e", bold = true }) @@ -83,53 +100,73 @@ local function pad(str, width) end local function calc_widths(tbl) - local col1, col2 = 0, 0 + local col1, col2, col3 = 0, 0, 0 for _, group in pairs(tbl) do for _, row in ipairs(group) do col1 = math.max(col1, vim.fn.strdisplaywidth(row[1])) col2 = math.max(col2, vim.fn.strdisplaywidth(row[2])) + col3 = math.max(col3, vim.fn.strdisplaywidth(row[3])) end end - return col1, col2 + return col1, col2, col3 end local function make_lines(tbl, max_width) - local col1, col2 = calc_widths(tbl) + local col1, col2, col3 = calc_widths(tbl) if max_width then - local padding = max_width - (col1 + col2 + 3) + local want = col1 + col2 + col3 + 6 + local padding = max_width - want if padding > 0 then - col1 = col1 + math.floor(padding * 0.7) - col2 = col2 + padding - math.floor(padding * 0.7) + col1 = col1 + math.floor(padding * 0.8) + col3 = col3 + (padding - math.floor(padding * 0.8)) end end local lines = {} local hls = {} - Random_index = 1 - for section, rows in pairs(tbl) do + -- Tambahkan info mode di bagian atas + for _, info in ipairs(mode_info) do + table.insert(lines, info) + table.insert(hls, {}) + end + + local random_index = 1 + + -- Urutkan section secara alfabetis + local section_names = {} + for section in pairs(tbl) do + table.insert(section_names, section) + end + table.sort(section_names) + + for _, section in ipairs(section_names) do + local rows = tbl[section] local section_title = (" %s "):format(section) table.insert(lines, section_title) - table.insert(hls, { { 0, #section_title, section_hl[Random_index] or "Normal2" } }) - Random_index = Random_index + 1 - if Random_index > #section_hl then - Random_index = 1 + table.insert(hls, { { 0, #section_title, section_hl[random_index] or "Normal2" } }) + random_index = random_index + 1 + if random_index > #section_hl then + random_index = 1 end - -- Hapus baris Description, hanya tampilkan garis bawah dan data - table.insert(lines, string.rep("─", col1) .. "─┬─" .. string.rep("─", col2)) + + table.insert( + lines, + string.rep("─", col1) .. "─┬─" .. string.rep("─", col2) .. "─┬─" .. string.rep("─", col3) + ) table.insert(hls, {}) for _, row in ipairs(rows) do - table.insert(lines, pad(row[1], col1) .. " │ " .. pad(row[2], col2)) + table.insert(lines, pad(row[1], col1) .. " │ " .. pad(row[2], col2) .. " │ " .. pad(row[3], col3)) table.insert(hls, {}) end table.insert(lines, "") table.insert(hls, {}) end - return lines, col1 + col2 + 3, hls + return lines, col1 + col2 + col3 + 6, hls end local function show_keymaps_popup() local ui = vim.api.nvim_list_uis()[1] - local win_width = math.floor(ui.width * 0.7) + local win_width = math.floor(ui.width * 0.8) local lines, width, hls = make_lines(keymaps, win_width) width = win_width local height = #lines @@ -156,7 +193,7 @@ local function show_keymaps_popup() width = width, height = height, style = "minimal", - border = "single", + border = "rounded", title = "Keymaps", title_pos = "center", }) From a4e2d9ec214c83262e079ccd9ad94bcddb3d25fc Mon Sep 17 00:00:00 2001 From: pojok code Date: Wed, 2 Jul 2025 21:27:12 +0700 Subject: [PATCH 25/28] enc: add file type definition --- lazy-lock.json | 2 +- lua/pcode/core/keymaps.lua | 3 +++ lua/pcode/plugins/extras/indentscupe.lua | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lazy-lock.json b/lazy-lock.json index 9b1eea1..3695993 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -7,7 +7,7 @@ "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, "auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" }, "auto-lsp.nvim": { "branch": "main", "commit": "c0e6f49bcf789b476ee551279f5b3ec9a8081bbd" }, - "auto-lualine.nvim": { "branch": "main", "commit": "c889473aef975bf3b17a770dfb2039bb2a0cd41c" }, + "auto-lualine.nvim": { "branch": "main", "commit": "9f0d6210344057eba2454113d3b07ef6eb58b5eb" }, "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, diff --git a/lua/pcode/core/keymaps.lua b/lua/pcode/core/keymaps.lua index 2ae9918..72837a2 100644 --- a/lua/pcode/core/keymaps.lua +++ b/lua/pcode/core/keymaps.lua @@ -176,6 +176,9 @@ local function show_keymaps_popup() vim.api.nvim_buf_set_option(buf, "modifiable", false) vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe") + -- Set the buffer's filetype to 'keymaps_table' + vim.api.nvim_buf_set_option(buf, "filetype", "keymaps_table") + -- highlight section titles for i, l in ipairs(hls) do for _, v in ipairs(l) do diff --git a/lua/pcode/plugins/extras/indentscupe.lua b/lua/pcode/plugins/extras/indentscupe.lua index ad4a10a..8ce15ae 100644 --- a/lua/pcode/plugins/extras/indentscupe.lua +++ b/lua/pcode/plugins/extras/indentscupe.lua @@ -26,6 +26,7 @@ return { "term", "terminal", "zsh", + "keymaps_table", }, callback = function() vim.b.miniindentscope_disable = true From 5206ccb56e469ceda4e8b780f7823eebc16775e1 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 5 Jul 2025 17:40:57 +0700 Subject: [PATCH 26/28] enc: add config cheatsheet keymaps --- lazy-lock.json | 17 +- lua/pcode/core/init.lua | 2 - lua/pcode/core/keymaps.lua | 220 ------------------------ lua/pcode/plugins/extras/cheatsheet.lua | 73 ++++++++ lua/pcode/user/default.lua | 1 + mysnippets/javascript/snippets.json | 33 ++++ mysnippets/package.json | 9 +- 7 files changed, 124 insertions(+), 231 deletions(-) delete mode 100644 lua/pcode/core/keymaps.lua create mode 100644 lua/pcode/plugins/extras/cheatsheet.lua create mode 100644 mysnippets/javascript/snippets.json diff --git a/lazy-lock.json b/lazy-lock.json index 3695993..a430e0c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -10,6 +10,7 @@ "auto-lualine.nvim": { "branch": "main", "commit": "9f0d6210344057eba2454113d3b07ef6eb58b5eb" }, "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "cheatsheet-nvim": { "branch": "main", "commit": "aaf8f4cc76e193997d0d0a27384cf09418fd7996" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, @@ -18,15 +19,15 @@ "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, - "conform.nvim": { "branch": "master", "commit": "f54259518695178168fbad442468e25f121230d4" }, + "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "588264bee92993df92535b6742576f5655c91b1c" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3ee68bc9f65b21a21582a3d80e270c7e4f2992" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "73e0143385d8a2185944b42ed44d728b94ee19a3" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, @@ -45,13 +46,13 @@ "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, + "nvim-dap": { "branch": "master", "commit": "1c75a797b4017fec6491f509cf196c8c8833f26f" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "1cb30b1bafe5a63a5c6ac20dc39f83487df38855" }, + "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, + "nvim-lspconfig": { "branch": "master", "commit": "d8f03bfd5b54b10352276a0ed1f2ffe9c2e0676f" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, @@ -65,7 +66,7 @@ "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, - "smart-splits.nvim": { "branch": "master", "commit": "039b1c280b849cc23190e94285083af9c2020596" }, + "smart-splits.nvim": { "branch": "master", "commit": "c088d64c6e0e3221d24ef1f9337b5fe15557ddcc" }, "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, @@ -74,7 +75,7 @@ "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, - "vscode-js-debug": { "branch": "main", "commit": "a3279c2abc1162069b0f5c014542b8b849cefa70" }, + "vscode-js-debug": { "branch": "main", "commit": "f8f4253879aa6cd81e5c776a4f9a619771ec2fc3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" } } diff --git a/lua/pcode/core/init.lua b/lua/pcode/core/init.lua index b3b3091..7ef9ee4 100644 --- a/lua/pcode/core/init.lua +++ b/lua/pcode/core/init.lua @@ -3,5 +3,3 @@ require("pcode.user.default") require("pcode.config.lazy_lib") require("pcode.user.colorscheme") require("pcode.core.neovide") - -require("pcode.core.keymaps") diff --git a/lua/pcode/core/keymaps.lua b/lua/pcode/core/keymaps.lua deleted file mode 100644 index 72837a2..0000000 --- a/lua/pcode/core/keymaps.lua +++ /dev/null @@ -1,220 +0,0 @@ -local mode_info = { - "Mode:", - " n => normal i => insert v => visual x => visual block t => terminal", - "", -} - -local keymaps = { - ["LSP"] = { - { "LSP Code Action", "n", "la" }, - { "LSP Code Format", "n", "lf" }, - { "LSP Information", "n", "li" }, - { "Mason Information", "n", "lI" }, - { "LSP Next Diagnostic", "n", "lj" }, - { "LSP Previous Diagnostic", "n", "lk" }, - { "LSP Quickfix", "n", "lr" }, - { "LSP Signature Help", "n", "ls" }, - { "LSP Format On Range", "v", "lF" }, - }, - ["Cmp"] = { - { "Scroll Next Documentation", "i", "CTRL + f" }, - { "Scroll Previous Documentation", "i", "CTRL + b" }, - { "Mapping Complete", "i", "CTRL + space" }, - { "Abort Completion", "i", "CTRL + e" }, - { "Accept Completion", "i", "↵" }, - { "Next Autocompletion", "i", "TAB" }, - { "Previous Autocompletion", "i", "SHIFT + TAB" }, - }, - ["Terminal"] = { - { "Terminal Float", "n", "tf" }, - { "Terminal Horizontal", "n", "th" }, - { "Terminal new tab", "n", "ts" }, - { "Terminal Vertical", "n", "tv" }, - { "Terminal Close", "n", "tx" }, - }, - ["Comment"] = { - { "Comment line toggle", "n/v", "gcc or CTRL + /" }, - { "Comment block toggle", "n/v", "gbc or CTRL + /" }, - { "Comment visual selection", "v", "gc" }, - { "Comment visual selection using block delimiters", "v", "gb" }, - { "Comment out text object line wise", "v", "gc" }, - { "Comment out text object block wise", "v", "gb" }, - { "Add comment on the line above", "n", "gcO" }, - { "Add comment on the line below", "n", "gco" }, - { "Add comment at the end of line", "n", "gcA" }, - }, - ["Bufferline"] = { - { "Move Active Buffer Left", "n", "SHIFT + h/SHIFT + Left" }, - { "Move Active Buffer Right", "n", "SHIFT + l/SHIFT + Right" }, - { "Reorder Bufferline", "n", "SHIFT + PageUp/PageDown" }, - { "Close Current Buffer", "n", "SHIFT + t" }, - }, - ["Window"] = { - { "Resize Window", "n", "CTRL + Left/Right/Up/Down" }, - { "Navigate Window", "n", "CTRL + h/l" }, - }, - ["Text-Manipulation"] = { - { "Select Multiple Cursor Vertical", "n/i", "SHIFT + ALT + Up/Down" }, - { "Select text", "n", "CTRL + d" }, - { "Select Multiple Cursor", "i/n", "ALT + Left Click Mouse" }, - { "Duplicate Row", "i/n/v", "SHIFT + ALT + Up/Down" }, - { "Move Row", "i/n/v", "ALT + Up/Down" }, - }, - ["Ai"] = { - { "Approve AI Sugention", "i", "CTRL + g" }, - { "Change AI Option", "i", "CTRL + Up/Down" }, - { "Clear AI Sugention", "i", "CTRL + x" }, - }, -} - -vim.api.nvim_set_hl(0, "KeymapsSectionOil", { bg = "#8fbcbb", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "KeymapsSectionCmp", { bg = "#b48ead", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "KeymapsSectionComment", { bg = "#bf616a", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Normal2", { bg = "#56B7C3", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color1", { bg = "#D6ACFF", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color2", { bg = "#F1FA8C", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color3", { bg = "#FF79C6", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color4", { bg = "#FF92DF", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color5", { bg = "#69ff94", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color6", { bg = "#FF6E6E", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color7", { bg = "#D6ACFF", fg = "#1e1e1e", bold = true }) - -local section_hl = { - "KeymapsSectionOil", - "KeymapsSectionCmp", - "KeymapsSectionComment", - "Normal2", - "Color1", - "Color2", - "Color3", - "Color4", - "Color5", - "Color6", - "Color7", -} - -local function pad(str, width) - local n = vim.fn.strdisplaywidth(str) - return str .. string.rep(" ", width - n) -end - -local function calc_widths(tbl) - local col1, col2, col3 = 0, 0, 0 - for _, group in pairs(tbl) do - for _, row in ipairs(group) do - col1 = math.max(col1, vim.fn.strdisplaywidth(row[1])) - col2 = math.max(col2, vim.fn.strdisplaywidth(row[2])) - col3 = math.max(col3, vim.fn.strdisplaywidth(row[3])) - end - end - return col1, col2, col3 -end - -local function make_lines(tbl, max_width) - local col1, col2, col3 = calc_widths(tbl) - if max_width then - local want = col1 + col2 + col3 + 6 - local padding = max_width - want - if padding > 0 then - col1 = col1 + math.floor(padding * 0.8) - col3 = col3 + (padding - math.floor(padding * 0.8)) - end - end - local lines = {} - local hls = {} - - -- Tambahkan info mode di bagian atas - for _, info in ipairs(mode_info) do - table.insert(lines, info) - table.insert(hls, {}) - end - - local random_index = 1 - - -- Urutkan section secara alfabetis - local section_names = {} - for section in pairs(tbl) do - table.insert(section_names, section) - end - table.sort(section_names) - - for _, section in ipairs(section_names) do - local rows = tbl[section] - local section_title = (" %s "):format(section) - table.insert(lines, section_title) - table.insert(hls, { { 0, #section_title, section_hl[random_index] or "Normal2" } }) - random_index = random_index + 1 - if random_index > #section_hl then - random_index = 1 - end - - table.insert( - lines, - string.rep("─", col1) .. "─┬─" .. string.rep("─", col2) .. "─┬─" .. string.rep("─", col3) - ) - table.insert(hls, {}) - for _, row in ipairs(rows) do - table.insert(lines, pad(row[1], col1) .. " │ " .. pad(row[2], col2) .. " │ " .. pad(row[3], col3)) - table.insert(hls, {}) - end - table.insert(lines, "") - table.insert(hls, {}) - end - return lines, col1 + col2 + col3 + 6, hls -end - -local function show_keymaps_popup() - local ui = vim.api.nvim_list_uis()[1] - local win_width = math.floor(ui.width * 0.8) - local lines, width, hls = make_lines(keymaps, win_width) - width = win_width - local height = #lines - - local buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) - vim.api.nvim_buf_set_option(buf, "modifiable", false) - vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe") - - -- Set the buffer's filetype to 'keymaps_table' - vim.api.nvim_buf_set_option(buf, "filetype", "keymaps_table") - - -- highlight section titles - for i, l in ipairs(hls) do - for _, v in ipairs(l) do - vim.api.nvim_buf_add_highlight(buf, -1, v[3], i - 1, v[1], v[2]) - end - end - - local row = math.floor((ui.height - height) / 2) - local col = math.floor((ui.width - width) / 2) - - local win = vim.api.nvim_open_win(buf, true, { - relative = "editor", - row = row, - col = col, - width = width, - height = height, - style = "minimal", - border = "rounded", - title = "Keymaps", - title_pos = "center", - }) - - vim.keymap.set("n", "q", function() - vim.api.nvim_win_close(win, true) - end, { buffer = buf, nowait = true }) - vim.keymap.set("n", "", function() - vim.api.nvim_win_close(win, true) - end, { buffer = buf, nowait = true }) -end - -vim.api.nvim_create_user_command("KeymapsPopup", function() - show_keymaps_popup() -end, {}) - -vim.keymap.set("n", "", ":KeymapsPopup", { noremap = true, silent = true }) - -return { - show = show_keymaps_popup, -} diff --git a/lua/pcode/plugins/extras/cheatsheet.lua b/lua/pcode/plugins/extras/cheatsheet.lua new file mode 100644 index 0000000..decb6fb --- /dev/null +++ b/lua/pcode/plugins/extras/cheatsheet.lua @@ -0,0 +1,73 @@ +return { + "pojokcodeid/cheatsheet-nvim", + event = "VeryLazy", + keys = { + { "", "KeymapsPopup", desc = "Keymaps Popup" }, + }, + cmd = { "KeymapsPopup" }, + opts = { + ["LSP"] = { + { "LSP Code Action", "n", "la" }, + { "LSP Code Format", "n", "lf" }, + { "LSP Information", "n", "li" }, + { "Mason Information", "n", "lI" }, + { "LSP Next Diagnostic", "n", "lj" }, + { "LSP Previous Diagnostic", "n", "lk" }, + { "LSP Quickfix", "n", "lr" }, + { "LSP Signature Help", "n", "ls" }, + { "LSP Format On Range", "v", "lF" }, + }, + ["Cmp"] = { + { "Scroll Next Documentation", "i", "CTRL + f" }, + { "Scroll Previous Documentation", "i", "CTRL + b" }, + { "Mapping Complete", "i", "CTRL + space" }, + { "Abort Completion", "i", "CTRL + e" }, + { "Accept Completion", "i", "↵" }, + { "Next Autocompletion", "i", "TAB" }, + { "Previous Autocompletion", "i", "SHIFT + TAB" }, + }, + ["Terminal"] = { + { "Terminal Float", "n", "tf" }, + { "Terminal Horizontal", "n", "th" }, + { "Terminal new tab", "n", "ts" }, + { "Terminal Vertical", "n", "tv" }, + { "Terminal Close", "n", "tx" }, + }, + ["Comment"] = { + { "Comment line toggle", "n/v", "gcc or CTRL + /" }, + { "Comment block toggle", "n/v", "gbc or CTRL + /" }, + { "Comment visual selection", "v", "gc" }, + { "Comment visual selection using block delimiters", "v", "gb" }, + { "Comment out text object line wise", "v", "gc" }, + { "Comment out text object block wise", "v", "gb" }, + { "Add comment on the line above", "n", "gcO" }, + { "Add comment on the line below", "n", "gco" }, + { "Add comment at the end of line", "n", "gcA" }, + }, + ["Bufferline"] = { + { "Move Active Buffer Left", "n", "SHIFT + h/SHIFT + Left" }, + { "Move Active Buffer Right", "n", "SHIFT + l/SHIFT + Right" }, + { "Reorder Bufferline", "n", "SHIFT + PageUp/PageDown" }, + { "Close Current Buffer", "n", "SHIFT + t" }, + }, + ["Window"] = { + { "Resize Window", "n", "CTRL + Left/Right/Up/Down" }, + { "Navigate Window", "n", "CTRL + h/l" }, + }, + ["Text-Manipulation"] = { + { "Select Multiple Cursor Vertical", "n/i", "SHIFT + ALT + Up/Down" }, + { "Select text", "n", "CTRL + d" }, + { "Select Multiple Cursor", "i/n", "ALT + Left Click Mouse" }, + { "Duplicate Row", "i/n/v", "SHIFT + ALT + Up/Down" }, + { "Move Row", "i/n/v", "ALT + Up/Down" }, + }, + ["Ai"] = { + { "Approve AI Sugention", "i", "CTRL + g" }, + { "Change AI Option", "i", "CTRL + Up/Down" }, + { "Clear AI Sugention", "i", "CTRL + x" }, + }, + }, + + config = true, +} diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 570c4b2..a196f7e 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -51,6 +51,7 @@ pcode.extras = { tinydignostic = false, dressing = true, telescopediff = true, + cheatsheet = true, } -- activate config themes pcode.themes = { diff --git a/mysnippets/javascript/snippets.json b/mysnippets/javascript/snippets.json new file mode 100644 index 0000000..88f8aaa --- /dev/null +++ b/mysnippets/javascript/snippets.json @@ -0,0 +1,33 @@ +{ + "author": { + "prefix": "@author", + "body": [ + "/*", + "Author = Pojok Code", + "email = pojokcodeid@gmail.com", + "Github = https://github.com/pojokcodeid", + "Youtube = https://youtube.com/pojokcode", + "Date = $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}", + "File = $TM_FILENAME", + "note = Penyalahgunaan kode ini bukan tanggung jawab pojok code", + "*/", + "$1" + ], + "description": "Komentar Author" + }, + "/*": { + "prefix": "/*", + "body": ["/*", "* $1", "*/"], + "description": "Komentar" + }, + "/": { + "prefix": "/", + "body": "// $1", + "description": "Komentar" + }, + "function": { + "prefix": "function", + "body": ["function $1($2) {", "$0", "}"], + "description": "function" + } +} diff --git a/mysnippets/package.json b/mysnippets/package.json index e566872..1c7dc5f 100644 --- a/mysnippets/package.json +++ b/mysnippets/package.json @@ -8,8 +8,15 @@ { "language": "go", "path": "./go/snippets.json" + }, + { + "language": "javascript", + "path": "./javascript/snippets.json" + }, + { + "language": "typescript", + "path": "./javascript/snippets.json" } ] } } - From 37aa6dd7a7cfeb9781019ae05a8a06bfd17080ef Mon Sep 17 00:00:00 2001 From: pojok code Date: Sun, 6 Jul 2025 20:50:50 +0700 Subject: [PATCH 27/28] enc: add gemini chat --- lazy-lock.json | 8 +++---- lua/gemini/init.lua | 53 +++++++++++++++++++++++++++++++++++++++++ lua/pcode/core/init.lua | 4 ++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 lua/gemini/init.lua diff --git a/lazy-lock.json b/lazy-lock.json index a430e0c..34242b8 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -23,18 +23,18 @@ "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "6e3ee68bc9f65b21a21582a3d80e270c7e4f2992" }, + "gitsigns.nvim": { "branch": "main", "commit": "362fe61f9f19e9bceff178792780df5cce118a7d" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "73e0143385d8a2185944b42ed44d728b94ee19a3" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c2465eb07db648026eee81005a659abe26e6d077" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" }, - "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, + "neotest": { "branch": "master", "commit": "201edab09fc1657f24da203451a6f501539db460" }, "neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" }, "neotest-jest": { "branch": "main", "commit": "797515e113ac8e19c6855046d7f746d9c0c39c15" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, @@ -52,7 +52,7 @@ "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, - "nvim-lspconfig": { "branch": "master", "commit": "d8f03bfd5b54b10352276a0ed1f2ffe9c2e0676f" }, + "nvim-lspconfig": { "branch": "master", "commit": "1b6d7c3abf962cc392bcaf0dd7b92bdb9a1a5684" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, diff --git a/lua/gemini/init.lua b/lua/gemini/init.lua new file mode 100644 index 0000000..4b63a77 --- /dev/null +++ b/lua/gemini/init.lua @@ -0,0 +1,53 @@ +local M = {} +M.last_popup_win = nil +M.last_popup_buf = nil + +function M.ask_gemini() + -- Ambil path file buffer aktif + --[[ local buf_path = vim.api.nvim_buf_get_name(0) + if buf_path ~= "" then + local dir = vim.fn.fnamemodify(buf_path, ":h") + vim.api.nvim_set_current_dir(dir) + end ]] + + vim.ui.input({ prompt = "Prompt ke Gemini: " }, function(prompt) + if not prompt or prompt == "" then + vim.notify("Prompt kosong", vim.log.levels.WARN) + return + end + + M.show_popup("Loading...") + + vim.schedule(function() + local output = vim.fn.system('gemini --prompt "' .. prompt .. '"') + M.show_popup(output) + end) + end) +end + +function M.show_popup(output) + if M.last_popup_win and vim.api.nvim_win_is_valid(M.last_popup_win) then + vim.api.nvim_win_close(M.last_popup_win, true) + end + if M.last_popup_buf and vim.api.nvim_buf_is_valid(M.last_popup_buf) then + vim.api.nvim_buf_delete(M.last_popup_buf, { force = true }) + end + + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(output or "", "\n")) + local width = math.floor(vim.o.columns * 0.6) + local height = math.floor(vim.o.lines * 0.8) + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = width, + height = height, + row = math.floor((vim.o.lines - height) / 2), + col = math.floor((vim.o.columns - width) / 2), + style = "minimal", + border = "rounded", + }) + M.last_popup_win = win + M.last_popup_buf = buf +end + +return M diff --git a/lua/pcode/core/init.lua b/lua/pcode/core/init.lua index 7ef9ee4..786792e 100644 --- a/lua/pcode/core/init.lua +++ b/lua/pcode/core/init.lua @@ -3,3 +3,7 @@ require("pcode.user.default") require("pcode.config.lazy_lib") require("pcode.user.colorscheme") require("pcode.core.neovide") + +vim.keymap.set({ "n", "v", "x" }, "", function() + require("gemini").ask_gemini() +end, { noremap = true, silent = true, desc = "Prompt Gemini CLI" }) From bb6238e749041b2d19cbc6f1f1a97d9bc408325b Mon Sep 17 00:00:00 2001 From: Pojok Code Date: Tue, 8 Jul 2025 07:35:24 +0700 Subject: [PATCH 28/28] enc: update default config --- lazy-lock.json | 26 +------------------------- lua/pcode/user/default.lua | 14 +++++++------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 34242b8..3f8c8e9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,6 +1,5 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, "auto-bufferline.nvim": { "branch": "main", "commit": "2766951c88e7fdf667b25799771d209fe1f025f3" }, @@ -10,7 +9,6 @@ "auto-lualine.nvim": { "branch": "main", "commit": "9f0d6210344057eba2454113d3b07ef6eb58b5eb" }, "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "cheatsheet-nvim": { "branch": "main", "commit": "aaf8f4cc76e193997d0d0a27384cf09418fd7996" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, @@ -28,34 +26,17 @@ "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "c2465eb07db648026eee81005a659abe26e6d077" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, - "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" }, - "neotest": { "branch": "master", "commit": "201edab09fc1657f24da203451a6f501539db460" }, - "neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" }, - "neotest-jest": { "branch": "main", "commit": "797515e113ac8e19c6855046d7f746d9c0c39c15" }, - "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, - "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, - "neotest-vitest": { "branch": "main", "commit": "a6099e1fb55a2c2851da3dd0f4d510af9a234c92" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, - "npm-runner.nvim": { "branch": "main", "commit": "06d303e0a8ba384cd5fc35de6ba62d3500c99148" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "1c75a797b4017fec6491f509cf196c8c8833f26f" }, - "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, - "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, - "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, - "nvim-lspconfig": { "branch": "master", "commit": "1b6d7c3abf962cc392bcaf0dd7b92bdb9a1a5684" }, + "nvim-lspconfig": { "branch": "master", "commit": "7fac9025a967a4d0846660f751cd392fac6bb788" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, - "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, "nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" }, "nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" }, @@ -65,17 +46,12 @@ "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, - "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, "smart-splits.nvim": { "branch": "master", "commit": "c088d64c6e0e3221d24ef1f9337b5fe15557ddcc" }, - "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, - "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, - "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, - "vscode-js-debug": { "branch": "main", "commit": "f8f4253879aa6cd81e5c776a4f9a619771ec2fc3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" } } diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index a196f7e..38844e0 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -4,12 +4,12 @@ pcode.lang = { cpp = false, sql = false, deno = false, - golang = true, + golang = false, java = false, java2 = false, java3 = false, java4 = false, - javascript = true, + javascript = false, kotlin = false, markdown = false, php = false, @@ -31,13 +31,13 @@ pcode.extras = { rest = false, treesittercontex = false, codeium = true, - colorizer = true, + colorizer = false, dap = false, deviconcolor = true, illuminate = true, indentscupe = true, navic = true, - nvimmenu = true, + nvimmenu = false, rainbowdelimiters = true, scrollview = true, smartsplit = true, @@ -46,12 +46,12 @@ pcode.extras = { yanky = true, zenmode = false, lspsignatur = false, - telescopetreesiterinfo = true, + telescopetreesiterinfo = false, fidget = false, tinydignostic = false, dressing = true, - telescopediff = true, - cheatsheet = true, + telescopediff = false, + cheatsheet = false, } -- activate config themes pcode.themes = {