From 23bad15ab1157629a187125ead08dcdb7277e2aa Mon Sep 17 00:00:00 2001 From: Oliver Davies <oliver@oliverdavies.dev> Date: Sat, 16 Nov 2024 20:37:27 +0000 Subject: [PATCH] Add terminal settings --- config/neovim/lua/opdavies/keymaps.lua | 6 ++++++ config/neovim/plugin/terminal.lua | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/neovim/plugin/terminal.lua diff --git a/config/neovim/lua/opdavies/keymaps.lua b/config/neovim/lua/opdavies/keymaps.lua index 1693bc6d..a18aa8d2 100644 --- a/config/neovim/lua/opdavies/keymaps.lua +++ b/config/neovim/lua/opdavies/keymaps.lua @@ -107,3 +107,9 @@ set("n", "<leader>et", function() end) set("n", "<leader>ec", ":edit composer.json") + +-- These mappings control the size of splits (height/width). +set("n", "<M-,>", "<c-w>5<") +set("n", "<M-.>", "<c-w>5>") +set("n", "<M-t>", "<C-W>+") +set("n", "<M-s>", "<C-W>-") diff --git a/config/neovim/plugin/terminal.lua b/config/neovim/plugin/terminal.lua new file mode 100644 index 00000000..d0ee393a --- /dev/null +++ b/config/neovim/plugin/terminal.lua @@ -0,0 +1,25 @@ +local set = vim.opt_local + +-- Set local settings for terminal buffers +vim.api.nvim_create_autocmd("TermOpen", { + group = vim.api.nvim_create_augroup("custom-term-open", {}), + callback = function() + set.number = false + set.relativenumber = false + set.scrolloff = 0 + + vim.bo.filetype = "terminal" + end, +}) + +-- Easily hit escape in terminal mode. +vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>") + +-- Open a terminal at the bottom of the screen with a fixed height. +vim.keymap.set("n", ",st", function() + vim.cmd.new() + vim.cmd.wincmd "J" + vim.api.nvim_win_set_height(0, 12) + vim.wo.winfixheight = true + vim.cmd.term() +end)