refactored keybindings; added search and grep to nvim-tree
This commit is contained in:
parent
e254433f2c
commit
0c6dab5310
9 changed files with 314 additions and 252 deletions
218
keymaps.nix
218
keymaps.nix
|
@ -2,23 +2,6 @@
|
|||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
# -----------------------------------------------------
|
||||
# nvim-tree
|
||||
# -----------------------------------------------------
|
||||
|
||||
## Go to current buffer's file in nvim-tree
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",n";
|
||||
action = ":NvimTreeFindFile<CR>";
|
||||
}
|
||||
## Toggle nvim-tree visibility
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",m";
|
||||
action = ":NvimTreeToggle<CR>";
|
||||
}
|
||||
|
||||
# -----------------------------------------------------
|
||||
# buffer manipulation
|
||||
# -----------------------------------------------------
|
||||
|
@ -53,207 +36,6 @@
|
|||
action = ":tabnew split<CR>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Telescope
|
||||
# -----------------------------------------------------
|
||||
|
||||
## Lists files in your current working directory, respects .gitignore
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>ff";
|
||||
action = "<cmd>Telescope find_files<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
## Finds files by filename
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-p>";
|
||||
action = "<cmd>Telescope find_files<cr>";
|
||||
# action = "<cmd>FzfLua files<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Search for a string in your current working directory and get results live as you type, respects .gitignore. (Requires ripgrep)
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fg";
|
||||
action = "<cmd>Telescope live_grep<cr>";
|
||||
# action = "<cmd>FzfLua live_grep<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Search file contents
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-s>";
|
||||
action = "<cmd>Telescope live_grep<cr>";
|
||||
# action = "<cmd>FzfLua live_grep<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists open buffers in current neovim instance
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>db";
|
||||
action = "<cmd>Telescope buffers<cr>";
|
||||
# action = "<cmd>FzfLua buffers<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists available help tags and opens a new window with the relevant help info on <cr>
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fh";
|
||||
action = "<cmd>Telescope help_tags<cr>";
|
||||
# action = "<cmd>FzfLua helptags<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists manpage entries, opens them in a help window on <cr>
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fm";
|
||||
action = "<cmd>Telescope man_pages<cr>";
|
||||
# action = "<cmd>FzfLua manpages<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists previously open files
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fp";
|
||||
action = "<cmd>Telescope oldfiles<cr>";
|
||||
# action = "<cmd>FzfLua oldfiles<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists previously open files, Maps to ctrl-/
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-_>";
|
||||
action = "<cmd>Telescope oldfiles<cr>";
|
||||
# action = "<cmd>FzfLua oldfiles<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists spelling suggestions for the current word under the cursor, replaces word with selected suggestion on <cr>
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fs";
|
||||
action = "<cmd>Telescope spell_suggest<cr>";
|
||||
# action = "<cmd>FzfLua spell_suggest<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists LSP references for iword under the cursor
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fr";
|
||||
action = "<cmd>Telescope lsp_references<cr>";
|
||||
# action = "<cmd>FzfLua lsp_references<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists LSP incoming calls for word under the cursor
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fi";
|
||||
action = "<cmd>Telescope lsp_incoming_calls<cr>";
|
||||
# action = "<cmd>FzfLua lsp_incoming_calls<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists LSP outgoing calls for word under the cursor
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fo";
|
||||
action = "<cmd>Telescope lsp_outgoing_calls<cr>";
|
||||
# action = "<cmd>FzfLua lsp_outgoing_calls<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Dynamically Lists LSP for all workspace symbols
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fw";
|
||||
action = "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>";
|
||||
# action = "<cmd>FzfLua lsp_workspace_symbols<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fd";
|
||||
action = "<cmd>Telescope lsp_definitions<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Got to previous error
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "[d";
|
||||
action = "<cmd>lua vim.diagnostic.goto_prev()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",k";
|
||||
action = "<cmd>lua vim.diagnostic.goto_prev()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
# Got to next error
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "]d";
|
||||
action = "<cmd>lua vim.diagnostic.goto_next()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",j";
|
||||
action = "<cmd>lua vim.diagnostic.goto_next()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
|
||||
## Other Telescope options:
|
||||
## git_files search only files in git, respects .gitignore
|
||||
## oldfiles previously opened files
|
||||
## command_history
|
||||
## search_history
|
||||
## man_pages
|
||||
## resume lists the results including multi-selections of the previous
|
||||
## picker
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Diff
|
||||
# -----------------------------------------------------
|
||||
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",d";
|
||||
## @TODO: This doesn't work
|
||||
action = ''
|
||||
function()
|
||||
if next(require('diffview.lib').views) == nil then
|
||||
vim.cmd('DiffviewOpen origin')
|
||||
else
|
||||
vim.cmd('DiffviewClose')
|
||||
end
|
||||
end
|
||||
'';
|
||||
options = { noremap = true; };
|
||||
}
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Bufferline
|
||||
# -----------------------------------------------------
|
||||
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<A-h>";
|
||||
action = ":BufferLineCyclePrev<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<A-l>";
|
||||
action = ":BufferLineCycleNex<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<A-c>";
|
||||
action = ":bdelete!<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
cursorline = true; # Highlight line cursor sits on
|
||||
|
||||
## @TODO Review these
|
||||
completeopt = ""; # Completion options
|
||||
completeopt = "menuone,noselect";
|
||||
hidden = true; # Enable modified buffers in background
|
||||
inccommand = "nosplit"; # Show effects of a command incrementally
|
||||
joinspaces = false; # No double spaces with join after a dot
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<A-h>";
|
||||
action = ":BufferLineCyclePrev<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<A-l>";
|
||||
action = ":BufferLineCycleNex<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<A-c>";
|
||||
action = ":bdelete!<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
];
|
||||
|
||||
plugins.bufferline = {
|
||||
enable = true;
|
||||
# extraOptions = {
|
||||
|
|
|
@ -81,8 +81,7 @@
|
|||
};
|
||||
|
||||
completion = {
|
||||
# completeopt = "menuone,noselect";
|
||||
completeopt = "";
|
||||
completeopt = "menuone,noselect";
|
||||
};
|
||||
|
||||
autoEnableSources = true;
|
||||
|
@ -117,7 +116,7 @@
|
|||
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
|
||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||
"<C-c>" = "cmp.mapping.complete()";
|
||||
"<Tab>" = "cmp.mapping.confirm({ select = true })";
|
||||
"<Tab>" = "cmp.mapping.confirm({ select = false })";
|
||||
# "<Tab>" = ''
|
||||
# cmp.mapping(function(fallback)
|
||||
# -- local context = require("cmp.config.context")
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
./cmp.nix
|
||||
./codecompanion.nix
|
||||
./copilot.nix
|
||||
./diffview.nix
|
||||
./fzf-lua.nix
|
||||
./lazydev.nix
|
||||
./lsp.nix
|
||||
|
@ -21,11 +22,10 @@
|
|||
|
||||
programs.nixvim.plugins = {
|
||||
comment.enable = true;
|
||||
diffview.enable = true;
|
||||
fugitive.enable = true;
|
||||
gitsigns.enable = true;
|
||||
indent-blankline.enable = true;
|
||||
lightline.enable = true;
|
||||
lightline.enable = false;
|
||||
lsp-signature.enable = true;
|
||||
# config = ''
|
||||
# lua << EOF
|
||||
|
|
24
plugins/diffview.nix
Normal file
24
plugins/diffview.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",d";
|
||||
## @TODO: This doesn't work
|
||||
action = ''
|
||||
function()
|
||||
if next(require('diffview.lib').views) == nil then
|
||||
vim.cmd('DiffviewOpen origin')
|
||||
else
|
||||
vim.cmd('DiffviewClose')
|
||||
end
|
||||
end
|
||||
'';
|
||||
options = { noremap = true; };
|
||||
}
|
||||
];
|
||||
|
||||
plugins.diffview.enable = true;
|
||||
};
|
||||
}
|
|
@ -1,33 +1,66 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
|
||||
extraFiles = {
|
||||
"lua/treeutils.lua" = {
|
||||
source = ./treeutils.lua;
|
||||
};
|
||||
};
|
||||
|
||||
keymaps = [
|
||||
## Go to current buffer's file in nvim-tree
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",n";
|
||||
action = ":NvimTreeFindFile<CR>";
|
||||
}
|
||||
## Toggle nvim-tree visibility
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",m";
|
||||
action = ":NvimTreeToggle<CR>";
|
||||
}
|
||||
## Search current path
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-f>";
|
||||
action = "<cmd>lua require('treeutils').launch_find_files()<CR>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-g>";
|
||||
action = "<cmd>lua require('treeutils').launch_live_grep()<CR>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
];
|
||||
|
||||
plugins.nvim-tree = {
|
||||
enable = true;
|
||||
extraOptions = {
|
||||
actions = {
|
||||
remove_file = {
|
||||
close_window = false;
|
||||
};
|
||||
actions = {
|
||||
removeFile = {
|
||||
closeWindow = false;
|
||||
};
|
||||
## Keep tree open if already open when opening a tab
|
||||
tab = {
|
||||
sync = {
|
||||
open = true;
|
||||
close = true;
|
||||
};
|
||||
};
|
||||
view = {
|
||||
width = 30;
|
||||
};
|
||||
renderer = {
|
||||
group_empty = true;
|
||||
};
|
||||
git = {
|
||||
enable = true;
|
||||
ignore = false;
|
||||
timeout = 500;
|
||||
};
|
||||
## Keep tree open if already open when opening a tab
|
||||
tab = {
|
||||
sync = {
|
||||
open = true;
|
||||
close = true;
|
||||
};
|
||||
};
|
||||
view = {
|
||||
width = 30;
|
||||
};
|
||||
renderer = {
|
||||
groupEmpty = true;
|
||||
};
|
||||
git = {
|
||||
enable = true;
|
||||
ignore = false;
|
||||
timeout = 500;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,163 @@
|
|||
{ ... }:
|
||||
{
|
||||
programs.nixvim = {
|
||||
keymaps = [
|
||||
## Lists files in your current working directory, respects .gitignore
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>ff";
|
||||
action = "<cmd>Telescope find_files<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
## Finds files by filename
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-p>";
|
||||
action = "<cmd>Telescope find_files<cr>";
|
||||
# action = "<cmd>FzfLua files<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Search for a string in your current working directory and get results live as you type, respects .gitignore. (Requires ripgrep)
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fg";
|
||||
action = "<cmd>Telescope live_grep<cr>";
|
||||
# action = "<cmd>FzfLua live_grep<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Search file contents
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-s>";
|
||||
action = "<cmd>Telescope live_grep<cr>";
|
||||
# action = "<cmd>FzfLua live_grep<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists open buffers in current neovim instance
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>db";
|
||||
action = "<cmd>Telescope buffers<cr>";
|
||||
# action = "<cmd>FzfLua buffers<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists available help tags and opens a new window with the relevant help info on <cr>
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fh";
|
||||
action = "<cmd>Telescope help_tags<cr>";
|
||||
# action = "<cmd>FzfLua helptags<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists manpage entries, opens them in a help window on <cr>
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fm";
|
||||
action = "<cmd>Telescope man_pages<cr>";
|
||||
# action = "<cmd>FzfLua manpages<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists previously open files
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fp";
|
||||
action = "<cmd>Telescope oldfiles<cr>";
|
||||
# action = "<cmd>FzfLua oldfiles<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists previously open files, Maps to ctrl-/
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<c-_>";
|
||||
action = "<cmd>Telescope oldfiles<cr>";
|
||||
# action = "<cmd>FzfLua oldfiles<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
## Binding currently used by nvim-tree
|
||||
## Lists spelling suggestions for the current word under the cursor, replaces word with selected suggestion on <cr>
|
||||
# {
|
||||
# mode = [ "n" ];
|
||||
# key = "<leader>fs";
|
||||
# action = "<cmd>Telescope spell_suggest<cr>";
|
||||
# # action = "<cmd>FzfLua spell_suggest<cr>";
|
||||
# options = { noremap = true; };
|
||||
# }
|
||||
# Lists LSP references for iword under the cursor
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fr";
|
||||
action = "<cmd>Telescope lsp_references<cr>";
|
||||
# action = "<cmd>FzfLua lsp_references<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists LSP incoming calls for word under the cursor
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fi";
|
||||
action = "<cmd>Telescope lsp_incoming_calls<cr>";
|
||||
# action = "<cmd>FzfLua lsp_incoming_calls<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Lists LSP outgoing calls for word under the cursor
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fo";
|
||||
action = "<cmd>Telescope lsp_outgoing_calls<cr>";
|
||||
# action = "<cmd>FzfLua lsp_outgoing_calls<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Dynamically Lists LSP for all workspace symbols
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fw";
|
||||
action = "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>";
|
||||
# action = "<cmd>FzfLua lsp_workspace_symbols<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "<leader>fd";
|
||||
action = "<cmd>Telescope lsp_definitions<cr>";
|
||||
options = { noremap = true; };
|
||||
}
|
||||
# Got to previous error
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "[d";
|
||||
action = "<cmd>lua vim.diagnostic.goto_prev()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",k";
|
||||
action = "<cmd>lua vim.diagnostic.goto_prev()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
# Got to next error
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = "]d";
|
||||
action = "<cmd>lua vim.diagnostic.goto_next()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
{
|
||||
mode = [ "n" ];
|
||||
key = ",j";
|
||||
action = "<cmd>lua vim.diagnostic.goto_next()<CR>";
|
||||
options = { noremap = true; silent = true; };
|
||||
}
|
||||
|
||||
## Other Telescope options:
|
||||
## git_files search only files in git, respects .gitignore
|
||||
## oldfiles previously opened files
|
||||
## command_history
|
||||
## search_history
|
||||
## man_pages
|
||||
## resume lists the results including multi-selections of the previous
|
||||
## picker
|
||||
];
|
||||
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.ui-select.enable = true;
|
||||
|
@ -16,14 +173,14 @@
|
|||
"<c-e>" = {
|
||||
__raw = "require('telescope.actions').to_fuzzy_refine";
|
||||
};
|
||||
# "<c-o>" = {
|
||||
# __raw = "require('trouble.sources.telescope').open";
|
||||
# };
|
||||
"<c-o>" = {
|
||||
__raw = "require('trouble.sources.telescope').open";
|
||||
};
|
||||
};
|
||||
n = {
|
||||
# "<c-o>" = {
|
||||
# __raw = "require('trouble.sources.telescope').open";
|
||||
# };
|
||||
"<c-o>" = {
|
||||
__raw = "require('trouble.sources.telescope').open";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
46
plugins/treeutils.lua
Normal file
46
plugins/treeutils.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
local api = require("nvim-tree.api")
|
||||
local openfile = require'nvim-tree.actions.node.open-file'
|
||||
local actions = require'telescope.actions'
|
||||
local action_state = require'telescope.actions.state'
|
||||
local M = {}
|
||||
|
||||
local view_selection = function(prompt_bufnr, map)
|
||||
actions.select_default:replace(function()
|
||||
actions.close(prompt_bufnr)
|
||||
local selection = action_state.get_selected_entry()
|
||||
local filename = selection.filename
|
||||
if (filename == nil) then
|
||||
filename = selection[1]
|
||||
end
|
||||
openfile.fn('preview', filename)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
function M.launch_live_grep(opts)
|
||||
return M.launch_telescope("live_grep", opts)
|
||||
end
|
||||
|
||||
function M.launch_find_files(opts)
|
||||
return M.launch_telescope("find_files", opts)
|
||||
end
|
||||
|
||||
function M.launch_telescope(func_name, opts)
|
||||
local telescope_status_ok, _ = pcall(require, "telescope")
|
||||
if not telescope_status_ok then
|
||||
return
|
||||
end
|
||||
local node = api.tree.get_node_under_cursor()
|
||||
local is_folder = node.fs_stat and node.fs_stat.type == 'directory' or false
|
||||
local basedir = is_folder and node.absolute_path or vim.fn.fnamemodify(node.absolute_path, ":h")
|
||||
if (node.name == '..' and TreeExplorer ~= nil) then
|
||||
basedir = TreeExplorer.cwd
|
||||
end
|
||||
opts = opts or {}
|
||||
opts.cwd = basedir
|
||||
opts.search_dirs = { basedir }
|
||||
opts.attach_mappings = view_selection
|
||||
return require("telescope.builtin")[func_name](opts)
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Reference in a new issue