local M = {} function M._LAZYGIT_TOGGLE() local Terminal = require("toggleterm.terminal").Terminal local lazygit = Terminal:new({ cmd = "lazygit", hidden = true }) lazygit:toggle() end function M._NODE_TOGGLE() local Terminal = require("toggleterm.terminal").Terminal local node = Terminal:new({ cmd = "node", hidden = true }) node:toggle() end function M._BTOP_TOGGLE() local Terminal = require("toggleterm.terminal").Terminal local htop = Terminal:new({ cmd = "btop", hidden = true }) htop:toggle() end function M._PYTHON_TOGGLE() local Terminal = require("toggleterm.terminal").Terminal local python = Terminal:new({ cmd = "python", hidden = true }) python:toggle() end function M._NEWTAB_TOGGLE() local Terminal = require("toggleterm.terminal").Terminal local pwsh = Terminal:new({ cmd = "pwsh", hidden = true, direction = "tab" }) pwsh:toggle() end function M._OPEN_EXPLORER() local Terminal = require("toggleterm.terminal").Terminal local pwsh = Terminal:new({ cmd = "explorer .", hidden = true, direction = "tab" }) pwsh:toggle() end function M._LIVE_SERVER() local Terminal = require("toggleterm.terminal").Terminal local live_server = Terminal:new({ cmd = "live-server", hidden = true, direction = "tab", }) live_server:toggle() end function M._OPEN_ALACRITTY() -- open alacritty new windows current directory vim.cmd("silent !alacritty --working-directory " .. vim.fn.getcwd()) end function M._OPEN_WEZTERM() -- open wezterm new windows current directory vim.cmd("silent !wezterm start --cwd " .. vim.fn.getcwd()) end -- get folder name from current directory function M._get_folder_name() return vim.fn.fnamemodify(vim.fn.getcwd(), ":t") end function M._OPEN_WEZTERM_TAB() -- open new tab wezterm current directory vim.cmd('silent !wezterm cli spawn --cwd "' .. vim.fn.getcwd() .. '"') end function M._SET_TAB_TITLE() -- set tab title vim.cmd('silent !wezterm cli set-tab-title "' .. M._get_folder_name() .. '"') end function M._CLOSE_BUFFER() local buf = vim.api.nvim_get_current_buf() -- delete current buffer require("user.utils.bufferline").bufremove(buf) end -- function for close all bufferline function M._CLOSE_ALL_BUFFER() -- get all buffer local bufs = vim.api.nvim_list_bufs() -- loop through all buffer for _, buf in pairs(bufs) do require("user.utils.bufferline").bufremove(buf) end end M.mappings = { -- ["a"] = { "Alpha", "󰕮 Alpha" }, -- ["e"] = { "NvimTreeToggle", "󰙅 Explorer" }, -- ["w"] = { "w!", "󰆓 Save" }, -- ["q"] = { "q!", "󰿅 Quit" }, -- open exloler and close toggleterm -- ["o"] = { -- "lua require('user.utils.whichkey')._OPEN_EXPLORER()", -- "󱏒 Open Explorer", -- }, -- ["h"] = { "nohlsearch", "󱪿 No Highlight" }, -- ["f"] = { -- "Telescope find_files ", -- " Find files", -- }, -- ["F"] = { "Telescope live_grep theme=ivy", " Find Text" }, -- ["F"] = { "Telescope live_grep", " Find Text" }, -- ["/"] = { -- function() -- require("Comment.api").toggle.linewise.current() -- end, -- "󰆈 Coment line", -- }, -- 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 = { "lua require('user.utils.bufferline').bufremove()", "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 require('user.utils.whichkey')._LAZYGIT_TOGGLE()", "Lazygit" }, -- j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, -- k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, -- l = { "lua require 'gitsigns'.blame_line()", "Blame" }, -- p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, -- r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, -- R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, -- s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, -- u = { -- "lua require 'gitsigns'.undo_stage_hunk()", -- "Undo Stage Hunk", -- }, -- o = { "Telescope git_status", "Open changed file" }, -- b = { "Telescope git_branches", "Checkout branch" }, -- c = { "Telescope git_commits", "Checkout commit" }, -- d = { -- "Gitsigns diffthis HEAD", -- "Diff", -- }, -- }, -- l = { -- name = "  LSP", -- a = { "lua vim.lsp.buf.code_action()", "Code Action" }, -- d = { -- "Telescope diagnostics bufnr=0", -- "Document Diagnostics", -- }, -- w = { -- "Telescope diagnostics", -- "Workspace Diagnostics", -- }, -- f = { "lua vim.lsp.buf.format{async=true}", "Format" }, -- i = { "LspInfo", "Info" }, -- I = { "Mason", "Installer Info" }, -- j = { -- "lua vim.lsp.diagnostic.goto_next()", -- "Next Diagnostic", -- }, -- k = { -- "lua vim.lsp.diagnostic.goto_prev()", -- "Prev Diagnostic", -- }, -- l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, -- q = { "lua vim.diagnostic.setloclist()", "Quickfix" }, -- r = { "lua vim.lsp.buf.rename()", "Rename" }, -- s = { "Telescope lsp_document_symbols", "Document Symbols" }, -- S = { -- "Telescope lsp_dynamic_workspace_symbols", -- "Workspace Symbols", -- }, -- }, -- s = { -- name = "  Search", -- b = { "Telescope git_branches", "Checkout branch" }, -- c = { "Telescope colorscheme", "Colorscheme" }, -- h = { "Telescope help_tags", "Find Help" }, -- M = { "Telescope man_pages", "Man Pages" }, -- r = { "Telescope oldfiles", "Open Recent File" }, -- R = { "Telescope registers", "Registers" }, -- k = { "Telescope keymaps", "Keymaps" }, -- C = { "Telescope commands", "Commands" }, -- }, -- t = { -- name = "  Terminal", -- l = { "terminal live-server", "Live Server" }, -- P = { "lua require('user.utils.whichkey')._NEWTAB_TOGGLE()", "Power Shell" }, -- x = { "ToggleTermToggleAll!", "Close Tab" }, -- n = { "lua require('user.utils.whichkey')._NODE_TOGGLE()", "Node" }, -- b = { "lua require('user.utils.whichkey')._BTOP_TOGGLE()", "Btop" }, -- p = { "lua require('user.utils.whichkey')._PYTHON_TOGGLE()", "Python" }, -- f = { "ToggleTerm direction=float", "Float" }, -- h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, -- v = { "ToggleTerm size=80 direction=vertical", "Vertical" }, -- s = { "ToggleTerm direction=tab", "New Tab" }, -- a = { "lua require('user.utils.whichkey')._OPEN_ALACRITTY()", "Open Alacritty" }, -- w = { "lua require('user.utils.whichkey')._OPEN_WEZTERM()", "Open Wezterm" }, -- t = { "lua require('user.utils.whichkey')._OPEN_WEZTERM_TAB()", "Open Tab Wezterm" }, -- j = { "lua _SET_TAB_TITLE()", "Set Tab Title" }, -- }, -- r = { -- name = "  Run", -- -- l = { "edit term://live-server", "Live Server" }, -- s = { -- 'autocmd bufwritepost [^_]*.sass,[^_]*.scss silent exec "!sass %:p %:r.css"', -- "Auto Compile Sass", -- }, -- r = { "RunCode", "Run Code" }, -- f = { "RunFile", "Run File" }, -- p = { "RunProject", "Run Project" }, -- g = { "terminalgradle run", "Run Gradle" }, -- m = { -- "terminal mvn package", -- "MVN Build", -- }, -- }, -- z = { -- name = " 󱑠 Plugins(Lazy)", -- i = { "Lazy install", "Install" }, -- s = { "Lazy sync", "Sync" }, -- S = { "Lazy clear", "Status" }, -- c = { "Lazy clean", "Clean" }, -- u = { "Lazy update", "Update" }, -- p = { "Lazy profile", "Profile" }, -- l = { "Lazy log", "Log" }, -- d = { "Lazy debug", "Debug" }, -- }, } -- if pcode.codeium then -- table.insert(M.mappings, { ["c"] = { ":call codeium#Chat()", "󰭹 Codeium Chat" } }) -- end -- if pcode.database then -- table.insert(M.mappings, { -- ["D"] = { -- name = " 󰆼 DBUI", -- -- d = { "NvimTreeClosetabnewDBUI", "󰆼 DBUI Open" }, -- d = { "AlphaNvimTreeCloseDBUI", "󰆼 DBUI Open" }, -- q = { -- "DBUICloseBufferLineCloseOthersbd!lua require('user.utils.bufferline').bufremove()Alpha", -- "󰅙 DBUI Close", -- }, -- }, -- }) -- end -- M.mappings2 = { -- ["/"] = { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", " 󰆈 Commet Block" }, -- } return M