Adding Terminal Config

This commit is contained in:
DarthMooMancer
2025-03-04 13:54:50 -05:00
parent e21c65e35d
commit 182457e29e
+26 -22
View File
@@ -8,6 +8,10 @@ M.config = {
["<leader>jr"] = "JavaRun",
["<leader>nf"] = "NewJavaFile",
["<leader>np"] = "NewJavaProject",
},
terminal = {
width_pad = 10,
height_pad = 10,
}
}
@@ -26,6 +30,28 @@ function M.setup(opts)
vim.api.nvim_create_user_command("JavaRun", M.run, {})
end
-- Open floating terminal
local function open_float_terminal(cmd)
local ui = vim.api.nvim_list_uis()[1]
local width, height = math.floor(ui.width * 0.9), math.floor(ui.height * 0.9)
local row, col = math.floor(ui.height * 0.05), math.floor(ui.width * 0.05)
local buf = vim.api.nvim_create_buf(false, true)
local win = vim.api.nvim_open_win(buf, true, {
relative = "editor", width = width - M.config.terminal.width_pad, height = height - M.config.terminal.height_pad,
row = row + 5, col = col + 5, style = "minimal", border = "rounded"
})
vim.api.nvim_win_set_option(win, "winblend", vim.o.pumblend)
vim.api.nvim_win_set_option(win, "winhighlight", "Normal:Pmenu,FloatBorder:Pmenu")
vim.fn.termopen(cmd)
vim.cmd("startinsert")
vim.api.nvim_buf_set_keymap(buf, "t", "<Esc>", "<C-\\><C-n>:q<CR>", { noremap = true, silent = true })
return buf, win
end
-- Create a new Java project
function M.create_project()
-- Use vim.ui.input for better handling of input
@@ -126,28 +152,6 @@ function M.build()
end
end
-- Open floating terminal
local function open_float_terminal(cmd)
local ui = vim.api.nvim_list_uis()[1]
local width, height = math.floor(ui.width * 0.9), math.floor(ui.height * 0.9)
local row, col = math.floor(ui.height * 0.05), math.floor(ui.width * 0.05)
local buf = vim.api.nvim_create_buf(false, true)
local win = vim.api.nvim_open_win(buf, true, {
relative = "editor", width = width - 10, height = height - 10,
row = row + 5, col = col + 5, style = "minimal", border = "rounded"
})
vim.api.nvim_win_set_option(win, "winblend", vim.o.pumblend)
vim.api.nvim_win_set_option(win, "winhighlight", "Normal:Pmenu,FloatBorder:Pmenu")
vim.fn.termopen(cmd)
vim.cmd("startinsert")
vim.api.nvim_buf_set_keymap(buf, "t", "<Esc>", "<C-\\><C-n>:q<CR>", { noremap = true, silent = true })
return buf, win
end
-- Run Java program in floating terminal
function M.run()
local current_dir = vim.fn.expand("%:p:h")