diff --git a/dot_files/.config/nvim/lua/core/plugins/coding/test/core.lua b/dot_files/.config/nvim/lua/core/plugins/coding/test/core.lua index c2cbbc3..2322502 100644 --- a/dot_files/.config/nvim/lua/core/plugins/coding/test/core.lua +++ b/dot_files/.config/nvim/lua/core/plugins/coding/test/core.lua @@ -7,7 +7,7 @@ return { optional = true, opts = { defaults = { - ["t"] = { name = "+test" }, + ["T"] = { name = "+test" }, }, }, }, diff --git a/dot_files/.config/nvim/lua/core/plugins/editor/flatten-nvim.lua b/dot_files/.config/nvim/lua/core/plugins/editor/flatten-nvim.lua new file mode 100644 index 0000000..200ec7f --- /dev/null +++ b/dot_files/.config/nvim/lua/core/plugins/editor/flatten-nvim.lua @@ -0,0 +1,54 @@ +-- Flatten allows you to open files from a neovim terminal buffer in your current neovim instance instead of a nested one:w +return { + 'willothy/flatten.nvim', + opts = { + window = { open = 'alternate' }, + callbacks = { + should_block = function(argv) + -- Note that argv contains all the parts of the CLI command, including + -- Neovim's path, commands, options and files. + -- See: :help v:argv + + -- In this case, we would block if we find the `-b` flag + -- This allows you to use `nvim -b file1` instead of `nvim --cmd 'let g:flatten_wait=1' file1` + return vim.tbl_contains(argv, "-b") + + -- Alternatively, we can block if we find the diff-mode option + -- return vim.tbl_contains(argv, "-d") + end, + post_open = function(_bufnr, winnr, _ft, is_blocking) + if is_blocking then + require('toggleterm').toggle(0) + else + vim.api.nvim_set_current_win(winnr) + end + + -- If the file is a git commit, create one-shot autocmd to delete its buffer on write + -- If you just want the toggleable terminal integration, ignore this bit + if ft == "gitcommit" then + vim.api.nvim_create_autocmd( + "BufWritePost", + { + buffer = bufnr, + once = true, + callback = function() + -- This is a bit of a hack, but if you run bufdelete immediately + -- the shell can occasionally freeze + vim.defer_fn( + function() + vim.api.nvim_buf_delete(bufnr, {}) + end, + 50 + ) + end + } + ) + end + end, + block_end = function() + -- After blocking ends (for a git commit, etc), reopen the terminal + require("toggleterm").toggle(0) + end + }, + }, +} diff --git a/dot_files/.config/nvim/lua/core/plugins/editor/toggleterm-nvim.lua b/dot_files/.config/nvim/lua/core/plugins/editor/toggleterm-nvim.lua new file mode 100644 index 0000000..c45d0db --- /dev/null +++ b/dot_files/.config/nvim/lua/core/plugins/editor/toggleterm-nvim.lua @@ -0,0 +1,45 @@ +return { + 'akinsho/toggleterm.nvim', + version = "*", + lazy = false, + priority = 1001, + opts = { + open_mapping = [[]], + direction = 'float', + shade_terminals = true, + float_opts = { + border = "curved", + } + }, + keys = { + { "", [[]], mode = 't', desc = "Enter free movement" }, + --{ "jk", [[]], mode = 't', desc = "" }, + { "", [[wincmd h]], mode = 't', desc = "Leave"} , + { "", [[wincmd j]], mode = 't', desc = "Leave" }, + { "", [[wincmd k]], mode = 't', desc = "Leave" }, + { "", [[wincmd l]], mode = 't', desc = "Leave" }, + { "", [[]], mode = 't', desc = "Leave" }, + }, + config = function(_, opts) + require('toggleterm').setup(opts) + -- + local Terminal = require('toggleterm.terminal').Terminal + + local htop = Terminal:new({ cmd = "htop", direction = "horizontal", hidden = true }) + function _htop_toggle() + htop:toggle() + end + + local lazygit = Terminal:new({ cmd = "lazygit", dir = "git_dir", hidden = true }) + function _lazygit_toggle() + lazygit:toggle() + end + + vim.api.nvim_set_keymap("n", "tf", "ToggleTerm direction=float", { desc = "Toggle floating terminal", noremap = true, silent = true }) + vim.api.nvim_set_keymap("n", "th", "ToggleTerm direction=horizontal size=10", { desc = "Toggle horizontal terminal", noremap = true, silent = true }) + vim.api.nvim_set_keymap("n", "tv", "ToggleTerm direction=vertical size=80", { desc = "Toggle vertical terminal", noremap = true, silent = true }) + + vim.api.nvim_set_keymap("n", "tg", "lua _lazygit_toggle()", {noremap = true, silent = true}) + vim.api.nvim_set_keymap("n", "tt", "lua _htop_toggle()", {noremap = true, silent = true}) + end, +}