From dd9c225fd982a0ee5ec9fd815c554e4a04091eae Mon Sep 17 00:00:00 2001 From: aleidk Date: Tue, 22 Jul 2025 14:33:01 -0400 Subject: [PATCH] add remote plugin to nvim --- Configs/fish/.config/fish/config.fish | 2 + Configs/kitty/.config/kitty/kitty.conf | 2 +- Configs/lazygit/.config/lazygit/config.yml | 8 ++-- Configs/nvim/.config/nvim/lazy-lock.json | 2 + .../.config/nvim/lua/aleidk/plugins/init.lua | 17 ++++++- .../nvim/lua/aleidk/plugins/remote-dev.lua | 45 +++++++++++++++++++ Configs/yazi/.config/yazi/keymap.toml | 5 +++ 7 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 Configs/nvim/.config/nvim/lua/aleidk/plugins/remote-dev.lua diff --git a/Configs/fish/.config/fish/config.fish b/Configs/fish/.config/fish/config.fish index 4427a62..2627b13 100644 --- a/Configs/fish/.config/fish/config.fish +++ b/Configs/fish/.config/fish/config.fish @@ -1,3 +1,5 @@ +. ~/.cargo/env.fish + if status is-interactive # Commands to run in interactive sessions can go here zoxide init --cmd cd fish | source diff --git a/Configs/kitty/.config/kitty/kitty.conf b/Configs/kitty/.config/kitty/kitty.conf index ee876ca..ce4f320 100644 --- a/Configs/kitty/.config/kitty/kitty.conf +++ b/Configs/kitty/.config/kitty/kitty.conf @@ -2002,7 +2002,7 @@ map ctrl+space>ctrl+v launch --location=split #:: For more details, see launch #:: . -map ctrl+space>g launch --cwd=current --type=overlay lazygit +map ctrl+space>g launch --cwd=current --type=overlay --var lazy_float=true lazygit #: New OS window diff --git a/Configs/lazygit/.config/lazygit/config.yml b/Configs/lazygit/.config/lazygit/config.yml index 55e13ca..04dc579 100644 --- a/Configs/lazygit/.config/lazygit/config.yml +++ b/Configs/lazygit/.config/lazygit/config.yml @@ -262,10 +262,10 @@ quitOnTopLevelReturn: true # Config relating to things outside of Lazygit like how files are opened, copying to clipboard, etc os: # Command for editing a file. Should contain "{{filename}}". - edit: "" + edit: "nvim -- {{filename}} && kitten @ close-window -m var:lazy_float=true --ignore-no-match" # Command for editing a file at a given line number. Should contain # "{{filename}}", and may optionally contain "{{line}}". - editAtLine: "" + editAtLine: "nvim +{{line}} -- {{filename}} && kitten @ close-window -m var:lazy_float=true --ignore-no-match" # Same as EditAtLine, except that the command needs to wait until the # window is closed. editAtLineAndWait: "" @@ -273,7 +273,7 @@ os: openDirInEditor: "" # A built-in preset that sets all of the above settings. Supported presets # are defined in the getPreset function in editor_presets.go. - editPreset: "nvim-remote" + editPreset: "nvim" # Command for opening a file, as if the file is double-clicked. Should # contain "{{filename}}", but doesn't support "{{line}}". open: "xdg-open {{filename}} >/dev/null" @@ -308,7 +308,7 @@ disableStartupPopups: false # - 'quit': exit Lazygit notARepository: quit # If true, display a confirmation when subprocess terminates. This allows you to view the output of the subprocess before returning to Lazygit. -promptToReturnFromSubprocess: true +promptToReturnFromSubprocess: false # Keybindings keybinding: universal: diff --git a/Configs/nvim/.config/nvim/lazy-lock.json b/Configs/nvim/.config/nvim/lazy-lock.json index f13b082..3702b64 100644 --- a/Configs/nvim/.config/nvim/lazy-lock.json +++ b/Configs/nvim/.config/nvim/lazy-lock.json @@ -4,6 +4,7 @@ "catppuccin": { "branch": "main", "commit": "56a9dfd1e05868cf3189369aad87242941396563" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, + "flatten.nvim": { "branch": "main", "commit": "72527798e75b5e34757491947c2cb853ce21dc0e" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "fzf-lua": { "branch": "main", "commit": "758173f499d15410ecb50c5519a41b27c33e645d" }, "grapple.nvim": { "branch": "main", "commit": "b41ddfc1c39f87f3d1799b99c2f0f1daa524c5f7" }, @@ -21,6 +22,7 @@ "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "render-markdown": { "branch": "main", "commit": "4a39681990fb515d00dd898de3d7bf2973805f1a" }, "smart-splits.nvim": { "branch": "master", "commit": "5ef94ca23b28148187846fc46f10184aad4d17b0" }, + "transfer.nvim": { "branch": "main", "commit": "ab12253c09f83a5b0b6ee108fc131be45abe446a" }, "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, "ts-node-action": { "branch": "master", "commit": "bfaa787cc85d753af3c19245b4142ed727a534b5" }, "vim-dadbod": { "branch": "master", "commit": "e95afed23712f969f83b4857a24cf9d59114c2e6" }, diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua index d681de9..beb326c 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/init.lua @@ -2,8 +2,8 @@ return { 'neovim/nvim-lspconfig', 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically { - "mason-org/mason.nvim", - opts = { } + "mason-org/mason.nvim", + opts = {} }, { "nvim-tree/nvim-web-devicons", lazy = true }, { @@ -26,4 +26,17 @@ return { }, }, }, + { + -- allow to reuse the same nvim instance when opening files in the same terminal context + "willothy/flatten.nvim", + opts = { + integrations = { + kitty = true, + wezterm = false, + }, + }, + -- Ensure that it runs first to minimize delay when opening file from terminal + lazy = false, + priority = 1001, + }, } diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/remote-dev.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/remote-dev.lua new file mode 100644 index 0000000..12d86b0 --- /dev/null +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/remote-dev.lua @@ -0,0 +1,45 @@ +return { + { + "coffebar/transfer.nvim", + lazy = true, + cmd = { "TransferInit", "DiffRemote", "TransferUpload", "TransferDownload", "TransferDirDiff", "TransferRepeat" }, + opts = {}, + keys = { + { "xx", function() vim.cmd("TransferRepeat") end, desc = "Repeat last transfer" }, + { "xc", function() vim.cmd("TransferInit") end, desc = "Config transfer.nvim" }, + { "xj", function() vim.cmd("TransferDownload") end, desc = "Download current file with transfer.nvim" }, + { "xJ", function() vim.cmd("TransferDownload " .. vim.uv.cwd()) end, desc = "Download root dir with transfer.nvim" }, + { "xk", function() vim.cmd("TransferUpload") end, desc = "Upload current file with transfer.nvim" }, + { "xK", function() vim.cmd("TransferUpload " .. vim.uv.cwd()) end, desc = "Upload root dir with transfer.nvim" }, + { "xd", function() vim.cmd("DiffRemote") end, desc = "Diff current file with transfer.nvim" }, + { "xD", function() vim.cmd("TransferDirDiff " .. vim.uv.cwd()) end, desc = "Diff root dir with transfer.nvim" }, + }, + init = function() + require("yazi").config.forwarded_dds_events = { + "TransferUpload", + "TransferDownload", + "DiffRemote", + "TransferDirDiff", + } + + vim.api.nvim_create_autocmd("User", { + pattern = "YaziDDSCustom", + callback = function(event) + -- vim.print(event.data); + local data = vim.json.decode(event.data.raw_data) + + if event.data.type == "DiffRemote" or event.data.type == "TransferDirDiff" then + local response = vim.system({ "ya", "emit-to", "0", "close" }, { timeout = 1000 }):wait() + + if response.stderr ~= "" then + vim.notify(response.stderr, vim.log.levels.ERROR) + return + end + end + + vim.iter(data):each(function(path) vim.cmd(string.format("%s %s", event.data.type, path)) end) + end, + }) + end + }, +} diff --git a/Configs/yazi/.config/yazi/keymap.toml b/Configs/yazi/.config/yazi/keymap.toml index cf1eb43..bcecc1e 100644 --- a/Configs/yazi/.config/yazi/keymap.toml +++ b/Configs/yazi/.config/yazi/keymap.toml @@ -39,6 +39,11 @@ prepend_keymap = [ { on = ["g", "t"], run = "cd /tmp", desc = "Go to the temporary directory" }, { on = ["g", "r"], run = "shell 'ya emit cd \"$(git rev-parse --show-toplevel)\"'", desc = "Go to git root" }, { on = ["g", ""], run = "cd --interactive", desc = "Go to a directory interactively" }, + + { on = ["", "j"], run = "shell 'ya pub-to 0 TransferDownload --list \"$@\"'", desc = "Download with transfer.nvim" }, + { on = ["", "k"], run = "shell 'ya pub-to 0 TransferUpload --list \"$@\"'", desc = "Upload with transfer.nvim" }, + { on = ["", "d"], run = ["shell 'ya pub-to 0 DiffRemote --orphan --list \"$@\"'", "quit"], desc = "Diff with transfer.nvim" }, + { on = ["", ""], run = ["shell 'ya pub-to 0 TransferDirDiff --list \"$@\"'"], desc = "Diff directory with transfer.nvim" }, ] [input]