More project specific stuff
This commit is contained in:
@@ -16,5 +16,39 @@ end
|
||||
|
||||
helpers.edit_cf('h', '/lua/helpers.lua')
|
||||
|
||||
---@param opts? { cmd?: string }
|
||||
helpers.open_term = function(opts)
|
||||
opts = opts or { cmd = '' }
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = buf })
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = buf })
|
||||
|
||||
local height = math.ceil(vim.o.lines * 0.9)
|
||||
local width = math.ceil(vim.o.columns * 0.9)
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
style = 'minimal',
|
||||
relative = 'editor',
|
||||
width = width,
|
||||
height = height,
|
||||
row = math.ceil((vim.o.lines - height) / 2),
|
||||
col = math.ceil((vim.o.columns - width) / 2),
|
||||
border = 'single',
|
||||
})
|
||||
|
||||
vim.api.nvim_set_current_win(win)
|
||||
|
||||
vim.fn.jobstart(opts.cmd, {
|
||||
term = true,
|
||||
on_exit = function(_, _, _)
|
||||
if vim.api.nvim_win_is_valid(win) then
|
||||
vim.api.nvim_win_close(win, true)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.cmd.startinsert()
|
||||
end
|
||||
|
||||
return helpers
|
||||
-- nnoremap <Leader>ev :tabedit $MYVIMRC<CR>
|
||||
|
||||
Reference in New Issue
Block a user