From af1cfebdbb4e7fee75f7a68d925f5ecb7da5e399 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 4 Feb 2023 22:50:59 +0100 Subject: [PATCH] add floatingterm --- lazy-lock.json | 1 + lua/config/keymaps.lua | 14 ++++++++++++++ lua/plugins/toggleterm.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 lua/plugins/toggleterm.lua diff --git a/lazy-lock.json b/lazy-lock.json index 2b7a795..efa1472 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -43,6 +43,7 @@ "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, "todo-comments.nvim": { "branch": "main", "commit": "74c7d28cb50b0713c881ef69bcb6cdd77d8907d1" }, + "toggleterm.nvim": { "branch": "main", "commit": "19aad0f41f47affbba1274f05e3c067e6d718e1e" }, "tokyonight.nvim": { "branch": "main", "commit": "affb21a81e6d7de073378eb86d02864c594104d9" }, "trouble.nvim": { "branch": "main", "commit": "490f7fe6d227f4f7a64f00be8c7dcd7a508ed271" }, "vim-illuminate": { "branch": "master", "commit": "d6ca7f77eeaf61b3e6ce9f0e5a978d606df44298" }, diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 2c134f7..fe5b809 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,3 +1,17 @@ -- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here +-- + +function _G.set_terminal_keymaps() + local opts = { buffer = 0 } + vim.keymap.set("t", "", [[]], opts) + vim.keymap.set("t", "jk", [[]], opts) + vim.keymap.set("t", "", [[wincmd h]], opts) + vim.keymap.set("t", "", [[wincmd j]], opts) + vim.keymap.set("t", "", [[wincmd k]], opts) + vim.keymap.set("t", "", [[wincmd l]], opts) +end + +-- if you only want these mappings for toggle term use term://*toggleterm#* instead +vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..4db7dfe --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,26 @@ +return { + "akinsho/toggleterm.nvim", + config = function() + require("toggleterm").setup({ + shading_factor = 2, + open_mapping = [[]], + insert_mapping = true, + terminal_mapping = true, + direction = "float", + float_opts = { + border = "curved", + highlights = { + border = "Normal", + background = "Normal", + }, + }, + }) + end, + keys = { + { + "t", + "ToggleTerm", + desc = "Open a terminal", + }, + }, +}