Git Product home page Git Product logo

telescope-insert-path.nvim's Introduction

telescope-insert-path.nvim

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

Supported Path Types

  • Absolute path
  • Relative path (to current working directory)
  • Relative path (to buffer file)
  • Relative to git root
  • Relative to custom source direcotry

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

  • i: before cursor
  • a: after cursor
  • I: beginning of the line
  • A: end of the line
  • o: new line after
  • O: new line before

Supported Vim Modes after Insertion

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

  • Insert
  • Normal
  • Visual mode with the path selected

Supported Telescope Modes

  • Multiple selections
  • Any modes (Find files, Live grep, ...)

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,
      }
    }
  }
}

telescope-insert-path.nvim's People

Contributors

kiyoon avatar noemurr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

telescope-insert-path.nvim's Issues

Standalone picker?

Why not to create standalone pickers with different commands?:

:Telescope insert-path-rel <arg>
:Telescope insert-path-abs <arg> 
:Telescope insert-path-rel-buf <arg>
...

load as extension

Hi,

how can I register and load your nice extension with load_extension ?

Bug with Zenmode Pluging? Inserting multiple times

Hi I love your plugin, I'm not sure why it's not global sensation.... (are people really content to look up relative paths for all their imports, temporarily memorize them, then type them? maybe they have sufficiently advanced autocomplete)

Anyway, bug with with folke/zen-mode.nvim...
I'd understand completely if its a 'won't fix' (it works when not in ZenMode) but maybe it's simple or you consider this particular zen-mode plugin popular enough to take a look at it...

telescope-path

How to insert in insert mode

Hi and thank you for this wonderful plugin.

I wonder if it is possible to add the selected file in insert mode with ctrl-enter? I have tried this, but it does not work as I have to leave the insert mode when in Telescope to insert the selected file. What I am looking for is just select a file and ctrl-enter to insert it at cursor position.

          mappings = {
            i = {
              ['<C-u>'] = false,
              ['<C-d>'] = false,
              ['<C-CR>'] = path_actions.insert_relpath_visual,             
            },           
          },

Thanks

attempt to call global 'trim' (a nil value)

I get the following error in the latest commit:

Error detected while processing /Users/uloco/.dotfiles/nvim/.config/nvim/after/plugin/telescope.rc.lua:
E5113: Error while calling lua chunk: ...cope-insert-path.nvim/lua/telescope_insert_path/init.lua:29: attempt to call global 'trim' (a nil value)
stack traceback:
        ...cope-insert-path.nvim/lua/telescope_insert_path/init.lua:29: in function 'get_git_root'
        ...cope-insert-path.nvim/lua/telescope_insert_path/init.lua:38: in function 'get_git_root_or_cwd'
        ...cope-insert-path.nvim/lua/telescope_insert_path/init.lua:268: in main chunk
        [C]: in function 'require'
        ...dotfiles/nvim/.config/nvim/after/plugin/telescope.rc.lua:14: in main chunk

Failed to call trim() on neovim start-up

I don't know if this is related to my setup (I just switched to Lazy.nvim from Vim-Plug, or a result of the update you pushed recently...Here's my config:

--/home/zmg/.config/nvim/lua/plugins/Telescope/telescope-insert-path.lua

return {
  {
 'kiyoon/telescope-insert-path.nvim',
 config = function (_,opts)

 end,
 opts = function()
   local path_actions = require('telescope_insert_path')

      mappings = {
        n = {
         ...
        }
      }
      return {defaults = mappings}
    end
 }
 }

Stacktrace:

Failed to run `config` for telescope-insert-path.nvim
...cope-insert-path.nvim/lua/telescope_insert_path/init.lua:29: attempt to call global 'trim' (a nil value
)
 stacktrace:
  - /telescope-insert-path.nvim/lua/telescope_insert_path/init.lua:29 _in_ **get_git_root**
  - /telescope-insert-path.nvim/lua/telescope_insert_path/init.lua:38 _in_ **get_git_root_or_cwd**
  - /telescope-insert-path.nvim/lua/telescope_insert_path/init.lua:268
  - ~/.config/nvim/lua/plugins/Telescope/telescope-insert-path.lua:8 _in_ **values**
  - ~/.config/nvim/lua/lazy.lua:16
Press ENTER or type command to continue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.