enc: add neocodeium config for replace codeium.vim

This commit is contained in:
Pojok Code 2025-07-12 17:23:58 +07:00
parent 64e62e59ba
commit 38bf58ad63
61 changed files with 2942 additions and 1051 deletions

View file

@ -67,14 +67,14 @@
## Basic Requirement ## Basic Requirement
2. Install Neovim 0.95+ https://github.com/neovim/neovim/releases/tag/stable 2. Install Neovim 0.95+ https://github.com/neovim/neovim/releases/tag/stable
3. C++ https://www.msys2.org/ 1. C++ https://www.msys2.org/
4. GIT https://git-scm.com/download/win 1. GIT https://git-scm.com/download/win
5. NodeJs https://nodejs.org/en/ 1. NodeJs https://nodejs.org/en/
6. Ripgrep https://github.com/BurntSushi/ripgrep 1. Ripgrep https://github.com/BurntSushi/ripgrep
7. Lazygit https://github.com/jesseduffield/lazygit 1. Lazygit https://github.com/jesseduffield/lazygit
8. Nerd Font https://www.nerdfonts.com/ or https://github.com/ryanoasis/nerd-fonts 1. 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 1. 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. Powershell (windows) https://apps.microsoft.com/store/detail/powershell/9MZ1SNWT0N5D?hl=en-id&gl=id
# Windows # Windows
@ -92,15 +92,21 @@ git clone https://github.com/pojokcodeid/neovim-starter.git ~/.config/nvim
# Uninstall # Uninstall
```bash ```bash
# Linux / Macos (unix) # Linux / MacOS (unix)
rm -rf ~/.config/nvim rm -rf ~/.config/nvim
rm -rf ~/.local/state/nvim
rm -rf ~/.local/share/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 # Windows CMD
rd -r ~\AppData\Local\nvim rd -r ~\AppData\Local\nvim
rd -r ~\AppData\Local\nvim-data rd -r ~\AppData\Local\nvim-data
# Window PowerShell # Windows PowerShell
rm -Force ~\AppData\Local\nvim rm -Force ~\AppData\Local\nvim
rm -Force ~\AppData\Local\nvim-data rm -Force ~\AppData\Local\nvim-data
``` ```

View file

@ -1,7 +1,6 @@
{ {
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
"LuaSnip": { "branch": "master", "commit": "66b5c2707e624dcd2cd3605676c64a2efe47e9d1" },
"alpha-nvim": { "branch": "main", "commit": "2b3cbcdd980cae1e022409289245053f62fb50f6" }, "alpha-nvim": { "branch": "main", "commit": "2b3cbcdd980cae1e022409289245053f62fb50f6" },
"auto-bufferline.nvim": { "branch": "main", "commit": "2766951c88e7fdf667b25799771d209fe1f025f3" }, "auto-bufferline.nvim": { "branch": "main", "commit": "2766951c88e7fdf667b25799771d209fe1f025f3" },
"auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" },
@ -17,38 +16,27 @@
"cmp-path": { "branch": "main", "commit": "e52e640b7befd8113b3350f46e8cfcfe98fcf730" }, "cmp-path": { "branch": "main", "commit": "e52e640b7befd8113b3350f46e8cfcfe98fcf730" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" },
"codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" },
"conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" },
"dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" },
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"gitsigns.nvim": { "branch": "main", "commit": "4666d040b60d1dc0e474ccd9a3fd3c4d67b4767c" }, "gitsigns.nvim": { "branch": "main", "commit": "4666d040b60d1dc0e474ccd9a3fd3c4d67b4767c" },
"inc-rename.nvim": { "branch": "main", "commit": "a3e31af13844534c66041ce92f29af7745883875" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"kulala.nvim": { "branch": "main", "commit": "9d3206dda077d24ef3e6a2e3578bc0c914b4944c" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"live-server.nvim": { "branch": "main", "commit": "e8a34bc37fc565c678addbb352a59aa6c1842c2b" },
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "7815740f4d0afb74ada00956c36e18ad695ed9e3" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "7815740f4d0afb74ada00956c36e18ad695ed9e3" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
"menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" },
"mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "neocodeium": { "branch": "main", "commit": "b4daf6805511681f83b37829e98f2d79418a93a6" },
"minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" },
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" }, "noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-colorizer.lua": { "branch": "master", "commit": "8a9b722257b5e6733c340c36f4bd8693e5f47de3" },
"nvim-dap": { "branch": "master", "commit": "cc77338e6e34c79f1c638f51ae4160dc9bfb05de" },
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
"nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" },
"nvim-lspconfig": { "branch": "master", "commit": "dbdb80d3bd311989d21029c63918d67a786d5013" }, "nvim-lspconfig": { "branch": "master", "commit": "dbdb80d3bd311989d21029c63918d67a786d5013" },
"nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" },
"nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" },
"nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" },
"nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" }, "nvim-tree.lua": { "branch": "master", "commit": "b0b49552c9462900a882fe772993b01d780445fe" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
@ -56,20 +44,11 @@
"nvim-web-devicons": { "branch": "master", "commit": "a1366758b3a232036dc97be8ca41184aa3f50506" }, "nvim-web-devicons": { "branch": "master", "commit": "a1366758b3a232036dc97be8ca41184aa3f50506" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" },
"refactoring.nvim": { "branch": "master", "commit": "74b608dfee827c2372250519d433cc21cb083407" },
"smart-splits.nvim": { "branch": "master", "commit": "30d645ed1eab77df9a5d9e98515316165b7d9ab9" }, "smart-splits.nvim": { "branch": "master", "commit": "30d645ed1eab77df9a5d9e98515316165b7d9ab9" },
"telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" },
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
"tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "51f548421f8a74680eff27d283c9d5ea6e8d0074" },
"toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" },
"vim-dadbod": { "branch": "master", "commit": "e95afed23712f969f83b4857a24cf9d59114c2e6" },
"vim-dadbod-completion": { "branch": "master", "commit": "a8dac0b3cf6132c80dc9b18bef36d4cf7a9e1fe6" },
"vim-dadbod-ui": { "branch": "master", "commit": "2900a1617b3df1a48683d872eadbe1101146a49a" },
"vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" },
"vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" },
"virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" },
"volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" },
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }
"zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" }
} }

View file

@ -65,7 +65,7 @@ local function gradle_new_project()
end, 4000) -- Delay is set in milliseconds (3,000ms = 3 seconds) end, 4000) -- Delay is set in milliseconds (3,000ms = 3 seconds)
end end
-- Run the delayed quit function -- Run the delayed quit function
-- delayed_quit() delayed_quit()
end end
end end

View file

@ -59,11 +59,11 @@ local function create_java_class()
-- Format direktori dan path file berdasarkan input pengguna -- Format direktori dan path file berdasarkan input pengguna
local package_dir = nil local package_dir = nil
if package_name then if package_name then
-- if is_maven_project() then if is_maven_project() then
package_dir = string.format("src/main/java/%s", package_name:gsub("%.", "/")) package_dir = string.format("src/main/java/%s", package_name:gsub("%.", "/"))
-- else else
-- package_dir = string.format("app/src/main/java/%s", package_name:gsub("%.", "/")) package_dir = string.format("app/src/main/java/%s", package_name:gsub("%.", "/"))
-- end end
if vim.fn.isdirectory(package_dir) == 0 then if vim.fn.isdirectory(package_dir) == 0 then
vim.fn.mkdir(package_dir, "p") vim.fn.mkdir(package_dir, "p")
end end

53
lua/gemini/init.lua Normal file
View file

@ -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

View file

@ -3,3 +3,7 @@ require("pcode.user.default")
require("pcode.config.lazy_lib") require("pcode.config.lazy_lib")
require("pcode.user.colorscheme") require("pcode.user.colorscheme")
require("pcode.core.neovide") require("pcode.core.neovide")
vim.keymap.set({ "n", "v", "x" }, "<C-i>", function()
require("gemini").ask_gemini()
end, { noremap = true, silent = true, desc = "Prompt Gemini CLI" })

View file

@ -1,7 +1,7 @@
return { return {
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
event = { "VeryLazy", "BufReadPre", "BufNewFile", "BufRead" }, event = { "CmdlineEnter", "BufReadPre", "BufNewFile", "BufRead" },
dependencies = { dependencies = {
{ "pojokcodeid/auto-lsp.nvim", lazy = true }, { "pojokcodeid/auto-lsp.nvim", lazy = true },
{ {

View file

@ -8,7 +8,7 @@ return {
lazy = true, lazy = true,
cmd = { cmd = {
"TSInstall", "TSInstall",
"TSInstallInfo", -- "TSInstallInfo",
"TSInstallSync", "TSInstallSync",
"TSUpdate", "TSUpdate",
"TSUpdateSync", "TSUpdateSync",
@ -42,6 +42,9 @@ return {
end, opts.ensure_installed) end, opts.ensure_installed)
end end
require("nvim-treesitter.configs").setup(opts) require("nvim-treesitter.configs").setup(opts)
vim.api.nvim_create_user_command("TSInstallInfo", function()
vim.cmd("Telescope treesitter_info")
end, {})
end, end,
}, },
} }

View file

@ -1,6 +1,6 @@
return { return {
"windwp/nvim-ts-autotag", "windwp/nvim-ts-autotag",
lazy = true, lazy = true,
event = { "BufRead", "VeryLazy" }, event = { "BufRead", "InsertEnter" },
opts = {}, opts = {},
} }

View file

@ -2,6 +2,8 @@ return {
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
event = "InsertEnter", event = "InsertEnter",
version = "v2.*",
build = "make install_jsregexp",
opts = { opts = {
history = true, history = true,
delete_check_events = "TextChanged", delete_check_events = "TextChanged",

View file

@ -91,7 +91,8 @@ return {
}, },
{ {
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-cmdline",
event = "VeryLazy", -- event = "VeryLazy",
event = "CmdlineEnter",
config = function() config = function()
local cmp = require("cmp") local cmp = require("cmp")
local mapping = { local mapping = {

View file

@ -12,15 +12,27 @@ local rfile = {
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt", cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css", scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css",
javascript = 'node "$dir/$fileName"', javascript = 'node "$dir/$fileName"',
go = "go run .", -- 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 { return {
"CRAG666/code_runner.nvim", "CRAG666/code_runner.nvim",
lazy = true, lazy = true,
cmd = { "RunCode", "RunFile", "RunProject", "RunClose" }, cmd = { "RunCode", "RunFile", "RunProject", "RunClose" },
opts = { opts = {
filetype = rfile, filetype = rfile,
project = runProject,
mode = "float", mode = "float",
focus = true, focus = true,
startinsert = true, startinsert = true,

View file

@ -4,7 +4,7 @@ return {
"williamboman/mason.nvim", "williamboman/mason.nvim",
"stevearc/conform.nvim", "stevearc/conform.nvim",
}, },
event = "VeryLazy", event = "BufRead",
opts = function(_, opts) opts = function(_, opts)
opts.formatters = opts.formatters or {} opts.formatters = opts.formatters or {}
opts.formatters_by_ft = opts.formatters_by_ft or {} opts.formatters_by_ft = opts.formatters_by_ft or {}
@ -37,4 +37,7 @@ return {
}) })
end, { desc = "Format file or range (in visual mode)" }) end, { desc = "Format file or range (in visual mode)" })
end, end,
keys = {
{ "<leader>l", "", desc = " 󰘦 Lsp" },
},
} }

View file

@ -0,0 +1,73 @@
return {
"pojokcodeid/cheatsheet-nvim",
event = "VeryLazy",
keys = {
{ "<F1>", "<cmd>KeymapsPopup<cr>", desc = "Keymaps Popup" },
},
cmd = { "KeymapsPopup" },
opts = {
["LSP"] = {
{ "LSP Code Action", "n", "<leader>la" },
{ "LSP Code Format", "n", "<leader>lf" },
{ "LSP Information", "n", "<leader>li" },
{ "Mason Information", "n", "<leader>lI" },
{ "LSP Next Diagnostic", "n", "<leader>lj" },
{ "LSP Previous Diagnostic", "n", "<leader>lk" },
{ "LSP Quickfix", "n", "<leader<lq" },
{ "LSP Rename", "n", "<leader>lr" },
{ "LSP Signature Help", "n", "<leader>ls" },
{ "LSP Format On Range", "v", "<leader>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", "<leader>tf" },
{ "Terminal Horizontal", "n", "<leader>th" },
{ "Terminal new tab", "n", "<leader>ts" },
{ "Terminal Vertical", "n", "<leader>tv" },
{ "Terminal Close", "n", "<leader>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<motion>" },
{ "Comment out text object block wise", "v", "gb<motion>" },
{ "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,
}

View file

@ -5,13 +5,16 @@ return {
dependencies = { dependencies = {
-- codeium -- codeium
{ {
"Exafunction/codeium.nvim", "Exafunction/windsurf.nvim",
cmd = "Codeium", cmd = "Codeium",
enabled = false, enabled = true,
build = ":Codeium Auth", build = ":Codeium Auth",
opts = { opts = {
enable_chat = true, enable_chat = true,
}, },
config = function(_, opts)
require("codeium").setup(opts)
end,
}, },
}, },
--@param opts cmp.ConfigSchema --@param opts cmp.ConfigSchema

View file

@ -0,0 +1,35 @@
return {
"pojokcodeid/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 = {
enabled = false,
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,
}

View file

@ -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,
}

View file

@ -1,6 +1,6 @@
local M = { local M = {
"RRethy/vim-illuminate", "RRethy/vim-illuminate",
event = "VeryLazy", event = "BufRead",
} }
M.opts = { M.opts = {

View file

@ -23,6 +23,10 @@ return {
"toggleterm", "toggleterm",
"Trouble", "Trouble",
"trouble", "trouble",
"term",
"terminal",
"zsh",
"keymaps_table",
}, },
callback = function() callback = function()
vim.b.miniindentscope_disable = true vim.b.miniindentscope_disable = true

View file

@ -1,6 +1,6 @@
local M = { local M = {
"SmiteshP/nvim-navic", "SmiteshP/nvim-navic",
event = "VeryLazy", event = "BufRead",
dependencies = { dependencies = {
"LunarVim/breadcrumbs.nvim", "LunarVim/breadcrumbs.nvim",
opts = {}, opts = {},

View file

@ -0,0 +1,20 @@
return {
"monkoose/neocodeium",
event = "VeryLazy",
config = function()
local neocodeium = require("neocodeium")
neocodeium.setup()
vim.keymap.set("i", "<C-g>", function()
neocodeium.accept()
end)
vim.keymap.set("i", "<c-Down>", function()
neocodeium.cycle()
end)
vim.keymap.set("i", "<c-Up>", function()
require("neocodeium").cycle(-1)
end)
vim.keymap.set("i", "<c-x>", function()
require("neocodeium").clear()
end)
end,
}

View file

@ -1,12 +1,13 @@
return { return {
{ {
"nvchad/menu", "nvzone/menu",
lazy = true, lazy = true,
event = { "VeryLazy" }, event = { "VeryLazy" },
dependencies = { dependencies = {
{ "nvchad/volt", lazy = true }, { "nvzone/volt", lazy = true },
{ "nvzone/showkeys", cmd = "ShowkeysToggle", lazy = true },
{ {
"nvchad/minty", "nvzone/minty",
cmd = { "Shades", "Huefy" }, cmd = { "Shades", "Huefy" },
lazy = true, lazy = true,
}, },
@ -22,10 +23,12 @@ return {
end, {}) end, {})
-- mouse users + nvimtree users! -- mouse users + nvimtree users!
vim.keymap.set("n", "<RightMouse>", function() vim.keymap.set({ "n", "v" }, "<RightMouse>", function()
require("menu.utils").delete_old_menus()
vim.cmd.exec('"normal! \\<RightMouse>"') vim.cmd.exec('"normal! \\<RightMouse>"')
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) require("menu").open(options, opts)
end, {}) end, {})
end, end,

View file

@ -2,6 +2,7 @@ return {
"hiphish/rainbow-delimiters.nvim", "hiphish/rainbow-delimiters.nvim",
lazy = true, lazy = true,
event = "BufRead", event = "BufRead",
branch = "master",
config = function() config = function()
-- Modul ini berisi beberapa definisi default -- Modul ini berisi beberapa definisi default
local rainbow_delimiters = require("rainbow-delimiters") local rainbow_delimiters = require("rainbow-delimiters")

View file

@ -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 = {
{
"<leader>sd",
function()
require("telescope").extensions.diff.diff_files({ hidden = true })
end,
desc = "Diff 2 Files",
},
{
"<leader>sD",
function()
require("telescope").extensions.diff.diff_current({ hidden = true })
end,
desc = "Diff Current File",
},
},
}

View file

@ -0,0 +1,22 @@
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",
-- signs = {
-- left = "",
-- right = "",
-- diag = "●",
-- arrow = "  ",
-- up_arrow = "  ",
-- vertical = " │",
-- vertical_end = " └",
-- },
blend = {
factor = 0.22,
},
})
end,
}

View file

@ -21,6 +21,8 @@ return {
"WinBar", "WinBar",
"WinBarNC", "WinBarNC",
"NotifyBackground", "NotifyBackground",
"TabLine",
"TabLineFill",
}, },
exclude_groups = { exclude_groups = {
-- disable active selection backgroun -- disable active selection backgroun
@ -53,6 +55,10 @@ return {
-- create auto command to set transparent -- create auto command to set transparent
vim.cmd("TransparentDisable") vim.cmd("TransparentDisable")
vim.cmd("TransparentEnable") 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, end,
}, },
{ {

View file

@ -1,9 +1,12 @@
return { return {
"mg979/vim-visual-multi", --[[ "mg979/vim-visual-multi",
event = { "BufRead", "InsertEnter", "BufNewFile" }, event = { "BufRead", "InsertEnter", "BufNewFile" },
branch = "master", branch = "master",
lazy = true, lazy = true,
init = function() 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_mouse_mappings = 1 -- equal CTRL + Left Click on VSCODE
vim.g.VM_maps = { vim.g.VM_maps = {
["Find Under"] = "<C-d>", -- equal CTRL+D on VSCODE ["Find Under"] = "<C-d>", -- equal CTRL+D on VSCODE
@ -13,5 +16,49 @@ return {
["Undo"] = "u", -- undo ["Undo"] = "u", -- undo
["Redo"] = "<C-r>", -- redo ["Redo"] = "<C-r>", -- redo
} }
end, ]]
{
"brenton-leighton/multiple-cursors.nvim",
version = "*",
opts = {},
event = { "BufRead", "InsertEnter", "BufNewFile" },
keys = {
-- 🧠 Seperti Ctrl + D di VS Code → pilih kata berikutnya yang sama
{
"<C-d>",
function()
vim.cmd("MultipleCursorsAddJumpNextMatch")
vim.schedule(function()
vim.notify(
"🖊️ Multiple cursor: menambahkan seleksi berikutnya",
vim.log.levels.INFO,
{ title = "MultipleCursors" }
)
end)
end, end,
mode = { "n", "x" },
desc = "Select next match",
},
-- 👇 Menambah kursor ke bawah seperti Ctrl + Alt + ↓
{ "<C-M-Down>", "<Cmd>MultipleCursorsAddDown<CR>", mode = { "n", "i", "x" }, desc = "Add cursor down" },
-- 👆 Menambah kursor ke atas seperti Ctrl + Alt + ↑
{ "<C-M-Up>", "<Cmd>MultipleCursorsAddUp<CR>", mode = { "n", "i", "x" }, desc = "Add cursor up" },
-- 🖱️ Tambah/hapus kursor dengan Ctrl + Klik mouse
{
"<M-LeftMouse>",
"<Cmd>MultipleCursorsMouseAddDelete<CR>",
mode = { "n", "i" },
desc = "Add/remove cursor with mouse",
},
-- 🔲 Tambah kursor ke seluruh baris visual yang dipilih (pakai Leader + m)
{ "<Leader>m", "<Cmd>MultipleCursorsAddVisualArea<CR>", mode = { "x" }, desc = "Add cursors to visual lines" },
-- 🔒 Lock semua kursor supaya siap edit serentak
{ "<Leader>L", "<Cmd>MultipleCursorsLock<CR>", mode = { "n", "x" }, desc = "Lock cursors" },
},
},
} }

View file

@ -11,6 +11,267 @@ return {
opts = function(_, opts) opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {} opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gopls" }) vim.list_extend(opts.ensure_installed, { "gopls" })
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, {})
-- 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, end,
}, },
{ {
@ -26,13 +287,14 @@ return {
"pojokcodeid/auto-lint.nvim", "pojokcodeid/auto-lint.nvim",
opts = function(_, opts) opts = function(_, opts)
opts.linters_by_ft = opts.linters_by_ft or {} opts.linters_by_ft = opts.linters_by_ft or {}
vim.list_extend(opts.ensure_installed, { "ast-grep" }) vim.list_extend(opts.ensure_installed, { "golangci-lint" })
opts.linters_by_ft.php = { "ast-grep" } opts.linters_by_ft.php = { "golangci-lint" }
end, end,
}, },
{ {
"nvim-neotest/neotest", "nvim-neotest/neotest",
event = "VeryLazy", event = "VeryLazy",
ft = "go",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim", "antoinemadec/FixCursorHold.nvim",

View file

@ -1,11 +1,4 @@
local M = {} local M = {}
local is_gradle = function()
if vim.fn.findfile("pom.xml", vim.fn.getcwd()) == "pom.xml" then
return false
else
return true
end
end
M = { M = {
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
@ -49,8 +42,9 @@ M = {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
"andy-bell101/neotest-java", "andy-bell101/neotest-java",
}, },
enabled = is_gradle(), -- enabled = vim.fn.findfile("build.gradle", vim.fn.getcwd()) == "build.gradle" or false,
config = function() config = function()
require("auto-jdtls.create_maven_project")
require("neotest").setup({ require("neotest").setup({
adapters = { adapters = {
require("neotest-java"), require("neotest-java"),
@ -112,38 +106,6 @@ M = {
{ "<leader>Js", "<cmd>SymbolsOutline<cr>", desc = "Toggle Outline" }, { "<leader>Js", "<cmd>SymbolsOutline<cr>", desc = "Toggle Outline" },
}, },
}, },
-- project.nvim [project search + auto cd]
-- https://github.com/ahmedkhalf/project.nvim
{
"zeioth/project.nvim",
cmd = "ProjectRoot",
ft = { "java" },
-- enabled = vim.fn.findfile("build.gradle", vim.fn.getcwd()) == "build.gradle" or false,
opts = {
-- How to find root directory
patterns = {
"build.gradle",
"pom.xml",
},
-- Don't list the next projects
exclude_dirs = {
"~/",
},
silent_chdir = true,
manual_mode = false,
-- Don't chdir for certain buffers
exclude_chdir = {
filetype = { "", "OverseerList", "alpha" },
buftype = { "nofile", "terminal" },
},
--ignore_lsp = { "lua_ls" },
},
config = function(_, opts)
require("project_nvim").setup(opts)
end,
},
} }
return M return M

View file

@ -0,0 +1,47 @@
return {
"nvim-java/nvim-java",
-- event = "VeryLazy",
ft = { "java" },
dependencies = {
"MunifTanjim/nui.nvim",
"neovim/nvim-lspconfig",
"mfussenegger/nvim-dap",
"williamboman/mason.nvim",
},
config = function()
require("java").setup({
notifications = {
dap = false,
},
jdk = {
auto_install = false,
},
})
require("lspconfig").jdtls.setup({
settings = {
java = {
configuration = {
runtimes = {
{
name = "JavaSE-17",
path = os.getenv("JAVA_HOME") or "",
default = true,
},
},
},
},
},
})
end,
keys = {
{ "<leader>rg", "", desc = "Gradle" },
{ "<leader>rgp", "<cmd>JavaProfile<cr>", desc = "Java Profile" },
{ "<leader>rgg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle" },
{ "<leader>rgb", "<cmd>JavaBuildBuildWorkspace<cr>", desc = "Java Build Workspace" },
{ "<leader>rgd", "<cmd>JavaDapConfig<cr>", desc = "Java Configure DAP" },
{ "<leader>T", "", desc = "Test" },
{ "<leader>Tc", "<cmd>JavaTestRunCurrentClass<cr>", desc = "Test Current Class" },
{ "<leader>Tm", "<cmd>JavaTestRunCurrentMethod<cr>", desc = "Test Current Method" },
{ "<leader>Th", "<cmd>JavaTestViewLastReport<cr>", desc = "View Test Last Report" },
},
}

View file

@ -0,0 +1,32 @@
return {
"nvim-java/nvim-java",
-- ft = { "java" },
dependencies = {
"MunifTanjim/nui.nvim",
"neovim/nvim-lspconfig",
"mfussenegger/nvim-dap",
"williamboman/mason.nvim",
},
opts = {
notifications = {
dap = false,
},
jdk = {
auto_install = false,
},
-- NOTE: One of these files must be in your project root directory.
-- Otherwise the debugger will end in the wrong directory and fail.
root_markers = {
"settings.gradle",
"settings.gradle.kts",
"pom.xml",
"build.gradle",
"mvnw",
"gradlew",
"build.gradle",
"build.gradle.kts",
".git",
},
},
}

View file

@ -4,10 +4,7 @@ local M = {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = function(_, opts) opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {} opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend( vim.list_extend(opts.ensure_installed, { "html", "javascript", "typescript", "tsx", "css", "json", "jsonc" })
opts.ensure_installed,
{ "html", "javascript", "typescript", "tsx", "css", "json", "jsonc" }
)
end, end,
}, },
{ {
@ -33,7 +30,9 @@ local M = {
"antoinemadec/FixCursorHold.nvim", "antoinemadec/FixCursorHold.nvim",
"nvim-neotest/neotest-jest", "nvim-neotest/neotest-jest",
"nvim-neotest/nvim-nio", "nvim-neotest/nvim-nio",
"marilari88/neotest-vitest",
}, },
ft = { "javascript", "typescript", "javascriptreact", "typescriptreact" },
opts = { opts = {
adapters = { adapters = {
["neotest-jest"] = { ["neotest-jest"] = {
@ -53,6 +52,7 @@ local M = {
return vim.fn.getcwd() return vim.fn.getcwd()
end, end,
}, },
["neotest-vitest"] = {},
}, },
status = { virtual_text = true }, status = { virtual_text = true },
output = { open_on_run = true }, output = { open_on_run = true },
@ -63,8 +63,7 @@ local M = {
virtual_text = { virtual_text = {
format = function(diagnostic) format = function(diagnostic)
-- Replace newline and tab characters with space for more compact diagnostics -- Replace newline and tab characters with space for more compact diagnostics
local message = local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
return message return message
end, end,
}, },
@ -112,6 +111,40 @@ local M = {
{ "<Leader>TS", function() require("neotest").run.stop() end, desc = "Stop" }, { "<Leader>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 = "<leader>nm",
hide_mapping = "<leader>nh",
width = 70,
height = 20,
},
},
keys = {
{ "<leader>n", "", desc = "  Npm" },
},
config = function(_, opts)
require("npm-runner").setup(opts.command, opts.opt)
end,
},
{ {
"rcarriga/nvim-dap-ui", "rcarriga/nvim-dap-ui",
lazy = true, lazy = true,

View file

@ -1,16 +1,3 @@
local function get_default_package()
local curr_file = vim.fn.expand("%:t")
curr_file = curr_file:gsub(".kt", "")
local path = vim.fn.expand("%:p:h")
local project_root = vim.fn.getcwd()
local relative_path = path:sub(#project_root + 1)
relative_path = relative_path:gsub("app\\src\\test\\kotlin\\", "")
relative_path = relative_path:gsub("app/src/test/kotlin/", "")
relative_path = relative_path:gsub("\\", ".")
relative_path = relative_path:gsub("/", ".")
return relative_path:sub(2) .. "." .. curr_file
end
return { return {
-- install treesitter -- install treesitter
{ {
@ -131,6 +118,7 @@ return {
{ {
"<leader>Tu", "<leader>Tu",
function() function()
-- local current_word = vim.fn.expand("<cword>")
local current_word = "" local current_word = ""
local input = vim.fn.getline(".") local input = vim.fn.getline(".")
current_word = all_trim((input:gsub("class", "")):gsub("{", "")) -- hilangkan bagian class current_word = all_trim((input:gsub("class", "")):gsub("{", "")) -- hilangkan bagian class
@ -138,30 +126,10 @@ return {
current_word = current_word:gsub("%(%)", "") current_word = current_word:gsub("%(%)", "")
current_word = current_word:gsub("{", "") current_word = current_word:gsub("{", "")
current_word = current_word:gsub("@Test", "") current_word = current_word:gsub("@Test", "")
require("notify").notify( vim.cmd("terminal gradle test --tests *." .. all_trim(current_word))
'gradle test --tests "' .. get_default_package() .. "." .. all_trim(current_word) .. '"',
"info"
)
vim.fn.jobstart("gradle cleanTest", {
on_exit = function()
vim.cmd('terminal gradle test --tests "' .. get_default_package() .. "." .. all_trim(current_word) .. '"')
end,
})
end, end,
desc = "Run Under Cursor", desc = "Run Under Cursor",
}, },
{
"<leader>Tf",
function()
require("notify").notify('gradle test --tests "' .. get_default_package() .. '"', "info")
vim.fn.jobstart("gradle cleanTest", {
on_exit = function()
vim.cmd('terminal gradle test --tests "' .. get_default_package() .. '"')
end,
})
end,
desc = "Run Current File",
},
{ "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle", mode = "n" }, { "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle", mode = "n" },
}, },
}, },

View file

@ -3,6 +3,7 @@ return {
lazy = true, lazy = true,
event = "VeryLazy", event = "VeryLazy",
keys = { keys = {
{ "<leader>u", "", desc = " 󰀦 Notify" },
{ {
"<leader>uN", "<leader>uN",
function() function()
@ -19,7 +20,7 @@ return {
max_width = function() max_width = function()
return math.floor(vim.o.columns * 0.4) return math.floor(vim.o.columns * 0.4)
end, end,
render = "wrapped-default", render = "wrapped-compact",
-- background_colour = "#00000000", -- background_colour = "#00000000",
}, },
config = function(_, opts) config = function(_, opts)

View file

@ -2,9 +2,8 @@ return {
"pojokcodeid/auto-lint.nvim", "pojokcodeid/auto-lint.nvim",
dependencies = { dependencies = {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
event = "VeryLazy",
}, },
event = "VeryLazy", event = "BufRead",
opts = function(_, opts) opts = function(_, opts)
opts.map_lang = opts.map_lang or {} opts.map_lang = opts.map_lang or {}
opts.map_name = opts.map_name or {} opts.map_name = opts.map_name or {}

View file

@ -6,9 +6,24 @@ return {
}, },
opts = function(_, opts) opts = function(_, opts)
local icons = require("pcode.user.icons") local icons = require("pcode.user.icons")
opts.disable_netrw = true opts.auto_reload_on_write = false
opts.hijack_cursor = true 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.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 = { opts.update_focused_file = {
enable = true, enable = true,
update_root = false, update_root = false,
@ -112,6 +127,44 @@ return {
return opts return opts
end, end,
config = function(_, opts) 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) require("nvim-tree").setup(opts)
local api = require("nvim-tree.api") local api = require("nvim-tree.api")
api.events.subscribe(api.events.Event.FileCreated, function(file) api.events.subscribe(api.events.Event.FileCreated, function(file)

View file

@ -36,11 +36,15 @@ return {
operators = {}, operators = {},
-- miscs = {}, -- Uncomment to turn off hard-coded styles -- miscs = {}, -- Uncomment to turn off hard-coded styles
}, },
color_overrides = {}, color_overrides = {
all = {
mantle = "#1e1e2e",
},
},
custom_highlights = function(colors) custom_highlights = function(colors)
return { return {
NvimTreeNormal = { fg = colors.text, bg = transparent and colors.none or colors.base }, 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 }, Pmenu = { fg = colors.text, bg = transparent and colors.none or colors.base },
WhichKeyFloat = { 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 }, WhichKey = { fg = colors.text, bg = transparent and colors.none or colors.base },
@ -48,7 +52,9 @@ return {
NormalFloat = { fg = colors.text, bg = transparent and colors.none or colors.base }, NormalFloat = { fg = colors.text, bg = transparent and colors.none or colors.base },
Normal = { 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 }, 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, end,
highlight_overrides = { highlight_overrides = {
@ -60,6 +66,7 @@ return {
}, },
default_integrations = true, default_integrations = true,
integrations = { integrations = {
bufferline = true,
cmp = true, cmp = true,
gitsigns = true, gitsigns = true,
nvimtree = true, nvimtree = true,

View file

@ -50,6 +50,7 @@ return {
LspReferenceWrite = { bg = "#3b4261" }, LspReferenceWrite = { bg = "#3b4261" },
WinBar = { bg = colors.bg }, WinBar = { bg = colors.bg },
WinBarNC = { fg = colors.fg, bg = colors.bg }, WinBarNC = { fg = colors.fg, bg = colors.bg },
MasonBackdrop = { link = "NormalFloat" },
}, },
transparent_bg = false, transparent_bg = false,
} }

View file

@ -21,7 +21,9 @@ return {
hi(0, "WinBar", { bg = color.background }) hi(0, "WinBar", { bg = color.background })
hi(0, "WinBarNC", { bg = color.background }) hi(0, "WinBarNC", { bg = color.background })
hi(0, "NormalFloat", { bg = color.background }) hi(0, "NormalFloat", { bg = color.background })
hi(0, "TabLine", { bg = color.background })
hi(0, "NormalNC", { 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.javascript", { fg = color.punctuation })
hi(0, "@tag.delimiter.tsx", { fg = color.punctuation }) hi(0, "@tag.delimiter.tsx", { fg = color.punctuation })
-- git -- git

View file

@ -53,6 +53,7 @@ return {
specs = {}, specs = {},
groups = { groups = {
all = { all = {
MasonBackdrop = { link = "NormalFloat" },
illuminatedWord = { bg = "#3b4261" }, illuminatedWord = { bg = "#3b4261" },
illuminatedCurWord = { bg = "#3b4261" }, illuminatedCurWord = { bg = "#3b4261" },
IlluminatedWordText = { bg = "#3b4261" }, IlluminatedWordText = { bg = "#3b4261" },

View file

@ -18,6 +18,7 @@ return {
["FoldColumn"] = { bg = "NONE" }, ["FoldColumn"] = { bg = "NONE" },
["Folded"] = { bg = "NONE" }, ["Folded"] = { bg = "NONE" },
["SignColumn"] = { bg = "NONE" }, ["SignColumn"] = { bg = "NONE" },
["MasonBackdrop"] = { link = "NormalFloat" },
}, },
} }
end, end,

View file

@ -33,6 +33,7 @@ return {
hi(0, "TelescopePromptNormal", { bg = colors.dark, fg = colors.grey }) hi(0, "TelescopePromptNormal", { bg = colors.dark, fg = colors.grey })
hi(0, "TelescopePromptPrefix", { bg = colors.dark, fg = colors.red }) hi(0, "TelescopePromptPrefix", { bg = colors.dark, fg = colors.red })
hi(0, "TelescopeResultsTitle", { bg = colors.olive_green, fg = colors.very_dark_gray }) hi(0, "TelescopeResultsTitle", { bg = colors.olive_green, fg = colors.very_dark_gray })
hi(0, "MasonBackdrop", { link = "NormalFloat" })
end, end,
}) })
local colorscheme = pcode.themes.jetbrains or "darcula-dark" local colorscheme = pcode.themes.jetbrains or "darcula-dark"

View file

@ -116,6 +116,7 @@ return {
NormalNC = { 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}" }, FloatBorder = { fg = "${fg}", bg = is_transparent and "NONE" or "${bg}" },
NonText = { bg = "NONE", fg = "#3E4450" }, NonText = { bg = "NONE", fg = "#3E4450" },
MasonBackdrop = { link = "NormalFloat" },
}, },
}) })
local colorscheme = pcode.themes.onedarkpro or "onedark" local colorscheme = pcode.themes.onedarkpro or "onedark"

View file

@ -12,6 +12,7 @@ return {
-- custom hilights -- custom hilights
local hi = vim.api.nvim_set_hl local hi = vim.api.nvim_set_hl
hi(0, "FoldColumn", { bg = colors.bg2 }) hi(0, "FoldColumn", { bg = colors.bg2 })
hi(0, "MasonBackdrop", { link = "NormalFloat" })
end, end,
}) })
end, end,

View file

@ -71,6 +71,7 @@ return {
highlights["@tag.attribute"] = { fg = colors.green1, italic = true } highlights["@tag.attribute"] = { fg = colors.green1, italic = true }
-- highlights["@keyword.function"] = { fg = colors.blue, italic = true } -- highlights["@keyword.function"] = { fg = colors.blue, italic = true }
-- highlights["@function"] = { fg = colors.blue, italic = true } -- highlights["@function"] = { fg = colors.blue, italic = true }
highlights.MasonBackdrop = { link = "NormalFloat" }
end, end,
}) })
end, end,

View file

@ -3,12 +3,12 @@ local api = vim.api
-- General Settings -- General Settings
api.nvim_create_augroup("_general_settings", { clear = true }) api.nvim_create_augroup("_general_settings", { clear = true })
api.nvim_create_autocmd("TextYankPost", { -- api.nvim_create_autocmd("TextYankPost", {
group = "_general_settings", -- group = "_general_settings",
callback = function() -- callback = function()
require("vim.highlight").on_yank({ higroup = "Visual", timeout = 200 }) -- require("vim.highlight").on_yank({ higroup = "Visual", timeout = 200 })
end, -- end,
}) -- })
api.nvim_create_autocmd("FileType", { api.nvim_create_autocmd("FileType", {
group = "_general_settings", group = "_general_settings",
@ -124,3 +124,264 @@ vim.api.nvim_create_autocmd("ExitPre", {
-- vim.api.nvim_set_keymap("n", "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", { noremap = true, silent = true }) -- vim.api.nvim_set_keymap("n", "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", { noremap = true, silent = true })
-- end, -- 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" })
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" })

View file

@ -47,7 +47,23 @@ return {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
opts = function(_, opts) opts = function(_, opts)
vim.list_extend(opts.skip_config, {}) 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, end,
}, },
-- add whichkey mappings -- add whichkey mappings

View file

@ -2,11 +2,13 @@
pcode.lang = { pcode.lang = {
angular = false, angular = false,
cpp = false, cpp = false,
sql = true, sql = false,
deno = false, deno = false,
golang = false, golang = false,
java = false, java = false,
java2 = false,
java3 = false, java3 = false,
java4 = false,
javascript = false, javascript = false,
kotlin = false, kotlin = false,
markdown = false, markdown = false,
@ -20,43 +22,49 @@ pcode.lang = {
pcode.extras = { pcode.extras = {
autosave = false, autosave = false,
bigfiles = false, bigfiles = false,
codeium = false,
codeiumnvim = false, codeiumnvim = false,
liveserver = true, neocodeium = true,
liveserver = false,
minianimate = false, minianimate = false,
neoscroll = false, neoscroll = false,
nvimufo = false, nvimufo = false,
refactoring = true, refactoring = false,
rest = true, rest = false,
treesittercontex = false, treesittercontex = false,
codeium = true, colorizer = false,
colorizer = true, dap = false,
dap = true, deviconcolor = false,
deviconcolor = true,
illuminate = true, illuminate = true,
indentscupe = true, indentscupe = false,
navic = true, navic = true,
nvimmenu = true, nvimmenu = false,
rainbowdelimiters = true, rainbowdelimiters = true,
scrollview = true, scrollview = false,
smartsplit = true, smartsplit = true,
verticalcolumn = true, verticalcolumn = true,
visualmulti = true, visualmulti = true,
yanky = true, yanky = true,
zenmode = true, zenmode = false,
lspsignatur = false, lspsignatur = false,
telescopetreesiterinfo = true, telescopetreesiterinfo = false,
fidget = false,
tinydignostic = false,
dressing = true,
telescopediff = false,
cheatsheet = false,
} }
-- activate config themes -- activate config themes
pcode.themes = { pcode.themes = {
-- note: open remark only one -- note: open remark only one
-- **:: Eva Theme ::** -- -- **:: Eva Theme ::** --
evatheme = "Eva-Dark", -- evatheme = "Eva-Dark",
-- evatheme = "Eva-Dark-Italic", -- evatheme = "Eva-Dark-Italic",
-- evatheme = "Eva-Dark-Bold", -- evatheme = "Eva-Dark-Bold",
-- evatheme = "Eva-Light", -- evatheme = "Eva-Light",
-- --
-- **:: Dracula Theme ::** -- -- **:: Dracula Theme ::** --
-- dracula = "dracula", dracula = "dracula",
-- dracula = "dracula-soft", -- dracula = "dracula-soft",
-- --
-- **:: Onedarkpro Theme ::** -- -- **:: Onedarkpro Theme ::** --
@ -93,3 +101,4 @@ pcode.themes = {
pcode.transparent = false pcode.transparent = false
pcode.localcode = true pcode.localcode = true
pcode.snippets_path = vim.fn.stdpath("config") .. "/mysnippets" pcode.snippets_path = vim.fn.stdpath("config") .. "/mysnippets"
pcode.nvimtree_float = false

View file

@ -2,7 +2,8 @@ return {
kind = { kind = {
Boolean = "󰨙", Boolean = "󰨙",
Color = "", Color = "",
Codeium = "󰘦", -- Codeium = "󰘦",
Codeium = "󰁨",
Control = "", Control = "",
Collapsed = "", Collapsed = "",
Component = "󰅴", Component = "󰅴",

View file

@ -1,4 +1,3 @@
require("auto-jdtls2.create_gradle_project") require("auto-jdtls2.create_gradle_project")
require("auto-jdtls2.create_maven_project") require("auto-jdtls2.create_maven_project")
require("auto-jdtls2.create_springboot_project") require("auto-jdtls2.create_springboot_project")
require("auto-jdtls2.generate_java_class")

View file

@ -1,5 +1,6 @@
-- definiskanfunction name -- 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 } local opts = { noremap = true, silent = true }
-- Remap space leader keys -- Remap space leader keys
@ -19,13 +20,17 @@ for _, mode in ipairs({ "i", "v", "n", "x" }) do
-- duplicate line -- duplicate line
keymap(mode, "<S-Down>", "<cmd>t.<cr>", opts) keymap(mode, "<S-Down>", "<cmd>t.<cr>", opts)
keymap(mode, "<S-Up>", "<cmd>t -1<cr>", opts) keymap(mode, "<S-Up>", "<cmd>t -1<cr>", opts)
keymap(mode, "<S-M-Down>", "<cmd>t.<cr>", opts)
keymap(mode, "<S-M-Up>", "<cmd>t -1<cr>", opts)
-- save file -- save file
keymap(mode, "<C-s>", "<cmd>silent! w<cr>", opts) keymap(mode, "<C-s>", "<cmd>silent! w<cr>", opts)
end end
-- duplicate line visual block -- duplicate line visual block
keymap("x", "<S-Down>", ":'<,'>t'><cr>", opts) keymap("x", "<S-Down>", ":'<,'>t'><cr>", opts)
keymap("x", "<S-M-Down>", ":'<,'>t'><cr>", opts)
keymap("x", "<S-Up>", ":'<,'>t-1<cr>", opts) keymap("x", "<S-Up>", ":'<,'>t-1<cr>", opts)
keymap("x", "<S-M-Up>", ":'<,'>t-1<cr>", opts)
-- move text up and down -- move text up and down
keymap("x", "<A-Down>", ":move '>+1<CR>gv-gv", opts) keymap("x", "<A-Down>", ":move '>+1<CR>gv-gv", opts)
@ -35,15 +40,43 @@ keymap("i", "<M-Down>", "<cmd>m+<cr>", opts)
keymap("n", "<M-Up>", "<cmd>m-2<cr>", opts) keymap("n", "<M-Up>", "<cmd>m-2<cr>", opts)
keymap("i", "<M-Up>", "<cmd>m-2<cr>", opts) keymap("i", "<M-Up>", "<cmd>m-2<cr>", opts)
-- create comment CTRL + / all mode -- create comment CTRL + / visual block mode
keymap("v", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts) keymap("x", "<C-_>", function()
keymap("v", "<C-/>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts) vim.api.nvim_feedkeys("gb", "v", true)
keymap("i", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts) end, opts)
keymap("i", "<C-/>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts) -- create comment CTRL + / normal mode
keymap("i", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts) keymap("i", "<C-_>", function()
keymap("i", "<C-/>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts) vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "n", true)
keymap("n", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts) -- Toggle comment baris
keymap("n", "<C-/>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts) 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("<Right><leader>", true, false, true), "n", true)
end)
end, opts)
-- create comment CTRL + / normal mode
keymap("n", "<C-_>", 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("<Right><leader>", true, false, true), "n", true)
end)
end, opts)
-- close windows -- close windows
keymap("n", "q", "<cmd>q<cr>", opts) keymap("n", "q", "<cmd>q<cr>", opts)
@ -91,3 +124,27 @@ keymap("n", "<A-l>", "<cmd>terminal live-server<cr>", opts)
-- close current buffer -- close current buffer
keymap("n", "<S-t>", "<cmd>lua require('auto-bufferline.configs.utils').bufremove()<cr>", opts) keymap("n", "<S-t>", "<cmd>lua require('auto-bufferline.configs.utils').bufremove()<cr>", opts)
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, {})

262
lua/pcode/user/npmrun.lua Normal file
View file

@ -0,0 +1,262 @@
local last_modal = nil -- global modal manager instance
local function modal_manager(opts)
opts = opts or {}
local win_id = nil
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
vim.api.nvim_win_close(win_id, true)
win_id = nil
end
is_shown = false
end
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
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
ever_shown = true
end
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
-- Hanya auto open saat pertama kali, tidak auto open setelah pernah di-close/hide
local function set_content(content)
last_content = content
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 {
show = show,
hide = hide,
update = update,
close = close,
set_content = set_content,
is_shown = function()
return is_shown
end,
}
end
local M = {}
M._last_modal = nil
local function log(message, level)
vim.notify(string.format("npm-dev-runner: %s", message), vim.log.levels[level])
end
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
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
local default_opts = {
show_mapping = "<leader>nm",
hide_mapping = "<leader>nh",
}
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
-- 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)
local cmd_str = conf.cmd or "npm run dev"
local cache = {}
local function do_start(dir)
if is_running(dir, cache) then
log(cmd_str .. " already running", "INFO")
return
end
local all_output = {}
local modal = modal_manager(opts)
last_modal = modal
M._last_modal = modal
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 _, l in ipairs(lines) do
table.insert(all_output, tostring(l))
end
modal.set_content(table.concat(all_output, "\n"))
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,
})
cache[dir] = { job_id = job_id, modal = modal }
log(cmd_str .. " started", "INFO")
end
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
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
return M

171
lua/pcode/user/npmrun2.lua Normal file
View file

@ -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

174
lua/pcode/user/npmrun3.lua Normal file
View file

@ -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

158
lua/pcode/user/npmrun4.lua Normal file
View file

@ -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

View file

@ -61,7 +61,7 @@ vim.loader.enable()
-- Disable statusline in dashboard -- Disable statusline in dashboard
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { "mysql", "dbout", "dbui", "http", "httpResult" }, pattern = { "dbout", "dbui", "http", "httpResult", "checkhealth", "qf", "help", "lazy" },
callback = function() callback = function()
local opt = vim.opt local opt = vim.opt
opt.number = false -- Print line number opt.number = false -- Print line number

View file

@ -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"
}
}

View file

@ -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"
}
}

View file

@ -4,6 +4,18 @@
{ {
"language": "html", "language": "html",
"path": "./html/snippets.json" "path": "./html/snippets.json"
},
{
"language": "go",
"path": "./go/snippets.json"
},
{
"language": "javascript",
"path": "./javascript/snippets.json"
},
{
"language": "typescript",
"path": "./javascript/snippets.json"
} }
] ]
} }