Skip to content

Commit 32671f1

Browse files
authored
Merge pull request #3 from ubaldot/dict_indices
indices take both list<string> and dict<string>
2 parents 0e8878e + 9d7ef0d commit 32671f1

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

autoload/mde_indices.vim

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ var indices_id = -1
77

88
def IndicesCallback(id: number, idx: number)
99
if idx > 0
10-
var selection = getbufline(winbufnr(id), idx)[0]
11-
exe $'edit {selection}'
10+
11+
if typename(g:markdown_extras_indices) == "list<string>"
12+
var selection = getbufline(winbufnr(id), idx)[0]
13+
exe $'edit {selection}'
14+
elseif typename(g:markdown_extras_indices) == "dict<string>"
15+
var selection = getbufline(winbufnr(id), idx)[0]
16+
exe $'edit {g:markdown_extras_indices[selection]}'
17+
endif
1218
indices_id = -1
1319
endif
1420
enddef
@@ -32,8 +38,13 @@ export def ShowIndices()
3238
wrap: 0,
3339
drag: 0,
3440
}
35-
indices_id = popup_create(g:markdown_extras_indices, opts)
36-
links.ShowPromptPopup(indices_id, g:markdown_extras_indices, " indices: ")
41+
if typename(g:markdown_extras_indices) == "list<string>"
42+
indices_id = popup_create(g:markdown_extras_indices, opts)
43+
links.ShowPromptPopup(indices_id, g:markdown_extras_indices, " indices: ")
44+
elseif typename(g:markdown_extras_indices) == "dict<string>"
45+
indices_id = popup_create(keys(g:markdown_extras_indices), opts)
46+
links.ShowPromptPopup(indices_id, keys(g:markdown_extras_indices), " indices: ")
47+
endif
3748
else
3849
utils.Echoerr("'g:markdown_extras_indices' not set" )
3950
endif

doc/markdown_extras.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,12 @@ filling it with he various keys.
221221

222222

223223
*g:markdown_extras_indices*
224-
g:markdown_extras_indices List containing the path of indices files.
225-
Default: empty
224+
g:markdown_extras_indices list<string> or dict<string>.
225+
If list<string>, contain the path of indices files.
226+
If dict<string>, the values are the path of
227+
the indices files whereas the keys are aliases. In
228+
the popup menu only the alias are displayed.
229+
Default: empty
226230

227231

228232
*markdown_extras_omnifunc*

0 commit comments

Comments
 (0)