From fa09a7248eb33413529e60068ce29296c06ce008 Mon Sep 17 00:00:00 2001 From: pojok code Date: Sat, 28 Jun 2025 23:42:52 +0700 Subject: [PATCH] enc: update key mapping for comment --- lazy-lock.json | 10 +-- lua/pcode/plugins/theme/catppuccin.lua | 12 ++- lua/pcode/user/default.lua | 4 +- lua/pcode/user/keymaps.lua | 102 ++++++++++--------------- mysnippets/go/snippets.json | 48 ++++++++++++ mysnippets/package.json | 7 +- 6 files changed, 109 insertions(+), 74 deletions(-) create mode 100644 mysnippets/go/snippets.json diff --git a/lazy-lock.json b/lazy-lock.json index 3f4aa5e..bdc86ce 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,10 +1,9 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "Eva-Theme.nvim": { "branch": "master", "commit": "9d743346eb0e7647d79468fff6f57352cd102655" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, - "auto-bufferline.nvim": { "branch": "main", "commit": "f5835a4b62bfb6f6c829f8f050e5102ccf230b3e" }, + "auto-bufferline.nvim": { "branch": "main", "commit": "2766951c88e7fdf667b25799771d209fe1f025f3" }, "auto-conform.nvim": { "branch": "main", "commit": "5f0897235e84bf2f8ff9d634e81678d5bfa63ab8" }, "auto-lint.nvim": { "branch": "main", "commit": "aff13cb8eaa055e66e940d43b7d83166397e5413" }, "auto-lsp.nvim": { "branch": "main", "commit": "ea80aef3ac630d310c2643047aaa7d7747d207a1" }, @@ -20,6 +19,7 @@ "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, "conform.nvim": { "branch": "master", "commit": "8132ec733eed3bf415b97b76797ca41b59f51d7d" }, + "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "1b0350ab707713b2bc6c236151f1a324175347b1" }, @@ -33,7 +33,7 @@ "mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" }, - "neotest-golang": { "branch": "main", "commit": "0a0acff3cf9a0bf140c84ea9e66d818df7c2608f" }, + "neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" }, "neotest-jest": { "branch": "main", "commit": "dd82016c01704d9bbd5188749fe0586b3b620693" }, "neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, @@ -44,7 +44,7 @@ "nvim-autopairs": { "branch": "master", "commit": "2647cce4cb64fb35c212146663384e05ae126bdf" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" }, + "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, @@ -64,7 +64,7 @@ "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, - "smart-splits.nvim": { "branch": "master", "commit": "0098e376638602bc6aaf779bb8531b840a3fe26e" }, + "smart-splits.nvim": { "branch": "master", "commit": "039b1c280b849cc23190e94285083af9c2020596" }, "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, diff --git a/lua/pcode/plugins/theme/catppuccin.lua b/lua/pcode/plugins/theme/catppuccin.lua index b4e5c68..d37df00 100644 --- a/lua/pcode/plugins/theme/catppuccin.lua +++ b/lua/pcode/plugins/theme/catppuccin.lua @@ -36,11 +36,15 @@ return { operators = {}, -- miscs = {}, -- Uncomment to turn off hard-coded styles }, - color_overrides = {}, + color_overrides = { + all = { + mantle = "#1e1e2e", + }, + }, custom_highlights = function(colors) return { NvimTreeNormal = { fg = colors.text, bg = transparent and colors.none or colors.base }, - NvimTreeWinSeparator = { fg = colors.mantle, bg = transparent and colors.none or colors.none }, + NvimTreeWinSeparator = { fg = "#181825", bg = transparent and colors.none or colors.none }, Pmenu = { fg = colors.text, bg = transparent and colors.none or colors.base }, WhichKeyFloat = { fg = colors.text, bg = transparent and colors.none or colors.base }, WhichKey = { fg = colors.text, bg = transparent and colors.none or colors.base }, @@ -48,7 +52,8 @@ return { NormalFloat = { fg = colors.text, bg = transparent and colors.none or colors.base }, Normal = { fg = colors.text, bg = transparent and colors.none or colors.base }, NormalNC = { fg = colors.text, bg = transparent and colors.none or colors.base }, - StatusLine = { fg = colors.text, bg = colors.none }, + TabLine = { fg = colors.text, bg = transparent and colors.none or colors.base }, + StatusLine = { fg = colors.text, bg = transparent and colors.none or colors.base }, MasonBackdrop = { link = "NormalFloat" }, } end, @@ -61,6 +66,7 @@ return { }, default_integrations = true, integrations = { + bufferline = true, cmp = true, gitsigns = true, nvimtree = true, diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index d151a30..570c4b2 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -56,13 +56,13 @@ pcode.extras = { pcode.themes = { -- note: open remark only one -- **:: Eva Theme ::** -- - evatheme = "Eva-Dark", + -- evatheme = "Eva-Dark", -- evatheme = "Eva-Dark-Italic", -- evatheme = "Eva-Dark-Bold", -- evatheme = "Eva-Light", -- -- **:: Dracula Theme ::** -- - -- dracula = "dracula", + dracula = "dracula", -- dracula = "dracula-soft", -- -- **:: Onedarkpro Theme ::** -- diff --git a/lua/pcode/user/keymaps.lua b/lua/pcode/user/keymaps.lua index a260663..6cbbc03 100644 --- a/lua/pcode/user/keymaps.lua +++ b/lua/pcode/user/keymaps.lua @@ -1,5 +1,6 @@ -- definiskanfunction name -local keymap = vim.api.nvim_set_keymap +-- local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap.set local opts = { noremap = true, silent = true } -- Remap space leader keys @@ -35,15 +36,43 @@ keymap("i", "", "m+", opts) keymap("n", "", "m-2", opts) keymap("i", "", "m-2", opts) --- create comment CTRL + / all mode -keymap("v", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("v", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise.current()", opts) -keymap("i", "", "lua require('Comment.api').toggle.linewise.current()", opts) -keymap("n", "", "lua require('Comment.api').toggle.linewise.current()", opts) -keymap("n", "", "lua require('Comment.api').toggle.linewise.current()", opts) +-- create comment CTRL + / visual block mode +keymap("x", "", function() + vim.api.nvim_feedkeys("gb", "v", true) +end, opts) +-- create comment CTRL + / normal mode +keymap("i", "", function() + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + -- Toggle comment baris + vim.api.nvim_feedkeys("gcc", "v", true) + + -- Tunggu sejenak agar komentar terbentuk + vim.schedule(function() + local row = vim.fn.line(".") - 1 -- index dimulai dari 0 + local col = #vim.fn.getline(".") -- panjang baris = akhir kalimat + + -- Geser 2 spasi dari akhir dan masuk insert mode + vim.api.nvim_win_set_cursor(0, { row + 1, col }) + vim.api.nvim_feedkeys("i", "v", true) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + end) +end, opts) +-- create comment CTRL + / normal mode +keymap("n", "", function() + -- Toggle comment baris + vim.api.nvim_feedkeys("gcc", "v", true) + + -- Tunggu sejenak agar komentar terbentuk + vim.schedule(function() + local row = vim.fn.line(".") - 1 -- index dimulai dari 0 + local col = #vim.fn.getline(".") -- panjang baris = akhir kalimat + + -- Geser 2 spasi dari akhir dan masuk insert mode + vim.api.nvim_win_set_cursor(0, { row + 1, col }) + vim.api.nvim_feedkeys("i", "v", true) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "n", true) + end) +end, opts) -- close windows keymap("n", "q", "q", opts) @@ -92,59 +121,6 @@ keymap("n", "", "terminal live-server", opts) -- close current buffer keymap("n", "", "lua require('auto-bufferline.configs.utils').bufremove()", opts) --- vim.keymap.set("n", "ti", function() --- local api = vim.api --- local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() --- local parsers = vim.tbl_keys(parser_configs) --- table.sort(parsers) --- --- local choices = {} --- local lookup = {} --- --- for _, parser in ipairs(parsers) do --- local is_installed = #api.nvim_get_runtime_file("parser/" .. parser .. ".so", false) > 0 --- --- local label = (is_installed and "[✓] " or "[✗] ") .. parser --- table.insert(choices, label) --- lookup[label] = parser --- end --- --- vim.ui.select(choices, { --- prompt = "Treesitter ([✓]= installed, [✗] = not installed)", --- }, function(choice) --- if choice then --- local parser_name = lookup[choice] --- if parser_name then --- vim.cmd("TSInstall " .. parser_name) --- end --- end --- end) --- end, { desc = "Install Treesitter" }) --- --- vim.keymap.set("n", "tu", function() --- local parsers = require("nvim-treesitter.info").installed_parsers() --- table.sort(parsers) --- local choices = {} --- local lookup = {} --- --- for _, parser in ipairs(parsers) do --- local label = "[✓] " .. parser --- table.insert(choices, label) --- lookup[label] = parser --- end --- --- vim.ui.select(choices, { --- prompt = "Uninstall Treesitter", --- }, function(choice) --- if choice then --- local parser_name = lookup[choice] --- if parser_name then --- vim.cmd("TSUninstall " .. parser_name) --- end --- end --- end) --- end, { desc = "Uninstall Treesitter" }) - vim.api.nvim_create_user_command("TSIsInstalled", function() local parsers = require("nvim-treesitter.info").installed_parsers() table.sort(parsers) diff --git a/mysnippets/go/snippets.json b/mysnippets/go/snippets.json new file mode 100644 index 0000000..6732087 --- /dev/null +++ b/mysnippets/go/snippets.json @@ -0,0 +1,48 @@ +{ + "author": { + "prefix": "@author", + "body": [ + "/*", + "Author = Pojok Code", + "email = pojokcodeid@gmail.com", + "Github = https://github.com/pojokcodeid", + "Youtube = https://youtube.com/pojokcode", + "Date = $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}", + "File = $TM_FILENAME", + "note = Penyalahgunaan kode ini bukan tanggung jawab pojok code", + "*/", + "$1" + ], + "description": "Komentar Author" + }, + "/*": { + "prefix": "/*", + "body": ["/*", "* $1", "*/"], + "description": "Komentar" + }, + "/": { + "prefix": "/", + "body": "// $1", + "description": "Komentar" + }, + "main": { + "prefix": "main", + "body": [ + "package main", + "", + "import (", + "\t\"fmt\"", + ")", + "", + "func main() {", + "\tfmt.Println($1)", + "}" + ], + "description": "main" + }, + "func": { + "prefix": "func", + "body": ["func $1($2) {", "\t$3", "}"], + "description": "func" + } +} diff --git a/mysnippets/package.json b/mysnippets/package.json index c9dd02e..e566872 100644 --- a/mysnippets/package.json +++ b/mysnippets/package.json @@ -4,7 +4,12 @@ { "language": "html", "path": "./html/snippets.json" + }, + { + "language": "go", + "path": "./go/snippets.json" } ] } -} \ No newline at end of file +} +