Skip to content

Commit

Permalink
feat(nvim): term
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Sep 11, 2024
1 parent 5ad0560 commit 5ca05a6
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 24 deletions.
1 change: 1 addition & 0 deletions .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" },
"copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" },
"dressing.nvim": { "branch": "master", "commit": "c5775a888adbc50652cb370073fcfec963eca93e" },
"edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"gitsigns.nvim": { "branch": "main", "commit": "1ef74b546732f185d0f806860fa5404df7614f28" },
Expand Down
32 changes: 16 additions & 16 deletions .config/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,24 @@ map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
map("n", "<leader>uI", "<cmd>InspectTree<cr>", { desc = "Inspect Tree" })

-- floating terminal
-- local lazyterm = function()
-- LazyVim.terminal(nil, { cwd = LazyVim.root() })
-- end
-- map("n", "<leader>ft", lazyterm, { desc = "Terminal (Root Dir)" })
-- map("n", "<leader>fT", function()
-- LazyVim.terminal()
-- end, { desc = "Terminal (cwd)" })
-- map("n", "<c-/>", lazyterm, { desc = "Terminal (Root Dir)" })
-- map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })
local lazyterm = function()
require("util.terminal")(nil, { cwd = require("util.root")() })
end
map("n", "<leader>ft", lazyterm, { desc = "Terminal" })
map("n", "<leader>fT", function()
require("util.terminal")()
end, { desc = "Terminal (cwd)" })
map("n", "<c-/>", lazyterm, { desc = "Terminal" })
map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })

-- Terminal Mappings
-- map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
-- map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to Left Window" })
-- map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to Lower Window" })
-- map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to Upper Window" })
-- map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to Right Window" })
-- map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
-- map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to Left Window" })
map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to Lower Window" })
map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to Upper Window" })
map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to Right Window" })
map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })

-- windows
map("n", "<leader>w", "<c-w>", { desc = "Windows", remap = true })
Expand Down
5 changes: 0 additions & 5 deletions .config/nvim/lua/config/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,3 @@ vim.keymap.set = function(mode, lhs, rhs, opts)
opts.silent = opts.silent ~= false
return keymap_set(mode, lhs, rhs, opts)
end

-- When using fish, set shell to bash
if vim.env.SHELL:match("fish$") then
vim.opt.shell = "/bin/bash"
end
130 changes: 128 additions & 2 deletions .config/nvim/lua/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,128 @@ return {
end,
},

-- edgy.nvim (https://github.com/folke/edgy.nvim)
{
"folke/edgy.nvim",
event = "VeryLazy",
keys = {
{
"<leader>ue",
function()
require("edgy").toggle()
end,
desc = "Edgy Toggle",
},
-- stylua: ignore
{ "<leader>uE", function() require("edgy").select() end, desc = "Edgy Select Window" },
},
opts = function()
local opts = {
animate = { enabled = false },
bottom = {
{
ft = "noice",
size = { height = 0.4 },
filter = function(_, win)
return vim.api.nvim_win_get_config(win).relative == ""
end,
},
{
ft = "lazyterm",
title = "LazyTerm",
size = { height = 0.4 },
filter = function(buf)
return not vim.b[buf].lazyterm_cmd
end,
wo = {
-- TODO: Figure out why `close` drops highlight when re-opening
winhighlight = "Normal:Normal,NormalNC:Normal",
},
},
"Trouble",
{ ft = "qf", title = "QuickFix" },
{
ft = "help",
size = { height = 20 },
-- don't open help files in edgy that we're editing
filter = function(buf)
return vim.bo[buf].buftype == "help"
end,
},
-- { title = "Spectre", ft = "spectre_panel", size = { height = 0.4 } },
-- { title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } },
},
left = {
-- { title = "Neotest Summary", ft = "neotest-summary" },
},
right = {
-- { title = "Grug Far", ft = "grug-far", size = { width = 0.4 } },
},
keys = {
-- increase width
["<c-Right>"] = function(win)
win:resize("width", 2)
end,
-- decrease width
["<c-Left>"] = function(win)
win:resize("width", -2)
end,
-- increase height
["<c-Up>"] = function(win)
win:resize("height", 2)
end,
-- decrease height
["<c-Down>"] = function(win)
win:resize("height", -2)
end,
},
wo = {
winbar = false,
winhighlight = "",
},
}

if require("util.init").has("neo-tree.nvim") then
local pos = {
filesystem = "left",
buffers = "top",
git_status = "right",
document_symbols = "bottom",
diagnostics = "bottom",
}
local sources = require("util.init").opts("neo-tree.nvim").sources or {}
for i, v in ipairs(sources) do
table.insert(opts.left, i, {
title = "Neo-Tree " .. v:gsub("_", " "):gsub("^%l", string.upper),
ft = "neo-tree",
filter = function(buf)
return vim.b[buf].neo_tree_source == v
end,
pinned = true,
open = function()
vim.cmd(("Neotree show position=%s %s dir=%s"):format(pos[v] or "bottom", v, require("util.root")()))
end,
})
end
end

for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {}
table.insert(opts[pos], {
ft = "trouble",
filter = function(_, win)
return vim.w[win].trouble
and vim.w[win].trouble.position == pos
and vim.w[win].trouble.type == "split"
and vim.w[win].trouble.relative == "editor"
and not vim.w[win].trouble_preview
end,
})
end
return opts
end,
},

-- gitsigns.nvim (https://github.com/lewis6991/gitsigns.nvim)
{
"lewis6991/gitsigns.nvim",
Expand Down Expand Up @@ -220,7 +342,6 @@ return {
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
},
Expand Down Expand Up @@ -490,7 +611,8 @@ return {
follow_current_file = { enabled = true },
use_libuv_file_watcher = true,
},
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
open_files_do_not_replace_types = { "edgy", "terminal", "Trouble", "qf", "Outline", "trouble" },
sources = { "filesystem" },
window = {
mappings = {
["O"] = {
Expand Down Expand Up @@ -1354,6 +1476,10 @@ return {
results = { "", "", "", "", "", "", "", "" },
preview = { "", "", "", "", "", "", "", "" },
},
get_selection_window = function()
require("edgy").goto_main()
return 0
end,
mappings = {
i = {
["<c-t>"] = open_with_trouble,
Expand Down
2 changes: 1 addition & 1 deletion .config/nvim/lua/util/root.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---@class lazyvim.util.root
---@class util.root
---@overload fun(): string
local M = setmetatable({}, {
__call = function(m)
Expand Down

0 comments on commit 5ca05a6

Please sign in to comment.