Giter Club home page Giter Club logo

friendly-snippets's Introduction

Rafael's github stats

friendly-snippets's People

Contributors

amtoine avatar arrow-x avatar askfiy avatar aspeddro avatar bobbyrahmanda13 avatar bradsherman avatar bryant-the-coder avatar christianchiarulli avatar cryptomilk avatar davidbloss avatar dev-ardi avatar h3ndry avatar jeroenbourgois avatar jim-at-jibba avatar juanvqz avatar karyanayandi avatar kedap avatar larissa avatar lasse16 avatar lun4m avatar mohammedzeglam-pg avatar okelleydevelopment avatar ourigen avatar premell avatar rafamadriz avatar remerald avatar surmish avatar winston0410 avatar zeioth avatar zweisamkeiten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

friendly-snippets's Issues

Extend typescript snippets due to #88 changes

Hello. I've notices you drop mixing sources for some complex filetypes (ts and tsx in my case).
#88

So now I should invoke additional command to mix js and ts snippets. But i guess typescript still js. It's not a framework or something like that. And js snippets still totally relevant.
May you please copy js snippets into typescript's json to make it consistent?
E.g in js snippets console.log is cl and in ts snippets its log. And so on.

Rescript snippets extending

Hi. Yesterday I've made a pull request with new snippets. #121 for rescript.
I'm gonna to extend this little bit in the future.

Auto close tags in JSX and TSX

It would be better to have the auto closing tags in react

Right now it's

<img src="" alt="">

It should be

<img src="" alt=""/>

Let me know what changes needs to be done I can make a PR

php snippets broken because $$ doesn't properly escape $ under neovim vsnip

I have to change snippets that contain $$ to \\$ for it to work. Otherwise vsnip errors out and just prints the snippet up to the point $$ was used. The rest is truncated.

So given the following snippet

	"foreach โ€ฆ": {
		"prefix": "foreach",
		"body": [
			"foreach ($${1:variable} as $${2:key} ${3:=> $${4:value}}) {",
			"\t${0:# code...}",
			"}"
		],
		"description": "Foreach loop"
	}

only the following is printed

