feat: add terminal toggle

pull/122/head
Colin Graydon 2025-04-07 22:27:56 -04:00
parent 943eed2ab6
commit bd049adb9a
2 changed files with 45 additions and 15 deletions

View File

@ -4,6 +4,51 @@
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.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
-- Enable Command key mappings
vim.g.neovide_input_use_logo = true -- Enable the Command/Super/Windows key

View File

@ -1,24 +1,9 @@
-- In ~/.config/nvim/lua/plugins/colorscheme.lua
return {
-- Add Dracula colorscheme
{
"Mofiqul/dracula.nvim",
lazy = false,
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