Fold Imports.Nvim banner
dmtrKovalenko dmtrKovalenko

Fold Imports.Nvim

Development community

Description

Neovim plugin to automatically fold imports in any language using treesitter

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

fold-imports.nvim

![Lua](https://img.shields.io/badge/Made%20with%20Lua-blueviolet.svg?style=for-the-badge&logo=lua) ![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white)

A Neovim plugin that automatically folds import/export statements in multiple programming languages using treesitter. Reduces visual clutter by folding verbose import blocks and showing the CODE.

https://github.com/user-attachments/assets/a1c54774-ee8a-4595-9653-bc400a34336a

Installation

Using [lazy.nvim](https://github.com/folke/lazy.nvim)

{
  "dmtrKovalenko/fold-imports.nvim",
  opts = {},
  event = "BufRead"
}

Using [packer.nvim](https://github.com/wbthomason/packer.nvim)

use {
  "dmtrKovalenko/fold-imports.nvim",
  config = function()
    require("fold_imports").setup()
  end,
}

Quick Start

The plugin works out of the box with zero configuration:

require("fold_imports").setup()

Open any supported file and imports will be automatically folded.

Configuration

Default Configuration

require("fold_imports").setup({{
  enabled = true,
  auto_fold = true,
  fold_level = 0,
  -- refolds imports after lsp code edits (e.g. code actions)
  auto_fold_after_code_action = true,
  -- custom fold text for import sections
  custom_fold_text = true,
  fold_text_format = "Folded imports (%d lines)",
  -- maximum lines for a single import statement to be considered for folding
  max_import_lines = 50,
  languages = {
    typescript = {
      enabled = true,
      parsers = { "typescript", "tsx" },
      queries = {
        "(import_statement) @import",
        "(export_statement (export_clause) @export)",
      },
      filetypes = { "typescript", "typescriptreact" },
      patterns = { "*.ts", "*.tsx" },
    },
    javascript = {
      enabled = true,
      parsers = { "javascript", "jsx" },
      queries = {
        "(import_statement) @import",
        "(export_statement (export_c