diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-10-17 21:26:40 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-10-17 21:26:40 +0200 |
| commit | 54a7c1bf02da30c353ddb4af51b065d895801f47 (patch) | |
| tree | 08dfaa302a7c7018d0dc03fe00518c8129c87c7b /.config/nvim/lua/plugins/telescope.lua | |
| parent | 1938838a043b13169a550af5ea37239adfc75293 (diff) | |
| parent | c3c0307c2fc26410249df9578c7bf16eb0caa9df (diff) | |
| download | dotfiles-54a7c1bf02da30c353ddb4af51b065d895801f47.tar.gz dotfiles-54a7c1bf02da30c353ddb4af51b065d895801f47.zip | |
Merge commit '67d475c7259bf2448fa3f1d330885ea88036668d'
Diffstat (limited to '.config/nvim/lua/plugins/telescope.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/telescope.lua | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 0167aa3..cf0864a 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -340,6 +340,7 @@ function M.find_configs() '~/.prettierrc.yml', '~/.ssh', '~/README.md', + '~/.config/inputrc', }, file_ignore_patterns = { '/nvim/startup.log', @@ -391,7 +392,7 @@ function M.find_projects() local search_dir = '~/projects' pickers .new({}, { - prompt_title = 'Change Directory', + prompt_title = 'Find Projects', finder = finders.new_oneshot_job({ 'find', vim.fn.expand(search_dir), @@ -450,26 +451,49 @@ function M.find_notes() end function M.find_books() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = false, - prompt_title = ' Find Books', - path_display = { 'smart' }, - search_dirs = { - '~/documents/books', - '~/books', - }, - layout_strategy = 'horizontal', - layout_config = { preview_width = 0.65, width = 0.75 }, - }) -end + local search_dir = '~/documents/books' -function M.file_explorer() - require('telescope.builtin').file_browser({ - prompt_title = 'File Browser', - cwd = '~', - layout_strategy = 'horizontal', - }) + pickers + .new({}, { + prompt_title = 'Find Books', + finder = finders.new_oneshot_job({ + 'find', + vim.fn.expand(search_dir), + '-type', + 'd', + '-o', + '-type', + 'f', + '-maxdepth', + '1', + }), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local path = entry.value + actions.close(prompt_bufnr, false) + + -- Determine whether it's a directory or a file + local is_directory = vim.fn.isdirectory(path) + + if is_directory then + -- It's a directory, navigate to it + vim.fn.chdir(path) + vim.cmd('e .') + print('Selected directory: ' .. path) + else + -- It's a file, do something with it (open it, for example) + print('Selected file: ' .. path) + end + end + end) + return true + end, + }) + :find() end function M.grep_current_dir() |
