Skip to content

piersolenski/telescope-import.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚢 telescope-import.nvim

An extension for telescope.nvim that allows you to import modules faster based on what you've already imported in your project.

Often we find ourselves importing the same modules over and over again in an existing project. Rather than typing out import statements from scratch or yanking them from other existing files, telescope-import.nvim searches your project for existing import statements giving you a faster way to add them to the current buffer. Import patterns are sorted by frequency, so your most used statements are usually just a few keystrokes away.

For languages that support auto importing through their LSP, telescope-import may still be of benefit by importing frequently used patterns of exports, rather than individually importing one at a time, or all at once, which can be inaccurate when there are multiple symbols with the same name in the project.

telescope-import.mp4

🤖 Supported languages

  • Bash
  • C++
  • Java
  • JavaScript
  • Typescript
  • Lua
  • PHP
  • Python
  • Swift
  • Zsh

🔩 Installation

Install ripgrep.

-- Lazy
{
  'piersolenski/telescope-import.nvim',
  dependencies = 'nvim-telescope/telescope.nvim',
  config = function()
    require("telescope").load_extension("import")
  end
}

⚙️ Configuration

require("telescope").setup({
  extensions = {
    import = {
      -- Add imports to the top of the file keeping the cursor in place
      insert_at_top = true,
      -- Support additional languages
      custom_languages = {
        {
          -- The regex pattern for the import statement
          regex = [[^(?:import(?:[\"'\s]*([\w*{}\n, ]+)from\s*)?[\"'\s](.*?)[\"'\s].*)]],
          -- The Vim filetypes
          filetypes = { "typescript", "typescriptreact", "javascript", "react" },
          -- The filetypes that ripgrep supports (find these via `rg --type-list`)
          extensions = { "js", "ts" },
        },
      },
    },
  },
})

🚀 Usage

:Telescope import

About

Import modules with ease

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages