|
@@ -20,19 +20,12 @@ function! neosnippet#mappings#jumpable() abort
|
20
|
20
|
\ .neosnippet#get_sync_placeholder_marker_pattern(), 'nw') > 0
|
21
|
21
|
endfunction
|
22
|
22
|
function! neosnippet#mappings#completed_expandable() abort
|
23
|
|
- if !s:enabled_completed_snippet()
|
|
23
|
+ if empty(get(v:, 'completed_item', {}))
|
24
|
24
|
return 0
|
25
|
25
|
endif
|
26
|
26
|
|
27
|
|
- let snippet = neosnippet#parser#_get_completed_snippet(
|
28
|
|
- \ v:completed_item, neosnippet#util#get_cur_text(),
|
29
|
|
- \ neosnippet#util#get_next_text())
|
30
|
|
- return snippet != ''
|
31
|
|
-endfunction
|
32
|
|
-function! s:enabled_completed_snippet() abort
|
33
|
|
- return exists('v:completed_item')
|
34
|
|
- \ && !empty(v:completed_item)
|
35
|
|
- \ && g:neosnippet#enable_completed_snippet
|
|
27
|
+ return !empty(s:get_completed_snippets(
|
|
28
|
+ \ neosnippet#util#get_cur_text(), col('.')))
|
36
|
29
|
endfunction
|
37
|
30
|
|
38
|
31
|
function! neosnippet#mappings#_clear_select_mode_mappings() abort
|
|
@@ -163,35 +156,36 @@ function! s:snippets_expand(cur_text, col) abort
|
163
|
156
|
|
164
|
157
|
return 1
|
165
|
158
|
endfunction
|
166
|
|
-function! s:expand_completed_snippets(cur_text, col) abort
|
167
|
|
- if !s:enabled_completed_snippet()
|
168
|
|
- return 0
|
|
159
|
+function! s:get_completed_snippets(cur_text, col) abort
|
|
160
|
+ if empty(get(v:, 'completed_item', {}))
|
|
161
|
+ return []
|
169
|
162
|
endif
|
170
|
163
|
|
171
|
164
|
let cur_text = a:cur_text
|
172
|
165
|
|
173
|
|
- if !empty(get(g:, 'deoplete#_context', []))
|
174
|
|
- \ && has_key(v:completed_item, 'word')
|
175
|
|
- let completed_candidates = filter(copy(g:deoplete#_context),
|
176
|
|
- \ "has_key(v:val, 'snippet') && has_key(v:val, 'snippet_trigger')
|
177
|
|
- \ && v:val.word ==# v:completed_item.word")
|
178
|
|
- if !empty(completed_candidates)
|
179
|
|
- let v:completed_item.snippet = completed_candidates[0].snippet
|
180
|
|
- let v:completed_item.snippet_trigger =
|
181
|
|
- \ completed_candidates[0].snippet_trigger
|
|
166
|
+ if !empty(get(v:completed_item, 'user_data', '{}'))
|
|
167
|
+ let user_data = json_decode(v:completed_item.user_data)
|
|
168
|
+ if has_key(user_data, 'snippet')
|
|
169
|
+ let snippet = user_data.snippet
|
|
170
|
+ if has_key(user_data, 'snippet_trigger')
|
|
171
|
+ let cur_text = cur_text[: -1-len(user_data.snippet_trigger)]
|
|
172
|
+ endif
|
|
173
|
+ return [cur_text, snippet]
|
182
|
174
|
endif
|
183
|
175
|
endif
|
184
|
176
|
|
185
|
|
- let snippet = neosnippet#parser#_get_completed_snippet(
|
186
|
|
- \ v:completed_item, cur_text, neosnippet#util#get_next_text())
|
187
|
|
- if snippet == ''
|
188
|
|
- return 0
|
189
|
|
- endif
|
190
|
|
-
|
191
|
|
- if has_key(v:completed_item, 'snippet_trigger')
|
192
|
|
- let cur_text = cur_text[: -1-len(v:completed_item.snippet_trigger)]
|
|
177
|
+ if g:neosnippet#enable_completed_snippet
|
|
178
|
+ let snippet = neosnippet#parser#_get_completed_snippet(
|
|
179
|
+ \ v:completed_item, cur_text, neosnippet#util#get_next_text())
|
|
180
|
+ if snippet != ''
|
|
181
|
+ return [cur_text, snippet]
|
|
182
|
+ endif
|
193
|
183
|
endif
|
194
|
184
|
|
|
185
|
+ return []
|
|
186
|
+endfunction
|
|
187
|
+function! s:expand_completed_snippets(cur_text, col) abort
|
|
188
|
+ let [cur_text, snippet] = s:get_completed_snippets(a:cur_text, a:col)
|
195
|
189
|
call neosnippet#view#_insert(snippet, {}, cur_text, a:col)
|
196
|
190
|
return 1
|
197
|
191
|
endfunction
|