Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Rodrigo Queiro
@drigz
@PratikBhusal, do you mean something like this?
snippet bordp "Add a border pair" b
" $1 {{{ `!p snip.rv = '-' * (70 - len(t[1]))`
${0:${VISUAL:" Content}}
" $1 }}} `!p snip.rv = '-' * (70 - len(t[1]))`
endsnippet
If that's not the right number of dashes, you can change the expression (70 - len(t[1]))
Charles-André Bouffard
@cabouffard

Hi! I'm having a small problem with UltiSnips;

When I'm in a vim buffer, the default python and all snippets work, but not my custom one.. Ultisnips detects that I've created custom snippets, but I'm unable to expand them.
I've checked if the snippets were found and they are;

:UltiSnipEdit!
1: /Users/cabouffard/src/configs/UltiSnips/all.snippets
2: /Users/cabouffard/src/configs/UltiSnips/python.snippets
3: /Users/cabouffard/src/configs/dotfiles/.vim/bundle/vim-snippets/UltiSnips/all.snippets
4: /Users/cabouffard/src/configs/dotfiles/.vim/bundle/vim-snippets/UltiSnips/python.snippets

I made sure that my rtp contained my folder with set rtp+=~/src/configs/UltiSnips/ and when I do :UltilSnipEdit it correctly open my custom file.

My custom python.snippets file includes:

snippet dw "print test" b
This should print this text
endsnippet

I've tried adding custom snippets to my all.snippets file but I have the exact same behavior.

Here are my custom configurations for UltiSnips:

    let g:UltiSnipsExpandTrigger = "<tab>"
    let g:UltiSnipsJumpForwardTrigger = "<tab>"
    let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
    let g:UltiSnipsSnippetsDir = "/Users/cabouffard/src/configs/UltiSnips"
    let g:ultisnips_python_quoting_style = 'single'
    let g:ultisnips_python_style = 'google'

Any suggestions?

Pratik Bhusal
@PratikBhusal
@drigz It works amazingly! Could you tell me what t[1] represents? I know what len() does thanks to :h len().

@cabouffard I faced a similar issue before. Since you use the vim-snippets repository, consider adding these lines:

let g:UltiSnipsSnippetsDir = "/Users/cabouffard/src/configs/UltiSnips"
let g:UltiSnipsSnippetDirectories=["UltiSnips","bundle/vim-snippets/UltiSnips"]

Just be aware that I'm assuming /Users/cabouffard/src/configs/UltiSnips is the full path to your custom snippets directory.

Pratik Bhusal
@PratikBhusal
If it doesn't work, please feel free to say so
Charles-André Bouffard
@cabouffard

@PratikBhusal Hey! I'm having the exact same problem with your recommended change.

Yes the path I've given is the full path to my custom snippets:

UltiSnips ➤ pwd                                                                                                                                                                                
/Users/cabouffard-glossier/src/configs/UltiSnips
UltiSnips ➤ ls                                                                                                                                                                                 
all.snippets    python.snippets

:/

Rodrigo Queiro
@drigz
@PratikBhusal t[1] refers to what you typed in place of $1. :help UltiSnips-python for more info
aalvarado
@aalvarado
can you match a parenthesis with a new line as a trigger?
ie
snip (\n "paren"
(
  ${1}
)$0
snippet
dustbyte
@maskedbyte
Is it possible at all to un-indent in a snippet?
For a case statement I need it unindented

where | is the cursor

switch (...) {
    case|
}

after expanding tthe snippet, it should become this

switch (...) {
case |:

    break;
}
i need ultisnips to do it because vim's auto indenting wont cooperate with ultisnips (if i manually type case: it unindents, but the snippet doesn't unindent)
Walter Simson
@waltsims
Quick questions guys: I want to use the google python style guide formatting for my comments but currently the todo snippet is this one: todo format is there a way to change the todo snippet format for python without writing my own custom snippet? I also opened honza/vim-snippets#1022 on the topic.
Christopher Valerio
@freexploit
does anyone know if somebody has written a markdown snippet file?
to not start from scratch ...
Miszo
@Miszo97
Do you maybe know how to resolve this?
This message was deleted
The problem is when I confirm completion suggestion it doesn't expand snippet
I use YCM + UltiSnips
WhimsicalAnotherKarakul-size_restricted.gif
Christopher Valerio
@freexploit
Hi I use deoplete + ultisnips
sometimes ultisnips work for some things
on neovim
but for vimwiki snippets and markdown I'm not able to make them work
let g:supertabdefaultcompletiontype = '<c-n>'

""" better key bindings for ultisnipsexpandtrigger
let g:ultisnipsexpandtrigger       = "<tab>"
let g:ultisnipsjumpforwardtrigger  = "<c-n>"
let g:ultisnipsjumpbackwardtrigger = "<c-p>"
let g:UltiSnipsSnippetDirectories  = [$HOME.'/UltiSnips', $HOME.'/.config/nvim/plugged/vim-snippets/UltiSnips']
James C Russell
@botanicus

Hey. Can I access VimL function from within Python interpolation code?

I want to use the Python complete() function, but the input for it is dynamic – it's a function ListTaskManagerTags defined in a (Neo)Vim plugin.

And I don't know how to access this VimL function from Python. Is there a way to do it? Thank you.

Ketan Kanishka
@disconsis
I have the same problem as @cabouffard
Just installed ultisnips and vim-snippets on neovim with YCM, and custom snippets aren't expanded.
let g:UltiSnipsExpandTrigger = "<c-c>"
let g:UltiSnipsJumpForwardTrigger = "<c-s-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-s-k>"
let g:UltiSnipsSnippetsDir = '/home/ketan/.vim/custom_snippets'
let g:UltiSnipsSnippetDirectories = ['UltiSnips', "bundle/vim-snippets/UltiSnips"]
set rtp+=/home/ketan/.vim/custom_snippets
Custom snippets don't show up in the autocomplete options either
Ketan Kanishka
@disconsis
:UltiSnipsEdit! shows the custom snippet directory
Tried the same config with vim, and that doesn't recognize the custom snippets either
Ketan Kanishka
@disconsis
Ah okay nevermind. Didn't read the docs well enough
For anyone who comes across the same problem, I solved it with this ->
set rtp+=~/.vim     " if not already there
let g:UltiSnipsSnippetsDir = 'custom_snippets'
let g:UltiSnipsSnippetDirectories = ['UltiSnips',"custom_snippets"]
PassionXV
@XvPassion_twitter
Hello Everyone

demo
I hope I'm not asking for a lot but I want to achieve the same look or at least the same completion smoothness (fast and smooth).
Completion (definition and how to use) + snippets
I only care about Javascript, nodejs, HTML, CSS, JSON
You can share a config example or anything can be helpful

Thank you!

Simon Leischnig
@simlei

Hello! Before diving into a full-blown fork-and-customization of ultisnips, I would like to ask:
Does any one else experience that snippet expansion and macros don't work together?

I am debuggin this for a few days right now, and I tried replacing macro registers so that they contain Ultisnips#[...] calls in place of the tab trigger, to no avail.
My issue is, that jumping between placeholders is not played back correctly when replaing a recorded macro. Can anyone confirm this?

I find this feature much needed and I imagine it to be very powerful in my workflow, since expanding US snippets is already part of it nearly every minute. Every time I could use a macro, I have to consider: "would I expand a snippet here?" before going at it (and if the anwer is 'no', I will have to reconsider :( ).
Daniel Guldberg Aaes
@notaduck

Hi guys.
I'm trying to create a snippet there should take the string "x // y" and convert it into "\frac{x}{y}".
However if there isn't anyting on the line it will return "None\frac{x}{y}".

I tried to solve it this way:

global !p
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C',
'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS',
'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]

texIgnoreMathZones = ['texMathText']

texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")

ignore = texIgnoreMathZoneIds[0]

def math():
    synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
    try:
        first = next(
            i for i in reversed(synstackids)
            if i in texIgnoreMathZoneIds or i in texMathZoneIds
        )
        return first != ignore
    except StopIteration:
        return False

def isNone(str):
    if (str == "None"):
        return ""
    else: return str
endglobal




######################


context "math()"
snippet '(.\s\s)?(\w+?|\d+?)\s//\s(\w+?|\d+?)\s(.)' "auto frag" wrA
`!p snip.rv = isNone(match.group(1))`\frac{`!p snip.rv = match.group(2)`}{`!p snip.rv = match.group(3)`} `!p snip.rv = match.group(4)`
endsnippet

However I still get the none part

@XvPassion_twitter try to take a loot here: https://github.com/honza/vim-snippets
ettom
@ettom
Hi, I'm trying to mirror a variable and insert a number immediately after. e.g $22 - I'd like it to expand as $2 with the number 2 inserted after but obviously it expands to $22. How could I do this?
!p snip.rv = t[2] did the trick
David Stadelmann
@dstadelm
Hi
I'm wondering if it would somehow be possible to use yanked text in a python interpolation. Much like the VISUAL but instead of expanding the snippet at the location of the selected text I would like to preserve the selected text, move to some other location and use the previously selected text using python interpolation.
David Stadelmann
@dstadelm
The use case is VHDL, where I want to create an instance from an entity (similar to defining a instance of a class)
Colin Kennedy
@ColinKennedy
Hi, quick question, is there a way to detect if the user is pressing backspace (or doing some kind of erase) and, if so, prevent a snippet from expanding?
Basically I have a single-line snippet that uses space as trigger. But the expanded text itself has spaces in it. So as soon as I erase the snippet, it triggers and expands again