From a4bba257add91b019a4b1c14fa24e605a3d399da Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Mon, 18 Mar 2024 14:51:29 +0545 Subject: [PATCH] config(nvim): change keymaps for diffview and floaterm file history --- .../extras/editor/terminal/toggleterm.lua | 128 +++++++++++------- 1 file changed, 80 insertions(+), 48 deletions(-) diff --git a/config/nvim/lua/plugins/extras/editor/terminal/toggleterm.lua b/config/nvim/lua/plugins/extras/editor/terminal/toggleterm.lua index 5c57ac1d..a73c4673 100644 --- a/config/nvim/lua/plugins/extras/editor/terminal/toggleterm.lua +++ b/config/nvim/lua/plugins/extras/editor/terminal/toggleterm.lua @@ -1,58 +1,90 @@ return { { - "akinsho/toggleterm.nvim", - cmd = { - "ToggleTerm", - "ToggleTermSetName", - "ToggleTermToggleAll", - "ToggleTermSendVisualLines", - "ToggleTermSendCurrentLine", - "ToggleTermSendVisualSelection", - }, - opts = { - size = function(term) - if term.direction == "horizontal" then - return 30 - elseif term.direction == "vertical" then - return vim.o.columns * 0.4 - end - end, - open_mapping = [[]], - hide_numbers = true, -- hide the number column in toggleterm buffers - shade_filetypes = {}, - shade_terminals = true, -- NOTE: this option takes priority over highlights specified so if you specify Normal highlights you should set this to false - shading_factor = "-10", -- the percentage by which to lighten terminal background, default: -30 (gets multiplied by -3 if background is light) - start_in_insert = true, - insert_mappings = true, -- whether or not the open mapping applies in insert mode - terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals - persist_size = true, - persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered - direction = "float", - close_on_exit = true, -- close the terminal window when the process exits - -- Change the default shell. Can be a string or a function returning a string - shell = vim.o.shell, - -- This field is only relevant if direction is set to 'float' - float_opts = { - -- The border key is *almost* the same as 'nvim_open_win' - -- see :h nvim_open_win for details on borders however - -- the 'curved' border is a custom border type - -- not natively supported but implemented in this plugin. - border = "curved", - -- like `size`, width and height can be a number or function which is passed the current terminal - highlights = { border = "Normal", background = "Normal" }, - winblend = 3, - }, - }, - -- stylua: ignore + "voldikss/vim-floaterm", + cmd = { "FloatermNew", "FloatermToggle", "FloatermNext", "FloatermPrev", "FloatermLast", "FloatermFirst" }, + --stylua: ignore keys = { - { [[]], "ToggleTerm", mode = "n", desc = "Toggle Terminal" }, + { "", "FloatermNew --disposable --name=yaziroot --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd= yazi", desc = "Yazi" }, + { "gg", "FloatermNew --name=lazygitroot --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd= lazygit", desc = "Lazygit (root dir)" }, + { "gG", "FloatermNew --name=lazygitbuffer --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd= lazygit", desc = "Lazygit (cwd)" }, + { "cen", "FloatermNew --name=node --opener=edit --titleposition=center --wintype=split --height=0.35 node", desc = "Node" }, + { "cep", "FloatermNew --name=python --opener=edit --titleposition=center --wintype=split --height=0.35 python", desc = "Python" }, + { "gF", function() + local git_path = vim.api.nvim_buf_get_name(0) + vim.api.nvim_command("FloatermNew --name=lazygitroot --opener=edit --titleposition=center --height=0.85 --width=0.85 lazygit -f " .. vim.trim(git_path)) + end, desc = "File History (LazyGit)" }, + { "", "FloatermNext", mode = { "t" }, desc = "Next Terminal" }, + { "", "FloatermPrev", mode = { "t" }, desc = "Prev Terminal" }, + { "", "FloatermLast", mode = { "t" }, desc = "Last Terminal" }, + { "", "FloatermFirst", mode = { "t" }, desc = "First Terminal" }, + { [[]], "FloatermToggle", mode = { "n", "t" }, desc = "Toggle Terminal" }, + { "ftf", "FloatermNew --name=floatroot --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd=", desc = "Floating (root dir)" }, + { "ftF", "FloatermNew --name=floatbuffer --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd=", desc = "Floating (cwd)" }, + { "fts", "FloatermNew --name=splitroot --opener=edit --titleposition=center --height=0.35 --wintype=split --cwd=", desc = "Split (root dir)" }, + { "ftS", "FloatermNew --name=splitbuffer --opener=edit --titleposition=center --height=0.35 --wintype=split --cwd=", desc = "Split (cwd)" }, }, }, { - "ryanmsnyder/toggleterm-manager.nvim", - opts = {}, + "dawsers/telescope-floaterm.nvim", + config = function() + require("lazyvim.util").on_load("telescope.nvim", function() + require("telescope").load_extension("floaterm") + end) + end, keys = { - { "", "Telescope toggleterm_manager", desc = "Terminals" }, + { [[]], "Telescope floaterm", desc = "Terminals" }, }, }, + { + "folke/which-key.nvim", + opts = { + defaults = { + ["ce"] = { name = "r[e]pl" }, + ["ft"] = { name = "terminals" }, + }, + }, + }, + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + table.insert(opts.bottom, { + ft = "floaterm", + title = "Floaterm", + size = { height = 0.4 }, + filter = function(buf, win) + return vim.api.nvim_win_get_config(win).relative == "" + end, + }) + end, + }, + { + "goolord/alpha-nvim", + optional = true, + opts = function(_, dashboard) + -- stylua: ignore + local button = dashboard.button("G", "󰊢 " .. " Git", "FloatermNew --disposable --name=lazygitroot --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd= lazygit") + button.opts.hl = "AlphaButtons" + button.opts.hl_shortcut = "AlphaShortcut" + table.insert(dashboard.section.buttons.val, 7, button) + return dashboard + end, + }, + { + "nvimdev/dashboard-nvim", + optional = true, + opts = function(_, opts) + local git = { + action = "FloatermNew --disposable --name=lazygitroot --opener=edit --titleposition=center --height=0.85 --width=0.85 --cwd= lazygit", + desc = " Git", + icon = " ", + key = "G", + } + + git.desc = git.desc .. string.rep(" ", 43 - #git.desc) + git.key_format = " %s" + + table.insert(opts.config.center, 7, git) + end, + }, }