kiyoon / telescope-insert-path.nvim

Insert file path on the current buffer using Telescope.nvim
MIT License
31 stars 4 forks source link
neovim neovim-plugin nvim nvim-plugin telescope telescope-extension telescope-plugin

telescope-insert-path.nvim

Set of telescope.nvim actions to insert file path on the current buffer.

Supported Path Types

Custom source directory

The custom source directory can be set using the method require('telescope_insert_path').set_source_dir().

A default custom source directory can be set using the global option telescope_insert_path_source_dir. In the case this option is set and present in the root of the project (git root or cwd) this will be used, if the value does not exists or it's not a directory the root of the project will be used as default.

Supported Insert Locations

Supported Vim Modes after Insertion

You can configure it to be in these three modes after insertion:

Supported Telescope Modes

Installation

Install using vim-plug:

Plug 'kiyoon/telescope-insert-path.nvim'

Install using packer:

use {'kiyoon/telescope-insert-path.nvim'}

Setup telescope with path actions in vimscript / lua:

local path_actions = require('telescope_insert_path')

require('telescope').setup {
  defaults = {
    mappings = {
      n = {
        -- E.g. Type `[i`, `[I`, `[a`, `[A`, `[o`, `[O` to insert relative path and select the path in visual mode.
        -- Other mappings work the same way with a different prefix.
        ["["] = path_actions.insert_reltobufpath_visual,
        ["]"] = path_actions.insert_abspath_visual,
        ["{"] = path_actions.insert_reltobufpath_insert,
        ["}"] = path_actions.insert_abspath_insert,
        ["-"] = path_actions.insert_reltobufpath_normal,
        ["="] = path_actions.insert_abspath_normal,
    -- If you want to get relative path that is relative to the cwd, use
    -- `relpath` instead of `reltobufpath`
        -- You can skip the location postfix if you specify that in the function name.
        -- ["<C-o>"] = path_actions.insert_relpath_o_visual,
      }
    }
  }
}