foreach (

However when $ is escaped properly using \$ it works as expected.

compe's first popup makes insert mode freeze or laggy

Hi there! great plugin. Ive been having this issue that compe's first popup ( autocompletion menu ) freezes or completely gets stuck for some seconds but this happens only for the first time and works fine later.

behaviour :

simplescreenrecorder-2021-06-26_15.05.46.mp4

Use single quote `'` instead of `"`

This is mostly my OCD thing. I'm always using single quote ' whenever possible. It annoy the hell out of me when I'm using snippets completion it use double quote "

I have to change back every single of them, every time and it's kind of defeat the purpose of having snippets completion.

I know we can run pettier or any other formatter, but it's nice if we have setting preference whether to use single or double quote.

Thank you for your work

Is snippet inheritance an upstream issue?

Is it possible to achieve snippet inheritance with friendly-snippet, or is that an upstream issue? Let say I have a snippet that will generate the following in Kotlin:

{
  "variable declaration": {
    "prefix": "var",
    "body": "var ${1:name} = ${2:value}",
    "description": "Snippet for a variable"
  }
}

Generating this:

var name = value

Now I want to add the keyword override into the mix, and generate this:

override var name = value

Is it possible to make a snippet that extends the original snippet and add override in front of it? Where can I find the doc and its related syntax?

Global snippets not recognized

The diso snippet in the global snippet file doesn't show up for me. If I copy that file to my g:vsnip_snippet_dir it works as expected. Maybe related to the package.json file?

Changes to react snippets

So I have been using friendly snippets for react for a while now and feel like some of them are a bit strange. For instance in react there is something called useState, which you write like this const [mynumber, setMynumber] = useState(). (mynumber is an arbitrary variable). However the current snippet only puts down one of the variables. Also friendly snippets currently import "react" from react, but you are no longer required to import react in React 17 (since oct 2020). Also when creating a functional component if doesnt automatically write the export.

A lot of these nitpicks are hard to understand if you dont use react, the main reason I am making a issue is because I want to make a PR, but first I want to check if you want to make these changes at all. Snippets are kind of subjective so its hard to say if these changes are strict improvements, but I think they make the most sense and are the most common. Also they are used in many other IDEs, like vscode etc. This doesnt make the snippets good, but it shows that my suggested snippets are pretty common (and not something strange I have come up with) and that new users would understand them easier than the current snippets.

Is shellscript meant to work for *.sh files?

Hi,
I couldn't get the bash snippets to work on *.sh named files.
But they do seem to work with python.

Using luasnip so wondering if the shellscript is meant to be used for bash scripts.

React Snippets not Loading

The snippets for react-js aren't loading but the normal javascript snippets are. The filetype of my react files are "javascript.jsx" if that helps. Is there a way I can fix this?

Curly brackets with Latex + Lunarvim ?

On LunarVim, it seems that the @{ snippet expands to \left\{ \right}, note the missing backslash before the closing curly brace. Adding a pair of backslashes to the corresponding line in latex.json fixes the issue.

I'm not sure what's going on here, or if this happens with a simpler setup.

Duplicate snippets

There are many duplicate snippets with typescript since it loads javascript snips and then typescript snips on package.json.

Also if i extend a filetype with luasnip it duplicates snippets further.

LaTeX snippets not working

In order to make the latex snippets to work I had to change in the package.json file

"language": ["plainlatex", "tex"],

Help: Not sure how to use this plugin

Hi,

I'm a bit confused on how to use this plugin. I've installed this using packer like so

 use "radamadriz/friendly-snippets"
 use({
    "L3MON4D3/LuaSnip",
    config = function()
      require("plugins.lua_snip")
    end,
  })

If I want completions for snippets in the c.json file do I just add this line to the lua_snip.lua file?

require("luasnip").filetype_extend("c", { "c" })

What about for frameworks like vue?

JS snippets dont work on vue files

JS snippets didnt work on vue files but did work on jsx files , is this normal? Also would it be possible to make them work on vue files? ๐Ÿค”

C# Support

I think having C# snippets would be nice.
Could we grab the snippets from here?

Duplicated python snippets

The following snippets are defined multiple times, with similar but not exactly the same definitions (at least def and while, I only looked at those)

$ rg -o '(?:prefix...)"([^"]+)' -r '$1' -I snippets/python | sort | uniq --count | grep 2
      2 class
      2 def
      2 for
      2 if
      2 ipdb
      2 pdb
      2 property
      2 pudb
      2 while

I'm not sure what the intention with snippets/python/base and snippets/python/python is, if you could explain that I can sort it out.

How to jump from placeholder?

I recently found that that there are placeholders in the snippet declaration. Taking snippet for func in golang for an example, after completing this snippet, the cursor will end up in $1 in insert mode.

{
  "function declaration": {
    "prefix": "func",
    "body": "func $1($2) $3 {\n\t$0\n}",
    "description": "Snippet for function declaration"
  }
}

My question is, after completing `$1`, how can I jump to `$2`? Is there any command that I can look for, or is it the responsibility of the snippet engine like `nvim-compe`?

Julia support

Any plans to support the Julia language in the near future?

React function component is being expanded inproperly

I just installed friendly-snippets together with LuaSnip, and I am experiencing the following issue: When using the rfc snippet for typescript, I am having a bad time because export const is written as exportconst.

Before (it even shows the right example):
image

After:
image

Is this a bug with LuaSnip or with friendly snippets? It shows the right in the preview window...

Cloning to add Rails seems to break the integration

I have forked and cloned the repo down to add in Rails snippet. But typescript is not working properly, for example the function prefix is returning the javascript syntax instead of typescript.

function name(params) {
  
}

For your reference, I am using vim-plug and I have it point to the directory where I have cloned it

:Plug '~/plugins/friendly-snippets'

What am I missing? How does vimsnip integrate with friendly-snippets? Do I have to locate at a specific directory?

I am able to add rails.json and then update package.json. This seems to work, but I am not sure why typescript snippet is breaking.

      {
        "language": "ruby",
        "path": "./snippets/rails.json"
      },

Update

After some researching, I am not sure if this is the part that is causing problem? If I remove typescript and typescriptreact from here, then things are working fine.

      {
        "language": [
          "javascript",
          "typescript",
          "javascriptreact",
          "typescriptreact"
        ],
        "path": "./snippets/javascript/javascript.json"
      },

Suggestion: Remove media folder

You can refer to gif/mov file from either gister or issue URL.
There is no need to put the media files in the repo. It is 6MB (3MB gif and 3MB .git history) ATM.

How to get the friendly-snippet suggestions first over the default nvim-cmp suggestions

When I type func I always get the friendly-snippet suggestions at the bottom. Is there a way to get the friendly-snippet suggestions at the top instead of the default suggestions?

Screenshot from 2022-03-17 10-23-02

Here is a part of my current setup

Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'rafamadriz/friendly-snippets'
call plug#end

local cmp = require("cmp")

cmp.setup({
    snippet = {
		  expand = function(args)
		      vim.fn["vsnip#anonymous"](args.body)
		  end,
    },
    mapping = {
		  ['<Enter>'] = cmp.mapping.confirm({ select = true })
    },
    sources = cmp.config.sources({
		  { name = 'nvim_lsp' },
		  { name = 'vsnip' }
		  }, {
		  { name = 'buffer' }
    }),
})

Snippet code style

I've noticed there isn't a uniform code style, e.g. some snippets put the opening bracket on a new line while others don't.
So what code style should a contributor use?

[Feat request] Avoid assigning multiple snippet sources to a single language

In my opinion, it would be better to avoid linking a single language to multiple snippet files.
For instance, snippets for markdown are loaded from global.json, markdown.json and vscode-jekyll-snippets.json. In my personal experience, I do not use jekyll. Therefore, the jekyll-specific snippets are just irrelevant; worse, they even conflict with some custom snippets I have set.

I believe (and so is the developer of luasnip) that it should be the job of the snippet engine to mix the various files according to the desired filetype/framework and not the job of the source to pre-mix them.

What do you think of it?

Python: parenthesis trigger same 3 snippets

Hello,

Just a repost of this issue: saadparwaiz1/cmp_luasnip#15

When I open or close parenthesis in python I get the following 3 snippets no matter the function:

image

Is it possible to change the prefix of these 3 snippets to not include () so they will not be triggered every time we open or close parenthesis?

I get the following behaviour with luasnip but the same seems to be happening with vsnip.

Thank you in advance!

Add return type annotation for python function snippet

Hi, the current behavior for python function snippet is:

def ${1:fname}(${2:arg}):
    ${3:pass}$0   

It does not have an insert text option for the return type annotation.

def my_func(x:int, y:str) -> str:
    return x * y

Can we add a return type annotation something like this?

def ${1:fname}(${2:arg}) -> ${3:return_type}:
    ${4:pass}$0   

A user may not always add a return type annotation. Therefore, the -> character would have to be optional.

What do you think?

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.