GithubHelp home page GithubHelp logo

willothy / nvim-snippets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garymjr/nvim-snippets

0.0 1.0 0.0 17 KB

Snippet support using native neovim snippets

License: MIT License

Lua 100.00%

nvim-snippets's Introduction

nvim-snippets

Allow vscode style snippets to be used with native neovim snippets vim.snippet. Also comes with support for friendly-snippets.

Features

  • Supports vscode style snippets
  • Has builtin support for friendly-snippets
  • Uses vim.snippet under the hood for snippet expansion

Requirements

Installation

Using lazy.nvim

{
  "garymjr/nvim-snippets",
  keys = {
    {
      "<Tab>",
      function()
        if vim.snippet.jumpable(1) then
          vim.schedule(function()
            vim.snippet.jump(1)
          end)
          return
        end
        return "<Tab>"
      end,
      expr = true,
      silent = true,
      mode = "i",
    },
    {
      "<Tab>",
      function()
        vim.schedule(function()
          vim.snippet.jump(1)
        end)
      end,
      expr = true,
      silent = true,
      mode = "s",
    },
    {
      "<S-Tab>",
      function()
        if vim.snippet.jumpable(-1) then
          vim.schedule(function()
            vim.snippet.jump(-1)
          end)
          return
        end
        return "<S-Tab>"
      end,
      expr = true,
      silent = true,
      mode = { "i", "s" },
    },
  },
}

Configuration

Option Type Default Description
create_autocmd boolean? false Optionally load all snippets when opening a file. Only needed if not using nvim-cmp.
create_cmp_source boolean? true Optionally create a nvim-cmp source. Source name will be snippets.
friendly_snippets boolean? false Set to true if using friendly-snippets.
ignored_filetypes string[]? nil Filetypes to ignore when loading snippets.
extended_filetypes table? nil Filetypes to load snippets for in addition to the default ones. ex: {typescript = {'javascript'}}
global_snippets string[]? {'all'} Snippets to load for all filetypes.
search_paths string[] {vim.fn.stdpath('config') .. '/snippets'} Paths to search for snippets.

Example Snippet

{
  "Say hello to the world": {
    "prefix": ["hw", "hello"],
    "body": "Hello, ${1:world}!$0"
  }
}

TODO

  • Automatically detect if friendly-snippets is installed
  • Add overrides to support overriding filetype snippets
  • (Undecided) Add support for friendly-snippets package.json definitions

nvim-snippets's People

Contributors

gamurray avatar garymjr avatar willothy avatar

Watchers

 avatar

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.