From 6acb3af8ab2fc559ccb24e58d81a6a69f987172c Mon Sep 17 00:00:00 2001 From: "asep.komarudin" Date: Thu, 21 Mar 2024 08:08:27 +0700 Subject: [PATCH] add: tabaction key mapping --- lazy-lock.json | 4 +-- lua/custom/default.lua | 2 +- lua/user/whichkey.lua | 59 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index c7c2eea..411f817 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -11,6 +11,7 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "code_runner.nvim": { "branch": "main", "commit": "baea3a97c02276bff92b235f4e0d9fd8909d0d04" }, "codeium.vim": { "branch": "main", "commit": "bef9cbaa5c19ab85d8048f364bfc0ac8c7ab335d" }, + "dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" }, "dressing.nvim": { "branch": "master", "commit": "42d767b04c50a6966c9633e3968bc65c0c2f2bfc" }, "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, "gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" }, @@ -18,7 +19,7 @@ "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, "lsp-progress.nvim": { "branch": "main", "commit": "1c37b1cd0611563a767f0a340d61f265c4c54ecd" }, "lualine.nvim": { "branch": "master", "commit": "af4c3cf17206810880d2a93562e0a4c0d901c684" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2ba17cecfde8b8c7c7c287909a1e4de895223df6" }, "mason-null-ls.nvim": { "branch": "main", "commit": "e270134d83ba59425edc53356c6fd337b61bb8dd" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mini.animate": { "branch": "main", "commit": "82519630b2760ffc516ebc387bef632f9c07b9f5" }, @@ -42,7 +43,6 @@ "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, "nvim-ts-rainbow2": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" }, "nvim-web-devicons": { "branch": "master", "commit": "a55b801b7ef5719ca25692c3a0a5447fdfb692ed" }, - "onedark.nvim": { "branch": "master", "commit": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "smart-splits.nvim": { "branch": "master", "commit": "f6fcb79527872e9330c554915af2ca511c388390" }, "telescope.nvim": { "branch": "master", "commit": "f06eeb79e14d5c95745558927c5b1f341c0a3a28" }, diff --git a/lua/custom/default.lua b/lua/custom/default.lua index d8750a6..96bc9f0 100644 --- a/lua/custom/default.lua +++ b/lua/custom/default.lua @@ -11,7 +11,7 @@ -- catppuccin, catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha -- dracula -- nightfox, dayfox, dawnfox, duskfox, nordfox, terafox, carbonfox -vim.g.pcode_colorscheme = "onedark" +vim.g.pcode_colorscheme = "dracula" -- custom transparent mode -- only support diff --git a/lua/user/whichkey.lua b/lua/user/whichkey.lua index 1212b07..1ba7c77 100644 --- a/lua/user/whichkey.lua +++ b/lua/user/whichkey.lua @@ -94,6 +94,22 @@ function _SET_TAB_TITLE() vim.cmd('silent !wezterm cli set-tab-title "' .. _get_folder_name() .. '"') end +function _CLOSE_BUFFER() + local buf = vim.api.nvim_get_current_buf() + -- delete current buffer + require("bufdelete").bufdelete(buf, true) +end + +-- function for close all bufferline +function _CLOSE_ALL_BUFFER() + -- get all buffer + local bufs = vim.api.nvim_list_bufs() + -- loop through all buffer + for _, buf in pairs(bufs) do + require("bufdelete").bufdelete(buf, true) + end +end + local setup = { plugins = { marks = true, -- shows a list of your marks on ' and ` @@ -188,12 +204,6 @@ local debug_key = {} -- local trasparant = {} -- local is_dap = pcall(require, "dap") -function _close_buffer() - local buf = vim.api.nvim_get_current_buf() - -- delete current buffer - require("bufdelete").bufdelete(buf, true) -end - -- local trans_ok, _ = pcall(require, "transparent") -- if trans_ok then -- trasparant = { "TransparentToggle", "Toggle Transparency" } @@ -225,16 +235,12 @@ local mappings2 = { local mappings = { -- ["c"] = trasparant, ["a"] = { "Alpha", "󰕮 Alpha" }, - ["b"] = { - "lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})", - " Buffers", - }, --["e"] = { "NvimTreeToggle", "Explorer" }, ["e"] = { "NvimTreeToggle", "󰙅 Explorer" }, ["w"] = { "w!", "󰆓 Save" }, ["q"] = { "q!", "󰿅 Quit" }, -- ["c"] = { "Bdelete!", "󰅗 Close Buffer" }, - ["k"] = { "lua _close_buffer()", "󰅗 Close Buffer" }, + -- ["k"] = { "lua _close_buffer()", "󰅗 Close Buffer" }, -- open exloler and close toggleterm ["o"] = { "lua _OPEN_EXPLORER()lua require('toggleterm').toggle()", "󱏒 Open Explorer" }, ["h"] = { "nohlsearch", "󱪿 No Highlight" }, @@ -266,6 +272,37 @@ local mappings = { -- u = { "PackerUpdate", "Update" }, -- }, + b = { + name = " Buffers", + -- show all buffers with telescope + b = { + "lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})", + "All Buffer", + }, + -- close current active buffer + c = { "bd!", "Close current buffer" }, + -- bufferline close left + d = { + "BufferLineCloseLeft", + "Buffer close left", + }, + -- bufferline close right + D = { + "BufferLineCloseRight", + "Buffer close right", + }, + -- bufferline close others + a = { + "BufferLineCloseOthers", + "Buffer close others", + }, + -- close all bufferline + A = { + "BufferLineCloseOthersbd!", + "Buffer close All Buffer", + }, + }, + g = { name = "  Git", g = { "lua _LAZYGIT_TOGGLE()", "Lazygit" },