Skip to content

Commit fd78bd6

Browse files
committed
fix previous commit, implementation should be fine now
1 parent e713269 commit fd78bd6

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

autoload/snipMate.vim

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,7 @@ fun! snipMate#RetabSnip() range
683683
endf
684684

685685
fun! snipMate#OpenSnippetFiles()
686-
let scopes = s:AddScopeAliases(snipMate#ScopesByFile())
687-
let dict = snipMate#GetSnippetFiles(0, scopes, '*')
686+
let dict = snipMate#GetSnippetFiles(0, snipMate#ScopesByFile(), '*')
688687
" sort by files wether they exist - put existing files first
689688
let exists = []
690689
let notExists = []
@@ -705,9 +704,8 @@ fun! snipMate#OpenSnippetFiles()
705704
endf
706705

707706
fun! snipMate#ScopesByFile()
708-
" default implementation to determine scopes based on cursor, filetype,
709-
" syntax setting. Usually &ft and &syntax are the same
710-
return tlib#list#Uniq(split(&ft, '\.') + [&syntax, '_'])
707+
" duplicates are removed in AddScopeAliases
708+
return funcref#Call(s:snipMate.get_scopes)
711709
endf
712710

713711
" vim:noet:sw=4:ts=4:ft=vim

doc/snipMate.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ See |snipMate-disambiguation| to learn about how name collisions are handled.
140140
Note that dotted
141141
'filetype' syntax is supported -- e.g., you can use >
142142
143-
:set ft=html.eruby =syntax=sql
143+
:set ft=html.eruby syntax=sql
144+
144145
to activate snippets for both HTML, eRuby and sql for the current file.
145-
See snipMate#ScopesByFile()
146+
See g:snipMate['get_scopes'] in plugin/snipMate.vim.
146147

147148
The syntax for snippets in *.snippets files is the following: >
148149

plugin/snipMate.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ let s:snipMate['get_snippets'] = get(s:snipMate, 'get_snippets', funcref#Functio
3737
" directories in &rtp/snippets/*
3838
let s:snipMate['snippet_dirs'] = get(s:snipMate, 'snippets_dirs', funcref#Function('return split(&runtimepath,",")'))
3939

40+
" _ is default scope added always
41+
"
42+
" &ft honors multiple filetypes and syntax such as in set ft=html.javascript syntax=FOO
43+
let s:snipMate['get_scopes'] = get(s:snipMate, 'get_scopes', funcref#Function('return split(&ft,"\\.")+[&syntax, "_"]'))
44+
4045
if !exists('snippets_dir')
4146
let snippets_dir = substitute(globpath(&rtp, 'snippets/'), "\n", ',', 'g')
4247
endif
@@ -153,7 +158,7 @@ fun! s:GetSnippet(word)
153158
" prefer longest word
154159
for word in lookups
155160
" echomsg string(lookups).' current: '.word
156-
let snippetD = get(funcref#Call(s:snipMate['get_snippets'], [split(&ft, '\.') + ['_'], word.'*']), word, {})
161+
let snippetD = get(funcref#Call(s:snipMate['get_snippets'], [snipMate#ScopesByFile(), word.'*']), word, {})
157162
if !empty(snippetD)
158163
let s = s:ChooseSnippet(snippetD)
159164
if type(s) == type([])
@@ -204,7 +209,7 @@ fun! ShowAvailableSnips()
204209
endif
205210
let matchlen = 0
206211
let matches = []
207-
let snips = funcref#Call(s:snipMate['get_snippets'], [split(&ft, '\.') + ['_'], word.'*'])
212+
let snips = funcref#Call(s:snipMate['get_snippets'], [snipMate#ScopesByFile(), word.'*'])
208213

209214

210215
for trigger in keys(snips)

0 commit comments

Comments
 (0)