Created
February 18, 2026 22:23
-
-
Save rawnly/800fdb659e719a42eabf3d35038972e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ---@type Terminal | |
| local lazygit | |
| ---@type Terminal | |
| local devserver | |
| local function close_on_q(bufnr) | |
| vim.cmd("startinsert!") | |
| vim.api.nvim_buf_set_keymap(bufnr, "n", "q", "<cmd>close<cr>", { | |
| noremap = true, | |
| silent = true, | |
| }) | |
| end | |
| local function get_lazygit() | |
| if not lazygit then | |
| local Terminal = require("toggleterm.terminal").Terminal | |
| lazygit = Terminal:new({ | |
| cmd = "lazygit", | |
| hidden = true, | |
| direction = "float", | |
| dir = "git_dir", | |
| display_name = "Lazygit", | |
| float_opts = { | |
| border = "double", | |
| }, | |
| on_open = function(t) | |
| close_on_q(t.bufnr) | |
| end, | |
| }) | |
| end | |
| return lazygit | |
| end | |
| local function get_dev_server(cmd) | |
| if not devserver then | |
| local Terminal = require("toggleterm.terminal").Terminal | |
| devserver = Terminal:new({ | |
| cmd = cmd, | |
| hidden = true, | |
| close_on_exit = true, | |
| auto_scroll = true, | |
| direction = "float", | |
| float_opts = { | |
| border = "double", | |
| }, | |
| on_open = function(t) | |
| close_on_q(t.bufnr) | |
| end, | |
| }) | |
| end | |
| return devserver | |
| end | |
| ---@type LazySpec | |
| return { | |
| { | |
| "akinsho/toggleterm.nvim", | |
| version = "*", | |
| config = function() | |
| local git = require("utils.git") | |
| local node = require("utils.node") | |
| local toggleterm = require("toggleterm") | |
| toggleterm.setup({ | |
| autochdir = true, | |
| direction = "horizontal", | |
| size = function(t) | |
| if t.direction == "horizontal" then | |
| return 20 | |
| elseif t.direction == "vertical" then | |
| return vim.o.columns * 0.3 | |
| end | |
| end, | |
| }) | |
| if git.is_repo() then | |
| vim.keymap.set("n", "<leader>rl", function() | |
| get_lazygit():toggle() | |
| end, { | |
| desc = "lazygit", | |
| }) | |
| end | |
| if node.manifest() ~= nil then | |
| local fname = node.lockfile() | |
| vim.notify(fname) | |
| if fname ~= nil then | |
| local runner = "npm" | |
| if fname:match("pnpm") then | |
| runner = "pnpm" | |
| end | |
| if fname:match("bun") then | |
| runner = "bun" | |
| end | |
| if fname:match("yarn") then | |
| runner = "bun" | |
| end | |
| local cmd = runner .. " run dev" | |
| vim.keymap.set("n", "<leader>rd", function() | |
| get_dev_server(cmd):toggle() | |
| end, { | |
| desc = "dev script", | |
| }) | |
| end | |
| end | |
| end, | |
| keys = { | |
| { | |
| "<leader>\\", | |
| function() | |
| require("toggleterm").toggle() | |
| end, | |
| desc = "terminal", | |
| }, | |
| }, | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment