Update init.lua
This commit is contained in:
+14
-1
@@ -8,6 +8,7 @@ M.config = {
|
|||||||
["<leader>jr"] = "JavaRun",
|
["<leader>jr"] = "JavaRun",
|
||||||
["<leader>nf"] = "NewJavaFile",
|
["<leader>nf"] = "NewJavaFile",
|
||||||
["<leader>np"] = "NewJavaProject",
|
["<leader>np"] = "NewJavaProject",
|
||||||
|
["<Esc>"] = "CloseTerminal",
|
||||||
},
|
},
|
||||||
terminal = {
|
terminal = {
|
||||||
width_pad = 10,
|
width_pad = 10,
|
||||||
@@ -34,6 +35,16 @@ function M.setup(opts)
|
|||||||
vim.api.nvim_create_user_command("JavaRun", M.run, {})
|
vim.api.nvim_create_user_command("JavaRun", M.run, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function get_key_for_action(action)
|
||||||
|
for key, cmd in pairs(M.config.keybinds) do
|
||||||
|
if cmd == action then
|
||||||
|
return key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil -- Return nil if the action is not found
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Open floating terminal
|
-- Open floating terminal
|
||||||
local function open_float_terminal(cmd)
|
local function open_float_terminal(cmd)
|
||||||
local ui = vim.api.nvim_list_uis()[1]
|
local ui = vim.api.nvim_list_uis()[1]
|
||||||
@@ -68,7 +79,9 @@ local function open_float_terminal(cmd)
|
|||||||
vim.fn.termopen(cmd)
|
vim.fn.termopen(cmd)
|
||||||
-- vim.cmd("startinsert")
|
-- vim.cmd("startinsert")
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(buf, "n", "<Esc>", "i<C-\\><C-n>:q<CR>", { noremap = true, silent = true })
|
local close_key = get_key_for_action("CloseTerminal")
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_keymap(buf, "n", close_key, "i<C-\\><C-n>:q<CR>", { noremap = true, silent = true })
|
||||||
return buf, win
|
return buf, win
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user