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