diff --git a/lazy-lock.json b/lazy-lock.json index 3695993..a430e0c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -10,6 +10,7 @@ "auto-lualine.nvim": { "branch": "main", "commit": "9f0d6210344057eba2454113d3b07ef6eb58b5eb" }, "breadcrumbs.nvim": { "branch": "master", "commit": "9f764278784ce2f10dbe2f555ba14be2451d36a0" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, + "cheatsheet-nvim": { "branch": "main", "commit": "aaf8f4cc76e193997d0d0a27384cf09418fd7996" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, @@ -18,15 +19,15 @@ "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "code_runner.nvim": { "branch": "main", "commit": "65c8d11f507073b915f10faa88ea05bd4fbf69ce" }, "codeium.vim": { "branch": "main", "commit": "272c6e2755e8faa90e26bcdcd9fde6b9e61751ea" }, - "conform.nvim": { "branch": "master", "commit": "f54259518695178168fbad442468e25f121230d4" }, + "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, "dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "588264bee92993df92535b6742576f5655c91b1c" }, + "gitsigns.nvim": { "branch": "main", "commit": "6e3ee68bc9f65b21a21582a3d80e270c7e4f2992" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "73e0143385d8a2185944b42ed44d728b94ee19a3" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, @@ -45,13 +46,13 @@ "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, - "nvim-dap": { "branch": "master", "commit": "14fe46ae16eb272629144a93f7738f5279665a4f" }, + "nvim-dap": { "branch": "master", "commit": "1c75a797b4017fec6491f509cf196c8c8833f26f" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-lint": { "branch": "master", "commit": "2b0039b8be9583704591a13129c600891ac2c596" }, - "nvim-lspconfig": { "branch": "master", "commit": "1cb30b1bafe5a63a5c6ac20dc39f83487df38855" }, + "nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" }, + "nvim-lspconfig": { "branch": "master", "commit": "d8f03bfd5b54b10352276a0ed1f2ffe9c2e0676f" }, "nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" }, "nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, @@ -65,7 +66,7 @@ "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "55ad4fb76ab68460f700599b7449385f0c4e858e" }, "showkeys": { "branch": "main", "commit": "cb0a50296f11f1e585acffba8c253b9e8afc1f84" }, - "smart-splits.nvim": { "branch": "master", "commit": "039b1c280b849cc23190e94285083af9c2020596" }, + "smart-splits.nvim": { "branch": "master", "commit": "c088d64c6e0e3221d24ef1f9337b5fe15557ddcc" }, "telescope-diff.nvim": { "branch": "master", "commit": "c797b722516e871b51def7e69266f0cc9875bacf" }, "telescope-treesitter-info.nvim": { "branch": "master", "commit": "4bed952c3c33015c4402007f179b478843d5aa3b" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, @@ -74,7 +75,7 @@ "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, "virt-column.nvim": { "branch": "master", "commit": "b87e3e0864211a32724a2ebf3be37e24e9e2fa99" }, "volt": { "branch": "main", "commit": "7b8c5e790120d9f08c8487dcb80692db6d2087a1" }, - "vscode-js-debug": { "branch": "main", "commit": "a3279c2abc1162069b0f5c014542b8b849cefa70" }, + "vscode-js-debug": { "branch": "main", "commit": "f8f4253879aa6cd81e5c776a4f9a619771ec2fc3" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }, "yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" } } diff --git a/lua/pcode/core/init.lua b/lua/pcode/core/init.lua index b3b3091..7ef9ee4 100644 --- a/lua/pcode/core/init.lua +++ b/lua/pcode/core/init.lua @@ -3,5 +3,3 @@ require("pcode.user.default") require("pcode.config.lazy_lib") require("pcode.user.colorscheme") require("pcode.core.neovide") - -require("pcode.core.keymaps") diff --git a/lua/pcode/core/keymaps.lua b/lua/pcode/core/keymaps.lua deleted file mode 100644 index 72837a2..0000000 --- a/lua/pcode/core/keymaps.lua +++ /dev/null @@ -1,220 +0,0 @@ -local mode_info = { - "Mode:", - " n => normal i => insert v => visual x => visual block t => terminal", - "", -} - -local keymaps = { - ["LSP"] = { - { "LSP Code Action", "n", "la" }, - { "LSP Code Format", "n", "lf" }, - { "LSP Information", "n", "li" }, - { "Mason Information", "n", "lI" }, - { "LSP Next Diagnostic", "n", "lj" }, - { "LSP Previous Diagnostic", "n", "lk" }, - { "LSP Quickfix", "n", "lr" }, - { "LSP Signature Help", "n", "ls" }, - { "LSP Format On Range", "v", "lF" }, - }, - ["Cmp"] = { - { "Scroll Next Documentation", "i", "CTRL + f" }, - { "Scroll Previous Documentation", "i", "CTRL + b" }, - { "Mapping Complete", "i", "CTRL + space" }, - { "Abort Completion", "i", "CTRL + e" }, - { "Accept Completion", "i", "↵" }, - { "Next Autocompletion", "i", "TAB" }, - { "Previous Autocompletion", "i", "SHIFT + TAB" }, - }, - ["Terminal"] = { - { "Terminal Float", "n", "tf" }, - { "Terminal Horizontal", "n", "th" }, - { "Terminal new tab", "n", "ts" }, - { "Terminal Vertical", "n", "tv" }, - { "Terminal Close", "n", "tx" }, - }, - ["Comment"] = { - { "Comment line toggle", "n/v", "gcc or CTRL + /" }, - { "Comment block toggle", "n/v", "gbc or CTRL + /" }, - { "Comment visual selection", "v", "gc" }, - { "Comment visual selection using block delimiters", "v", "gb" }, - { "Comment out text object line wise", "v", "gc" }, - { "Comment out text object block wise", "v", "gb" }, - { "Add comment on the line above", "n", "gcO" }, - { "Add comment on the line below", "n", "gco" }, - { "Add comment at the end of line", "n", "gcA" }, - }, - ["Bufferline"] = { - { "Move Active Buffer Left", "n", "SHIFT + h/SHIFT + Left" }, - { "Move Active Buffer Right", "n", "SHIFT + l/SHIFT + Right" }, - { "Reorder Bufferline", "n", "SHIFT + PageUp/PageDown" }, - { "Close Current Buffer", "n", "SHIFT + t" }, - }, - ["Window"] = { - { "Resize Window", "n", "CTRL + Left/Right/Up/Down" }, - { "Navigate Window", "n", "CTRL + h/l" }, - }, - ["Text-Manipulation"] = { - { "Select Multiple Cursor Vertical", "n/i", "SHIFT + ALT + Up/Down" }, - { "Select text", "n", "CTRL + d" }, - { "Select Multiple Cursor", "i/n", "ALT + Left Click Mouse" }, - { "Duplicate Row", "i/n/v", "SHIFT + ALT + Up/Down" }, - { "Move Row", "i/n/v", "ALT + Up/Down" }, - }, - ["Ai"] = { - { "Approve AI Sugention", "i", "CTRL + g" }, - { "Change AI Option", "i", "CTRL + Up/Down" }, - { "Clear AI Sugention", "i", "CTRL + x" }, - }, -} - -vim.api.nvim_set_hl(0, "KeymapsSectionOil", { bg = "#8fbcbb", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "KeymapsSectionCmp", { bg = "#b48ead", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "KeymapsSectionComment", { bg = "#bf616a", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Normal2", { bg = "#56B7C3", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color1", { bg = "#D6ACFF", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color2", { bg = "#F1FA8C", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color3", { bg = "#FF79C6", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color4", { bg = "#FF92DF", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color5", { bg = "#69ff94", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color6", { bg = "#FF6E6E", fg = "#1e1e1e", bold = true }) -vim.api.nvim_set_hl(0, "Color7", { bg = "#D6ACFF", fg = "#1e1e1e", bold = true }) - -local section_hl = { - "KeymapsSectionOil", - "KeymapsSectionCmp", - "KeymapsSectionComment", - "Normal2", - "Color1", - "Color2", - "Color3", - "Color4", - "Color5", - "Color6", - "Color7", -} - -local function pad(str, width) - local n = vim.fn.strdisplaywidth(str) - return str .. string.rep(" ", width - n) -end - -local function calc_widths(tbl) - local col1, col2, col3 = 0, 0, 0 - for _, group in pairs(tbl) do - for _, row in ipairs(group) do - col1 = math.max(col1, vim.fn.strdisplaywidth(row[1])) - col2 = math.max(col2, vim.fn.strdisplaywidth(row[2])) - col3 = math.max(col3, vim.fn.strdisplaywidth(row[3])) - end - end - return col1, col2, col3 -end - -local function make_lines(tbl, max_width) - local col1, col2, col3 = calc_widths(tbl) - if max_width then - local want = col1 + col2 + col3 + 6 - local padding = max_width - want - if padding > 0 then - col1 = col1 + math.floor(padding * 0.8) - col3 = col3 + (padding - math.floor(padding * 0.8)) - end - end - local lines = {} - local hls = {} - - -- Tambahkan info mode di bagian atas - for _, info in ipairs(mode_info) do - table.insert(lines, info) - table.insert(hls, {}) - end - - local random_index = 1 - - -- Urutkan section secara alfabetis - local section_names = {} - for section in pairs(tbl) do - table.insert(section_names, section) - end - table.sort(section_names) - - for _, section in ipairs(section_names) do - local rows = tbl[section] - local section_title = (" %s "):format(section) - table.insert(lines, section_title) - table.insert(hls, { { 0, #section_title, section_hl[random_index] or "Normal2" } }) - random_index = random_index + 1 - if random_index > #section_hl then - random_index = 1 - end - - table.insert( - lines, - string.rep("─", col1) .. "─┬─" .. string.rep("─", col2) .. "─┬─" .. string.rep("─", col3) - ) - table.insert(hls, {}) - for _, row in ipairs(rows) do - table.insert(lines, pad(row[1], col1) .. " │ " .. pad(row[2], col2) .. " │ " .. pad(row[3], col3)) - table.insert(hls, {}) - end - table.insert(lines, "") - table.insert(hls, {}) - end - return lines, col1 + col2 + col3 + 6, hls -end - -local function show_keymaps_popup() - local ui = vim.api.nvim_list_uis()[1] - local win_width = math.floor(ui.width * 0.8) - local lines, width, hls = make_lines(keymaps, win_width) - width = win_width - local height = #lines - - local buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) - vim.api.nvim_buf_set_option(buf, "modifiable", false) - vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe") - - -- Set the buffer's filetype to 'keymaps_table' - vim.api.nvim_buf_set_option(buf, "filetype", "keymaps_table") - - -- highlight section titles - for i, l in ipairs(hls) do - for _, v in ipairs(l) do - vim.api.nvim_buf_add_highlight(buf, -1, v[3], i - 1, v[1], v[2]) - end - end - - local row = math.floor((ui.height - height) / 2) - local col = math.floor((ui.width - width) / 2) - - local win = vim.api.nvim_open_win(buf, true, { - relative = "editor", - row = row, - col = col, - width = width, - height = height, - style = "minimal", - border = "rounded", - title = "Keymaps", - title_pos = "center", - }) - - vim.keymap.set("n", "q", function() - vim.api.nvim_win_close(win, true) - end, { buffer = buf, nowait = true }) - vim.keymap.set("n", "", function() - vim.api.nvim_win_close(win, true) - end, { buffer = buf, nowait = true }) -end - -vim.api.nvim_create_user_command("KeymapsPopup", function() - show_keymaps_popup() -end, {}) - -vim.keymap.set("n", "", ":KeymapsPopup", { noremap = true, silent = true }) - -return { - show = show_keymaps_popup, -} diff --git a/lua/pcode/plugins/extras/cheatsheet.lua b/lua/pcode/plugins/extras/cheatsheet.lua new file mode 100644 index 0000000..decb6fb --- /dev/null +++ b/lua/pcode/plugins/extras/cheatsheet.lua @@ -0,0 +1,73 @@ +return { + "pojokcodeid/cheatsheet-nvim", + event = "VeryLazy", + keys = { + { "", "KeymapsPopup", desc = "Keymaps Popup" }, + }, + cmd = { "KeymapsPopup" }, + opts = { + ["LSP"] = { + { "LSP Code Action", "n", "la" }, + { "LSP Code Format", "n", "lf" }, + { "LSP Information", "n", "li" }, + { "Mason Information", "n", "lI" }, + { "LSP Next Diagnostic", "n", "lj" }, + { "LSP Previous Diagnostic", "n", "lk" }, + { "LSP Quickfix", "n", "lr" }, + { "LSP Signature Help", "n", "ls" }, + { "LSP Format On Range", "v", "lF" }, + }, + ["Cmp"] = { + { "Scroll Next Documentation", "i", "CTRL + f" }, + { "Scroll Previous Documentation", "i", "CTRL + b" }, + { "Mapping Complete", "i", "CTRL + space" }, + { "Abort Completion", "i", "CTRL + e" }, + { "Accept Completion", "i", "↵" }, + { "Next Autocompletion", "i", "TAB" }, + { "Previous Autocompletion", "i", "SHIFT + TAB" }, + }, + ["Terminal"] = { + { "Terminal Float", "n", "tf" }, + { "Terminal Horizontal", "n", "th" }, + { "Terminal new tab", "n", "ts" }, + { "Terminal Vertical", "n", "tv" }, + { "Terminal Close", "n", "tx" }, + }, + ["Comment"] = { + { "Comment line toggle", "n/v", "gcc or CTRL + /" }, + { "Comment block toggle", "n/v", "gbc or CTRL + /" }, + { "Comment visual selection", "v", "gc" }, + { "Comment visual selection using block delimiters", "v", "gb" }, + { "Comment out text object line wise", "v", "gc" }, + { "Comment out text object block wise", "v", "gb" }, + { "Add comment on the line above", "n", "gcO" }, + { "Add comment on the line below", "n", "gco" }, + { "Add comment at the end of line", "n", "gcA" }, + }, + ["Bufferline"] = { + { "Move Active Buffer Left", "n", "SHIFT + h/SHIFT + Left" }, + { "Move Active Buffer Right", "n", "SHIFT + l/SHIFT + Right" }, + { "Reorder Bufferline", "n", "SHIFT + PageUp/PageDown" }, + { "Close Current Buffer", "n", "SHIFT + t" }, + }, + ["Window"] = { + { "Resize Window", "n", "CTRL + Left/Right/Up/Down" }, + { "Navigate Window", "n", "CTRL + h/l" }, + }, + ["Text-Manipulation"] = { + { "Select Multiple Cursor Vertical", "n/i", "SHIFT + ALT + Up/Down" }, + { "Select text", "n", "CTRL + d" }, + { "Select Multiple Cursor", "i/n", "ALT + Left Click Mouse" }, + { "Duplicate Row", "i/n/v", "SHIFT + ALT + Up/Down" }, + { "Move Row", "i/n/v", "ALT + Up/Down" }, + }, + ["Ai"] = { + { "Approve AI Sugention", "i", "CTRL + g" }, + { "Change AI Option", "i", "CTRL + Up/Down" }, + { "Clear AI Sugention", "i", "CTRL + x" }, + }, + }, + + config = true, +} diff --git a/lua/pcode/user/default.lua b/lua/pcode/user/default.lua index 570c4b2..a196f7e 100644 --- a/lua/pcode/user/default.lua +++ b/lua/pcode/user/default.lua @@ -51,6 +51,7 @@ pcode.extras = { tinydignostic = false, dressing = true, telescopediff = true, + cheatsheet = true, } -- activate config themes pcode.themes = { diff --git a/mysnippets/javascript/snippets.json b/mysnippets/javascript/snippets.json new file mode 100644 index 0000000..88f8aaa --- /dev/null +++ b/mysnippets/javascript/snippets.json @@ -0,0 +1,33 @@ +{ + "author": { + "prefix": "@author", + "body": [ + "/*", + "Author = Pojok Code", + "email = pojokcodeid@gmail.com", + "Github = https://github.com/pojokcodeid", + "Youtube = https://youtube.com/pojokcode", + "Date = $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}", + "File = $TM_FILENAME", + "note = Penyalahgunaan kode ini bukan tanggung jawab pojok code", + "*/", + "$1" + ], + "description": "Komentar Author" + }, + "/*": { + "prefix": "/*", + "body": ["/*", "* $1", "*/"], + "description": "Komentar" + }, + "/": { + "prefix": "/", + "body": "// $1", + "description": "Komentar" + }, + "function": { + "prefix": "function", + "body": ["function $1($2) {", "$0", "}"], + "description": "function" + } +} diff --git a/mysnippets/package.json b/mysnippets/package.json index e566872..1c7dc5f 100644 --- a/mysnippets/package.json +++ b/mysnippets/package.json @@ -8,8 +8,15 @@ { "language": "go", "path": "./go/snippets.json" + }, + { + "language": "javascript", + "path": "./javascript/snippets.json" + }, + { + "language": "typescript", + "path": "./javascript/snippets.json" } ] } } -