From 08eec76067ce6288e8aaa6f7f35d49260aa3d028 Mon Sep 17 00:00:00 2001 From: yzinchuk Date: Thu, 18 Jun 2026 20:34:32 -0400 Subject: [PATCH] television and zoxide integration --- lua/custom/plugins/television.lua | 113 ++++++++++++++++++++++++++++++ lua/custom/plugins/zoxide.lua | 55 +++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 lua/custom/plugins/television.lua create mode 100644 lua/custom/plugins/zoxide.lua diff --git a/lua/custom/plugins/television.lua b/lua/custom/plugins/television.lua new file mode 100644 index 0000000..ce7e01e --- /dev/null +++ b/lua/custom/plugins/television.lua @@ -0,0 +1,113 @@ +vim.pack.add { + { + src = 'https://github.com/alexpasmantier/tv.nvim', + version = 'main', + }, +} + +-- Built-in tv.nvim handlers. +local h = require('tv').handlers + +require('tv').setup { + layout = 'landscape', -- 'landscape' (default) or 'portrait' + window = { + width = 0.8, + height = 0.8, + border = 'none', + title = ' tv.nvim ', + title_pos = 'center', + }, + channels = { + files = { + layout = 'portrait', + keybinding = '', + handlers = { + [''] = h.open_as_files, + [''] = h.send_to_quickfix, + [''] = h.open_in_split, + [''] = h.open_in_vsplit, + [''] = h.copy_to_clipboard, + }, + }, + + text = { + layout = 'portrait', + keybinding = '', + handlers = { + [''] = h.open_at_line, + [''] = h.send_to_quickfix, + [''] = h.open_in_split, + [''] = h.open_in_vsplit, + [''] = h.copy_to_clipboard, + }, + }, + + ['git-log'] = { + keybinding = 'gl', + handlers = { + [''] = function(entries, config) + if #entries > 0 then + vim.cmd 'enew | setlocal buftype=nofile bufhidden=wipe' + vim.cmd('silent 0read !git show ' .. vim.fn.shellescape(entries[1])) + vim.cmd '1delete _ | setlocal filetype=git nomodifiable' + vim.cmd 'normal! gg' + end + end, + [''] = h.copy_to_clipboard, + }, + }, + + ['git-branch'] = { + keybinding = 'gb', + handlers = { + [''] = h.execute_shell_command 'git checkout {}', + [''] = h.copy_to_clipboard, + }, + }, + + ['docker-images'] = { + keybinding = 'di', + window = { title = ' Docker Images ' }, + handlers = { + [''] = function(entries, config) + if #entries > 0 then + vim.ui.input({ + prompt = 'Container name: ', + default = 'my-container', + }, function(name) + if name and name ~= '' then + local cmd = string.format('docker run -it --name %s %s', name, entries[1]) + vim.cmd('!' .. cmd) + end + end) + end + end, + [''] = h.copy_to_clipboard, + }, + }, + + env = { + keybinding = 'ev', + handlers = { + [''] = h.insert_at_cursor, + [''] = h.insert_on_new_line, + [''] = h.copy_to_clipboard, + }, + }, + + alias = { + keybinding = 'al', + handlers = { + [''] = h.insert_at_cursor, + [''] = h.copy_to_clipboard, + }, + }, + }, + tv_binary = 'tv', + global_keybindings = { + channels = 'tv', + }, + quickfix = { + auto_open = true, + }, +} diff --git a/lua/custom/plugins/zoxide.lua b/lua/custom/plugins/zoxide.lua new file mode 100644 index 0000000..2b78953 --- /dev/null +++ b/lua/custom/plugins/zoxide.lua @@ -0,0 +1,55 @@ +-- Zoxide integration for Neovim +-- Allows you to use zoxide's smart directory jumping within Neovim + +-- Install telescope-zoxide plugin +local gh = function(repo) + return 'https://github.com/' .. repo +end + +vim.pack.add { gh 'jvgrootveld/telescope-zoxide' } + +-- Configure telescope-zoxide +require('telescope').load_extension 'zoxide' + +-- Keymaps for zoxide +vim.keymap.set('n', 'cd', function() + require('telescope').extensions.zoxide.list() +end, { desc = '[C]hange [D]irectory with zoxide' }) + +-- Optional: Create a command to change directory using zoxide +vim.api.nvim_create_user_command('Z', function(opts) + local path = opts.args + if path == '' then + -- If no argument, open telescope picker + require('telescope').extensions.zoxide.list() + else + -- Otherwise, use zoxide to find and change to directory + local handle = io.popen('zoxide query -- ' .. vim.fn.shellescape(path)) + if handle then + local result = handle:read '*a' + handle:close() + result = result:gsub('%s+$', '') -- trim trailing whitespace + if result ~= '' then + vim.cmd('cd ' .. vim.fn.fnameescape(result)) + print('Changed directory to: ' .. result) + else + print('Directory not found in zoxide database') + end + end + end +end, { nargs = '*', desc = 'Change directory using zoxide' }) + +-- Optional: Create commands similar to zoxide's zi (interactive) +vim.api.nvim_create_user_command('Zi', function() + require('telescope').extensions.zoxide.list() +end, { desc = 'Interactive zoxide directory picker' }) + +-- Optional: Add zoxide entries when changing directories in Neovim +-- This keeps your zoxide database in sync with Neovim directory changes +vim.api.nvim_create_autocmd('DirChanged', { + callback = function() + local dir = vim.fn.getcwd() + vim.fn.system('zoxide add ' .. vim.fn.shellescape(dir)) + end, + desc = 'Add directory to zoxide database when changing directories in Neovim', +})