Skip to content

Commit

Permalink
feat(nvim): clean up terminal config
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Dec 21, 2024
1 parent 44f272b commit f4ab374
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 64 deletions.
16 changes: 6 additions & 10 deletions nvim-fredrik/lua/fredrik/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -878,29 +878,25 @@ function M.setup_noice_keymaps()
map_normal_mode("<leader>snL", ":NoiceLog<CR>", "[s]earch [n]oice [L]og")
end

function M.setup_terminal_keymaps()
function M.setup_fterm_keymaps()
-- Both <C-/> and <C-_> are mapped due to the way control characters are interpreted by terminal emulators.
-- ASCII value of '/' is 47, and of '_' is 95. When <C-/> is pressed, the terminal sends (47 - 64) which wraps around to 111 ('o').
-- When <C-_> is pressed, the terminal sends (95 - 64) which is 31. Hence, both key combinations need to be mapped.

-- <C-/> toggles the floating terminal
local ctrl_slash = "<C-/>"
local ctrl_underscore = "<C-_>"
local ctrl_alt_slash = "<C-A-/>"
local ctrl_alt_underscore = "<C-A-_>"
-- local ctrl_alt_slash = "<C-A-/>"
-- local ctrl_alt_underscore = "<C-A-_>"
local floating_term_cmd = function()
vim.api.nvim_set_keymap("t", "<Esc><Esc>", "<C-\\><C-n>", { noremap = true })
require("fredrik.utils.terminal").toggle_fterm()
end
local split_term_cmd = function()
vim.api.nvim_set_keymap("t", "<Esc><Esc>", "<C-\\><C-n>", { noremap = true })
require("fredrik.utils.terminal").toggle_terminal_native()
require("FTerm").toggle()
end

return {

{ ctrl_alt_slash, split_term_cmd, mode = { "n", "i", "t", "v" }, desc = "Toggle terminal" },
{ ctrl_alt_underscore, split_term_cmd, mode = { "n", "i", "t", "v" }, desc = "Toggle terminal" },
-- { ctrl_alt_slash, split_term_cmd, mode = { "n", "i", "t", "v" }, desc = "Toggle terminal" },
-- { ctrl_alt_underscore, split_term_cmd, mode = { "n", "i", "t", "v" }, desc = "Toggle terminal" },

-- C-A-/ toggles split terminal on/off
{ ctrl_slash, floating_term_cmd, mode = { "n", "i", "t", "v" }, desc = "Toggle native terminal" },
Expand Down
17 changes: 17 additions & 0 deletions nvim-fredrik/lua/fredrik/plugins/core/fterm.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
return {

{
"numToStr/FTerm.nvim",
lazy = true,
opts = {
dimensions = {
height = 0.9,
width = 0.9,
},
},
config = function(_, opts)
require("FTerm").setup(opts)
end,
keys = require("fredrik.config.keymaps").setup_fterm_keymaps(),
},
}
12 changes: 0 additions & 12 deletions nvim-fredrik/lua/fredrik/plugins/fterm.lua

This file was deleted.

42 changes: 0 additions & 42 deletions nvim-fredrik/lua/fredrik/utils/terminal.lua

This file was deleted.

0 comments on commit f4ab374

Please sign in to comment.