-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remote-development): added remote-sshfs plugin (#1180)
* feat(remote-development): added remote-sshfs plugin * fix(remote-sshfs-nvim): fix plugin implementation --------- Co-authored-by: Micah Halter <[email protected]>
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
lua/astrocommunity/remote-development/remote-sshfs-nvim/README.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# remote-sshfs | ||
|
||
- Add plugin [remote-sshfs.nvim](https://github.com/nosduco/remote-sshfs.nvim) | ||
- Require `sshfs` & `ssh` | ||
- Bind keymap for convenience: | ||
- `<leader>Re` edit ssh config file | ||
- `<leader>Rc` select ssh target which is saved in your ssh config file | ||
- `<leader>Rd` disconnect (this will unmount sshfs) | ||
- Override telescope find_files and live_grep to make dynamic based on if connected to host | ||
- Need `fd` and `ripgrep` be installed on server machine | ||
- Check plugin README for more information |
56 changes: 56 additions & 0 deletions
56
lua/astrocommunity/remote-development/remote-sshfs-nvim/init.lua
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
---@type LazySpec | ||
return { | ||
"nosduco/remote-sshfs.nvim", | ||
cmd = { | ||
"RemoteSSHFSConnect", | ||
"RemoteSSHFSDisconnect", | ||
"RemoteSSHFSEdit", | ||
"RemoteSSHFSFindFiles", | ||
"RemoteSSHFSLiveGrep", | ||
}, | ||
opts = {}, | ||
dependencies = { | ||
"nvim-lua/plenary.nvim", | ||
{ "nvim-telescope/telescope.nvim", opts = function() require("telescope").load_extension "remote-sshfs" end }, | ||
}, | ||
specs = { | ||
{ | ||
"AstroNvim/astrocore", | ||
optional = true, | ||
opts = function(_, opts) | ||
local map = opts.mappings | ||
map.n["<Leader>R"] = { desc = "Remote" } | ||
map.n["<Leader>Rc"] = { function() require("remote-sshfs.api").connect() end, desc = "Connect" } | ||
map.n["<Leader>Rd"] = { function() require("remote-sshfs.api").disconnect() end, desc = "Disconnect" } | ||
map.n["<Leader>Re"] = { function() require("remote-sshfs.api").edit() end, desc = "Edit" } | ||
-- Override telescope find_files and live_grep to make dynamic based on if connected to host | ||
local find_files = map.n["<Leader>ff"] | ||
if type(find_files) == "table" then | ||
local orig_find_files = find_files[1] | ||
find_files[1] = function() | ||
if require("remote-sshfs.connections").is_connected then | ||
require("remote-sshfs.api").find_files() | ||
elseif type(orig_find_files) == "function" then | ||
orig_find_files() | ||
elseif type(orig_find_files) == "string" then | ||
vim.cmd(orig_find_files) | ||
end | ||
end | ||
end | ||
local live_grep = map.n["<Leader>fw"] | ||
if type(live_grep) == "table" then | ||
local orig_live_grep = live_grep[1] | ||
live_grep[1] = function() | ||
if require("remote-sshfs.connections").is_connected then | ||
require("remote-sshfs.api").live_grep() | ||
elseif type(orig_live_grep) == "function" then | ||
orig_live_grep() | ||
elseif type(orig_live_grep) == "string" then | ||
vim.cmd(orig_live_grep) | ||
end | ||
end | ||
end | ||
end, | ||
}, | ||
}, | ||
} |