Removed Copy Pasted Shorthands for vim functions
This commit is contained in:
30
init.lua
30
init.lua
@@ -53,33 +53,27 @@ vim.opt.statusline = ' #%n %f %h%w%m%r %= %y %l:%c %p%% '
|
|||||||
local te_buf = nil
|
local te_buf = nil
|
||||||
local te_win_id = nil
|
local te_win_id = nil
|
||||||
|
|
||||||
local v = vim
|
|
||||||
local fun = v.fn
|
|
||||||
local cmd = v.api.nvim_command
|
|
||||||
local gotoid = fun.win_gotoid
|
|
||||||
local getid = fun.win_getid
|
|
||||||
|
|
||||||
local function openTerminal()
|
local function openTerminal()
|
||||||
if fun.bufexists(te_buf) ~= 1 then
|
if vim.fn.bufexists(te_buf) ~= 1 then
|
||||||
cmd("au TermOpen * setlocal nonumber norelativenumber signcolumn=no")
|
vim.api.nvim_command("au TermOpen * setlocal nonumber norelativenumber signcolumn=no")
|
||||||
cmd("sp | winc J | res 10 | te")
|
vim.api.nvim_command("sp | winc J | res 10 | te")
|
||||||
te_win_id = getid()
|
te_win_id = vim.fn.win_getid()
|
||||||
te_buf = fun.bufnr('%')
|
te_buf = vim.fn.bufnr('%')
|
||||||
elseif gotoid(te_win_id) ~= 1 then
|
elseif vim.fn.win_gotoid(te_win_id) ~= 1 then
|
||||||
cmd("sb " .. te_buf .. "| winc J | res 10")
|
vim.api.nvim_command("sb " .. te_buf .. "| winc J | res 10")
|
||||||
te_win_id = getid()
|
te_win_id = vim.fn.win_getid()
|
||||||
end
|
end
|
||||||
cmd("startinsert")
|
vim.api.nvim_command("startinsert")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function hideTerminal()
|
local function hideTerminal()
|
||||||
if gotoid(te_win_id) == 1 then
|
if vim.fn.win_gotoid(te_win_id) == 1 then
|
||||||
cmd("hide")
|
vim.api.nvim_command("hide")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ToggleTerminal()
|
function ToggleTerminal()
|
||||||
if gotoid(te_win_id) == 1 then
|
if vim.fn.win_gotoid(te_win_id) == 1 then
|
||||||
hideTerminal()
|
hideTerminal()
|
||||||
else
|
else
|
||||||
openTerminal()
|
openTerminal()
|
||||||
|
|||||||
Reference in New Issue
Block a user