Skip to content

caplod/extract.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

extract.nvim

This is a neovim plugin to help refactoring code when using snippets/partials.

usage

Usage

Visual select some code that you want to extract into a partial or snippet. Type :Extract then enter path/to/snippets/file.extension

  1. The selected code gets extracted to that file.
  2. If the file extension is found in templates the code gets substituted by the replacement with the path
  3. optional the path gets cut if any string in extract_dirs is found. ex. if the entered path is snippets/mysnippet.php the replacement is <?php snippet('mysnippet') ?>

Setup

You can add or modify the given templates.

Default setup:

templates = {
    css = {
      replacement = "@import '##path##.css';",
      extract_dirs = {
        'css',
        'stylesheets',
      },
    },
    php = {
      replacement = "<?php snippet('##path##') ?>",
      extract_dirs = {
        'snippets',
      },
    },
    lua = {
      replacement = "require('##path##')"
    }
}

Installation

{
    'caplod/extract.vim', 
}

Optional

Setup a key mapping like this:

vim.keymap.set('v', '<leader>x', ":Extract<cr>", { desc = "extract to partial" })

About

This is a neovim plugin to help refactoring code when using snippets/partials.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages