Add toggleterminal
This commit is contained in:
parent
3d149ce17a
commit
3d80a82ebe
61
init.lua
61
init.lua
|
@ -226,11 +226,42 @@ require('lazy').setup({
|
|||
filters = { dotfiles = true, },
|
||||
}
|
||||
},
|
||||
{
|
||||
'kylechui/nvim-surround',
|
||||
opts = {
|
||||
version = "*",
|
||||
config = {},
|
||||
}
|
||||
},
|
||||
{
|
||||
'akinsho/toggleterm.nvim',
|
||||
opts = {
|
||||
version = "*",
|
||||
size = 20,
|
||||
open_mapping = [[c-\]],
|
||||
hide_numbers = true,
|
||||
shading_factor = 2,
|
||||
start_in_insert = true,
|
||||
insert_mappings = true,
|
||||
persist_size = true,
|
||||
direction = "float",
|
||||
close_on_exit = true,
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
winblend = 0,
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
|
||||
-- These are some example plugins that I've included in the kickstart repository.
|
||||
-- Uncomment any of the lines below to enable them.
|
||||
-- require 'kickstart.plugins.autoformat',
|
||||
require 'kickstart.plugins.autoformat',
|
||||
-- require 'kickstart.plugins.debug',
|
||||
|
||||
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
|
||||
|
@ -507,6 +538,16 @@ require('which-key').register {
|
|||
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
||||
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
||||
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
||||
--Toggle Term
|
||||
['<leader>t'] = {
|
||||
name = "[T]erminal",
|
||||
p = { "<cmd>lua _PYTHON_TOGGLE()<cr>", "Python" }, -- Python Terminal
|
||||
f = { "<cmd>ToggleTerm direction=float<cr>", "Float" }, -- Floating Terminal
|
||||
|
||||
-- Play with size according to your needs.
|
||||
h = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", "Horizontal" }, -- Horizontal Terminal,
|
||||
v = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", "Vertical" }, -- Vertical Terminal
|
||||
},
|
||||
}
|
||||
|
||||
-- mason-lspconfig requires that these setup functions are called in this order
|
||||
|
@ -616,5 +657,23 @@ cmp.setup {
|
|||
},
|
||||
}
|
||||
|
||||
-- configure toggleterm
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = {noremap = true}
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
|
||||
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
|
||||
end
|
||||
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
local python = Terminal:new({ cmd = "python3", hidden = true })
|
||||
|
||||
function _PYTHON_TOGGLE()
|
||||
python:toggle()
|
||||
end
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
|
|
Loading…
Reference in New Issue