Adding Terminal Config
This commit is contained in:
+26
-22
@@ -8,6 +8,10 @@ M.config = {
|
|||||||
["<leader>jr"] = "JavaRun",
|
["<leader>jr"] = "JavaRun",
|
||||||
["<leader>nf"] = "NewJavaFile",
|
["<leader>nf"] = "NewJavaFile",
|
||||||
["<leader>np"] = "NewJavaProject",
|
["<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, {})
|
vim.api.nvim_create_user_command("JavaRun", M.run, {})
|
||||||
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 - 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
|
-- Create a new Java project
|
||||||
function M.create_project()
|
function M.create_project()
|
||||||
-- Use vim.ui.input for better handling of input
|
-- Use vim.ui.input for better handling of input
|
||||||
@@ -126,28 +152,6 @@ function M.build()
|
|||||||
end
|
end
|
||||||
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
|
-- Run Java program in floating terminal
|
||||||
function M.run()
|
function M.run()
|
||||||
local current_dir = vim.fn.expand("%:p:h")
|
local current_dir = vim.fn.expand("%:p:h")
|
||||||
|
|||||||
Reference in New Issue
Block a user