添加终端

This commit is contained in:
Sakura 2022-09-27 17:56:42 +08:00
parent 590f9629e3
commit 30d0bd6baf
4 changed files with 47 additions and 0 deletions

View File

@ -22,6 +22,9 @@ require "user.shade"
require "user.code_runner" require "user.code_runner"
-- 文件搜索 -- 文件搜索
require "user.telescope" require "user.telescope"
-- 终端
require "user.toggleterm"
-- 代码补全插件(安装代码补全插件需要node版本14.14.0支持) -- 代码补全插件(安装代码补全插件需要node版本14.14.0支持)
require "user.coc" require "user.coc"

View File

@ -60,3 +60,21 @@ vim.keymap.set('n', '<leader>crp', ':CRProjects<CR>', {
noremap = true, noremap = true,
silent = false silent = false
}) })
-- 启动终端
vim.cmd [[
" 垂直终端
map bv :ToggleTerm direction=vertical<CR>
" 水平终端
map bh :ToggleTerm direction=horizontal<CR>
" 标签终端
map bt :ToggleTerm direction=tab<CR>
" 浮动终端
map bf :ToggleTerm direction=float<CR>
" 发送当前行字符到终端
map bc :ToggleTermSendCurrentLine<CR>
" 发送选中行到终端
map bv :ToggleTermSendVisualLines<CR>
" 发送选中字符到终端
map bs :ToggleTermSendVisualSelection<CR>
]]

View File

@ -105,6 +105,12 @@ return packer.startup({function(use)
-- 未选择状态窗口阴影 -- 未选择状态窗口阴影
use {'sunjon/shade.nvim'} use {'sunjon/shade.nvim'}
-- 终端
use {
"akinsho/toggleterm.nvim",
tag = '*'
}
-- 代码补全插件 -- 代码补全插件
use { use {
'neoclide/coc.nvim', 'neoclide/coc.nvim',

20
lua/user/toggleterm.lua Normal file
View File

@ -0,0 +1,20 @@
local status_ok, toggleterm = pcall(require, "toggleterm")
if not status_ok then
return
end
toggleterm.setup()
function _G.set_terminal_keymaps()
local opts = {
buffer = 0
}
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
-- vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
-- vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')