From 3e4ce0d7db1a308a8e0d6051e8020211bd84ea94 Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Wed, 19 Jul 2023 02:17:18 +0530 Subject: nvim: Adding toggleterm plugin + whickey spacebinds w term,lazygit and packer --- .config/nvim/init.lua | 1 + .config/nvim/lua/justsaumit/plugins.lua | 3 +++ .config/nvim/lua/justsaumit/toggleterm-config.lua | 16 ++++++++++++++ .config/nvim/lua/justsaumit/which-key-config.lua | 27 ++++++++++++++++++++++- .config/nvim/plugin/packer_compiled.lua | 5 +++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/lua/justsaumit/toggleterm-config.lua diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 3f8a04b..99966ff 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -14,4 +14,5 @@ require("justsaumit.nvim-comment-config") require("justsaumit.mason") require("justsaumit.lsp-config") require("justsaumit.cmp-config") +require("justsaumit.toggleterm-config") print ("while(!(succeed = try() ) );") diff --git a/.config/nvim/lua/justsaumit/plugins.lua b/.config/nvim/lua/justsaumit/plugins.lua index c14149b..63aa83a 100644 --- a/.config/nvim/lua/justsaumit/plugins.lua +++ b/.config/nvim/lua/justsaumit/plugins.lua @@ -86,6 +86,9 @@ return packer.startup(function(use) --Markdown + Zenmode --Telescope use {'nvim-telescope/telescope.nvim', tag = '0.1.2', requires = { {'nvim-lua/plenary.nvim'} }} +-- ToggleTerm + use ('akinsho/toggleterm.nvim') + -- use "rafamadriz/friendly-snippets" -- a bunch of snippets to use -- -- Comments - Toggle comments in Neovim diff --git a/.config/nvim/lua/justsaumit/toggleterm-config.lua b/.config/nvim/lua/justsaumit/toggleterm-config.lua new file mode 100644 index 0000000..b1579cd --- /dev/null +++ b/.config/nvim/lua/justsaumit/toggleterm-config.lua @@ -0,0 +1,16 @@ +require'toggleterm'.setup{ + size = 20, + open_mapping = [[]], + hide_numbers = true, -- hide the number column in toggleterm buffers + shade_filetypes = {}, + autochdir = false, + shade_terminals = true, + shading_factor = 1, + 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, + direction = 'horizontal', + close_on_exit = true, + shell = '/usr/bin/zsh', +} diff --git a/.config/nvim/lua/justsaumit/which-key-config.lua b/.config/nvim/lua/justsaumit/which-key-config.lua index 25ec150..16ffedd 100644 --- a/.config/nvim/lua/justsaumit/which-key-config.lua +++ b/.config/nvim/lua/justsaumit/which-key-config.lua @@ -1,13 +1,38 @@ local wk = require("which-key") +local Terminal = require('toggleterm.terminal').Terminal +local toggle_float = function() + local float = Terminal:new({ direction = "float" }) + return float:toggle() +end +local toggle_lazygit = function() + local lazygit = Terminal:new({ cmd = "lazygit", direction = "float" }) + return lazygit:toggle() +end local mappings = { q = {":q", "Quit"}, Z = {":wq", "Save and Quit"}, w = {":w", "Save"}, x ={":bdelete", "Close"}, + E = { ":e ~/.config/nvim/init.lua", "Edit config" }, f = { ":Telescope find_files", "Telescope Find Files" }, h = { ":Telescope find_files hidden=true", "Telescope Find Files" }, g = { ":Telescope live_grep", "Telescope Live Grep" }, - r = { ":Telescope oldfiles", "Recent files" } + r = { ":Telescope oldfiles", "Recent files" }, + t = { + t = { ":ToggleTerm", "Split Below" }, + f = { toggle_float, "Floating Terminal" }, + l = { toggle_lazygit, "Lazygit" }, + }, + p = { + name = "Packer", + s = { ":PackerSync", "Sync Plugins" }, + r = { ":PackerClean", "Remove Unused Plugins" }, + c = { ":PackerCompile profile=true", "Recompile Plugins" }, + i = { ":PackerInstall", "Install Plugins" }, + p = { ":PackerProfile", "Packer Profile" }, + S = { ":PackerStatus", "Packer Status" }, + u = { ":PackerUpdate", "Update Plugins" } + }, } local opts = {prefix = ''} wk.register(mappings, opts) diff --git a/.config/nvim/plugin/packer_compiled.lua b/.config/nvim/plugin/packer_compiled.lua index 67f0b41..e90bab8 100644 --- a/.config/nvim/plugin/packer_compiled.lua +++ b/.config/nvim/plugin/packer_compiled.lua @@ -204,6 +204,11 @@ _G.packer_plugins = { path = "/home/saumit/.local/share/nvim/site/pack/packer/start/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" }, + ["toggleterm.nvim"] = { + loaded = true, + path = "/home/saumit/.local/share/nvim/site/pack/packer/start/toggleterm.nvim", + url = "https://github.com/akinsho/toggleterm.nvim" + }, ["tokyodark.nvim"] = { loaded = true, path = "/home/saumit/.local/share/nvim/site/pack/packer/start/tokyodark.nvim", -- cgit v1.2.3