Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix for python dots #84

Closed
wants to merge 1 commit into from

2 participants

@davidhalter

I fixed something concerning dots in python.

Since this was a deeper issue with code and I wasn't always shure what I exactly did :-) please read it.
In the end it's just a new option, which produces by default the same behaviour as your script.

let g:snipMateAllowMatchingDot = 0
Dots can still be expanded, but only if they are alone. Not in cases like "self."
In such cases you rather want autocompletion (with supertab), than another self, which produces "selfself."

#65

@MarcWeber
Collaborator

I commented the issue 65. What do you guys expect? What's your use case?

@MarcWeber
Collaborator

I don't think at the moment that a global option is going to solve anything - because completion behavior may differ per filetype. So tell me which behavior you expect so that we can find the perfect solution

@MarcWeber
Collaborator

I expect ".|something" expand to "self.something" where | is the cursor position. Did I get it?
This case works without the patch here. Do you have custom snippets?

@MarcWeber MarcWeber closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 10, 2012
  1. @davidhalter

    added new option: g:snipMateAllowMatchingDot which changes the behavi…

    davidhalter authored
    …our of the script for dots in python. (issue #65 @garbas)
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 6 deletions.
  1. +4 −0 after/plugin/snipMate.vim
  2. +12 −6 autoload/snipMate.vim
View
4 after/plugin/snipMate.vim
@@ -18,6 +18,10 @@ if !exists('g:snips_trigger_key_backwards')
let g:snips_trigger_key_backwards = '<s-' . substitute(g:snips_trigger_key, '[<>]', '', 'g')
endif
+if !exists('g:snipMateAllowMatchingDot')
+ let g:snipMateAllowMatchingDot = 1
+endif
+
exec 'ino <silent> ' . g:snips_trigger_key . ' <c-g>u<c-r>=snipMate#TriggerSnippet()<cr>'
exec 'snor <silent> ' . g:snips_trigger_key . ' <esc>i<right><c-r>=snipMate#TriggerSnippet()<cr>'
exec 'ino <silent> ' . g:snips_trigger_key_backwards . '> <c-r>=snipMate#BackwardsSnippet()<cr>'
View
18 autoload/snipMate.vim
@@ -719,9 +719,13 @@ endf
" used by both: completion and insert snippet
fun! snipMate#GetSnippetsForWordBelowCursor(word, suffix, break_on_first_match)
" Setup lookups: '1.2.3' becomes [1.2.3] + [3, 2.3]
- let parts = split(a:word, '\W\zs')
- if len(parts) > 2
- let parts = parts[-2:] " max 2 additional items, this might become a setting
+ if g:snipMateAllowMatchingDot
+ let parts = split(a:word, '\W\zs')
+ if len(parts) > 2
+ let parts = parts[-2:] " max 2 additional items, this might become a setting
+ endif
+ else
+ let parts = [a:word]
endif
let lookups = [a:word.a:suffix]
let lookup = ''
@@ -732,9 +736,11 @@ fun! snipMate#GetSnippetsForWordBelowCursor(word, suffix, break_on_first_match)
endif
endfor
- " allow matching '.'
- if a:word =~ '\.$'
- call add(lookups, '.'.a:suffix)
+ if g:snipMateAllowMatchingDot
+ " allow matching '.'
+ if a:word =~ '\.$'
+ call add(lookups, '.'.a:suffix)
+ endif
endif
call filter(lookups, 'v:val != ""')
Something went wrong with that request. Please try again.