mirror of https://github.com/LazyVim/starter
feat: add terminal toggle
parent
943eed2ab6
commit
bd049adb9a
|
@ -4,6 +4,51 @@
|
||||||
vim.keymap.set("n", "<D-s>", ":w<CR>", { desc = "Save file", silent = true })
|
vim.keymap.set("n", "<D-s>", ":w<CR>", { desc = "Save file", silent = true })
|
||||||
vim.keymap.set("i", "<D-s>", "<Esc>:w<CR>a", { desc = "Save file", silent = true })
|
vim.keymap.set("i", "<D-s>", "<Esc>:w<CR>a", { desc = "Save file", silent = true })
|
||||||
vim.g.neovide_input_macos_option_key_is_meta = "only_left"
|
vim.g.neovide_input_macos_option_key_is_meta = "only_left"
|
||||||
|
|
||||||
|
vim.api.nvim_echo({ { "Terminal toggle binding loaded!", "Normal" } }, true, {})
|
||||||
|
-- Terminal keybindings with Ctrl+`
|
||||||
|
vim.keymap.set({ "n", "t" }, "<C-`>", function()
|
||||||
|
local term_bufnrs = {}
|
||||||
|
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
|
if vim.bo[bufnr].buftype == "terminal" then
|
||||||
|
table.insert(term_bufnrs, bufnr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #term_bufnrs == 0 then
|
||||||
|
-- No terminal exists, create a new one
|
||||||
|
vim.cmd("split | terminal")
|
||||||
|
vim.cmd("resize 15")
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
else
|
||||||
|
-- Check if a terminal is visible
|
||||||
|
local term_visible = false
|
||||||
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
|
if vim.bo[buf].buftype == "terminal" then
|
||||||
|
term_visible = true
|
||||||
|
if vim.api.nvim_get_current_win() == win then
|
||||||
|
-- Currently focused on terminal, hide it
|
||||||
|
vim.cmd("hide")
|
||||||
|
else
|
||||||
|
-- Terminal visible but not focused, focus it
|
||||||
|
vim.api.nvim_set_current_win(win)
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not term_visible then
|
||||||
|
-- Terminal exists but not visible, show it
|
||||||
|
vim.cmd("sbuffer " .. term_bufnrs[1])
|
||||||
|
vim.cmd("resize 15")
|
||||||
|
vim.cmd("startinsert")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, { desc = "Toggle terminal" })
|
||||||
|
|
||||||
|
-- Neovide enable Command key
|
||||||
if vim.g.neovide then
|
if vim.g.neovide then
|
||||||
-- Enable Command key mappings
|
-- Enable Command key mappings
|
||||||
vim.g.neovide_input_use_logo = true -- Enable the Command/Super/Windows key
|
vim.g.neovide_input_use_logo = true -- Enable the Command/Super/Windows key
|
||||||
|
|
|
@ -1,24 +1,9 @@
|
||||||
-- In ~/.config/nvim/lua/plugins/colorscheme.lua
|
|
||||||
return {
|
return {
|
||||||
-- Add Dracula colorscheme
|
-- Add Dracula colorscheme
|
||||||
{
|
{
|
||||||
"Mofiqul/dracula.nvim",
|
"Mofiqul/dracula.nvim",
|
||||||
lazy = false,
|
lazy = false,
|
||||||
priority = 1000,
|
priority = 1000,
|
||||||
config = function()
|
|
||||||
-- First load the colorscheme
|
|
||||||
vim.cmd([[colorscheme dracula]])
|
|
||||||
|
|
||||||
-- Then override the problematic highlight groups
|
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeDirectoryName", { fg = "#BD93F9" }) -- Purple for directories
|
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeDirectoryIcon", { fg = "#BD93F9" })
|
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeNormal", { fg = "#F8F8F2" }) -- Lighter text
|
|
||||||
|
|
||||||
-- For NvimTree (if you're using that instead)
|
|
||||||
vim.api.nvim_set_hl(0, "NvimTreeFolderName", { fg = "#BD93F9" })
|
|
||||||
vim.api.nvim_set_hl(0, "NvimTreeFolderIcon", { fg = "#BD93F9" })
|
|
||||||
vim.api.nvim_set_hl(0, "NvimTreeNormal", { fg = "#F8F8F2" })
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Configure LazyVim to use Dracula
|
-- Configure LazyVim to use Dracula
|
||||||
|
|
Loading…
Reference in New Issue