TheFirstMinute
TheFirstMinute

Reputation: 99

Neovim Telescope Read File Into Current File?

Jumping on this lua-neovim bandwagon...Need help with Telescope, please.

In my old setup; I'd grab basic templates from my documents like: <leader>gt :-1read ~/Documents/templates/

And then I just use vim's normal tab completion to get where I need to go, but with telescope's fuzzy search and preview window, this will go to the next level!

I can open my templates like this lua require('telescope.builtin').find_files{ cwd = '~/Documents/templates/' }

I've tried several combos with :read and various brackets, to make it read the contents into the current file to no avail (just learning Lua now, so mostly just crash and bang methods)

I found this in the docs with vague mention to reading files

previewers.buffer_previewer_maker({filepath}, {bufnr}, {opts}) previewers.buffer_previewer_maker()

But I'm obviously missing something.

Ideally I'd want key combo in the mappings, that way I can open normally, or read it (bonus points if it inserts at the cursor) - along with the miriad of options already available.

  mappings = {
    i = {
      ["<C-n>"] = actions.cycle_history_next,
      ["<C-p>"] = actions.cycle_history_prev,
      ...
      ["<C-r>"] = actions.READ_FILE_INTO_BUFFER,
      ...

Anyways, I've spent way too long on this, and I'm sure one of you Lua/Neovim Geniuses will have the solution!

Thanks!

Upvotes: 2

Views: 1079

Answers (0)

Related Questions