rafamadriz / friendly-snippets Goto Github PK
View Code? Open in Web Editor NEWSet of preconfigured snippets for different languages.
License: MIT License
Set of preconfigured snippets for different languages.
License: MIT License
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.
I'll add these if i get around to it, hopefully someone beats me to it: https://github.com/juanfranblanco/vscode-solidity/blob/master/snippets/solidity.json
use \t instead of 4 spaces
friendy-snippets doesn't work on Luasnip out of the box, do I need to do add any configs?
Here are my, lsp-config , nvim-cmp and lua-snip config
https://github.com/arionrefat/dotfiles/blob/master/neovim/.config/nvim/lua/neovim-lsp-config.lua
https://github.com/arionrefat/dotfiles/blob/master/neovim/.config/nvim/lua/neovim-snip.lua
https://github.com/arionrefat/dotfiles/blob/master/neovim/.config/nvim/lua/compe-config.lua
Hello and thank you for the snippets!
Is it possible to add to your list snippets for Fortran? I found these:
https://github.com/Gimly/vscode-fortran/blob/master/snippets/fortran.json
(Haven't checked if they work)
Thanks in advance
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.
The title sums it all.
With syntax set to shell or bash, the shell snippets are working well, however when it's set to zsh, these snippets aren't loaded.
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
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.
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 :
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
snippets/c.json#L87, snippets/cpp.json#L257
"#def": {
"prefix": "#def",
"body": ["#define \"$1\" \"$2\" "],
"description": "Code snippet for #define \" \""
},
I believe this is incorrect. Macro names cannot be quoted. It should be just "#define $1 $2"
.
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?
This is an announcement more than an issue. Since some weeks ago https://github.com/L3MON4D3/LuaSnip also works with these snippets.
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?
The README says it should be compatible but I don't see any setup instructions.
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.
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.
Hello and thank you for the snippets!
Is it possible to add to your list snippets for LaTeX? I found these:
https://github.com/James-Yu/LaTeX-Workshop/blob/master/snippets/latex.json
This is a widely-used LaTeX plugin for VS Code .
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?
Seems like there should be 3
not 2
friendly-snippets/snippets/rust.json
Line 551 in 83de928
Same problem with if-let
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.
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.
In order to make the latex snippets to work I had to change in the package.json file
"language": ["plainlatex", "tex"],
Though it's an old HDL, but still a lot of users. So I'd appreciate it a lot if it's supported soon.
Miint is a language for front end.
snippets : https://github.com/mint-lang/mint-vscode/blob/master/snippets/mint.json
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 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? ๐ค
Hi, is there any instruction like #33 asked?
I think having C# snippets would be nice.
Could we grab the snippets from here?
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.
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`?
Hello.
Can you please add arrow functions?
Something like that
const bla = () => { return }
Any plans to support the Julia language in the near future?
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):
Is this a bug with LuaSnip or with friendly snippets? It shows the right in the preview window...
friendly-snippets/snippets/lua.json
Line 32 in 22c37fd
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"
},
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"
},
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.
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?
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' }
}),
})
Could you please add snippets for vue?
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?
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?
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:
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!
Nvim -v = v.06.dev
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?
Any plans to support the Kubernetes manifests in the near future?
Remove duplicate snippets in https://github.com/rafamadriz/friendly-snippets/blob/main/snippets/javascript/javascript.json
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.