Skip to content

ccaglak/snippets.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

snippets.nvim -- 100 loc snippet plugin for neovim

A lightweight and efficient snippet expansion plugin for Neovim using native neovim snippet features.

Features

  • LSP integration for seamless snippet suggestions alongside language server completions
  • JSON-based snippet definitions
  • Variable expansion in snippets

Installation

Using your preferred plugin manager, add the following:

{'ccaglak/snippets.nvim'}

Usage

Snippets will automatically be suggested in the completion menu when typing. The plugin integrates with LSP completions, so you'll see snippets alongside other suggestions.

Snippet Format

Snippets are defined in JSON files. Each snippet is defined as a JSON object with the following structure:

{
  "Console Log": {
    "prefix": "log",
    "body": "console.log($1);",
    "description": "Log output to console"
  }
}

assumes filetype.json located in nvim config snippets folder.

lua vim.fn.stdpath('config') .. '/snippets/'

Variables

The plugin supports various built-in variables for snippet expansion:

  • TM_FILENAME: Current file name
  • TM_FILENAME_BASE: Current file name without extension
  • TM_FILEPATH: Full path of the current file
  • TM_DIRECTORY: Directory of the current file
  • CURRENT_YEAR: Current year
  • CURRENT_MONTH: Current month
  • CURRENT_DATE: Current date

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

About

snippets.nvim - simple snippet expansion plugin

Topics

Resources

License

Stars

Watchers

Forks

Languages