New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate word boundaries with Vim, not r'\b' #119

Merged
merged 1 commit into from Dec 24, 2013

Conversation

Projects
None yet
2 participants
@guns
Copy link
Contributor

guns commented Dec 23, 2013

Hello,

UltiSnips currently has a hard-coded notion of a word boundary (python's
r'\b'), which makes using snippets from languages like Scheme and
Clojure a bit problematic.

e.g.

snippet map "map" w
(map ${0:pred} ${1:coll})
endsnippet

- is a word character in Lisps, so the following should not trigger
the snippet:

(hash-map^I)

If we use vim's regex engine to do the word matching, we can have
dynamic word character classes per FileType. This is what this patch
implements. I ran the test suite and all tests pass with Vim 7.4.131.

Please let me know if you'd like me to make any amendments.

Cheers!

From the patch header:

Certain non ALGOL-derived languages (notably LISP derivatives) do not
share the alphanumeric + underscore definition of a word character.

Fortunately, each language FileType has its own definition of a word
character, which Vim's regex engine uses when matching against the
boundary classes \< and \>.

We change the word matching routine of 'w' snippets to use Vim's regex
engine instead of a static pattern.

Evaluate word boundaries with Vim, not r'\b'
Certain non ALGOL-derived languages (notably LISP derivatives) do not
share the alphanumeric + underscore definition of a word character.

Fortunately, each language FileType has its own definition of a word
character, which Vim's regex engine uses when matching against the
boundary classes \< and \>.

We change the word matching routine of 'w' snippets to use Vim's regex
engine instead of a static pattern.

@SirVer SirVer merged commit 7cd4434 into SirVer:master Dec 24, 2013

@SirVer

This comment has been minimized.

Copy link
Owner

SirVer commented Dec 24, 2013

Thanks. merged as is. Been a while since you've contributed, glad that you still enjoy ultisnips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment