Skip to content

Commit 0242e65

Browse files
committed
✨ Add g:gitmoji_abbreviations setting and iabbrev generation
📝 Add documentation for g:gitmoji_abbreviations 📝 Update wording for documentation. 🔥 Remove doc/tags and add it to .gitignore
1 parent 150fcf8 commit 0242e65

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/doc/tags

after/ftplugin/gitcommit.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
setlocal completefunc=gitmoji#complete
22
setlocal omnifunc=gitmoji#complete
3+
4+
if g:gitmoji_abbreviations && g:gitmoji_insert_emoji
5+
for [name, gitmoji] in gitmoji#builtins()->items()
6+
execute 'iabbrev' gitmoji.code gitmoji.emoji
7+
endfor
8+
endif

autoload/gitmoji.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,15 @@ function s:load()
6262
return result
6363
endfunction
6464

65-
function gitmoji#complete(findstart, base)
65+
function gitmoji#builtins()
6666
if !exists('s:gitmoji')
6767
let s:gitmoji = s:load()
6868
endif
69+
return s:gitmoji
70+
endfunction
71+
72+
function gitmoji#complete(findstart, base)
73+
call gitmoji#builtins()
6974
" TODO: Permit configuration setting to allow 'matching' if the line is
7075
" empty
7176
if a:base->empty() && a:findstart == 1
@@ -78,3 +83,7 @@ function gitmoji#complete(findstart, base)
7883
endif
7984
return keys->map(function('s:builtin'))
8085
endfunction
86+
87+
" Registers aliases from a dictionary to be usable as gitmoji names.
88+
function gitmoji#register(aliases)
89+
endfunction

doc/gitmoji.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,25 @@ CONFIGURATION *gitmoji-configuration
3535

3636
*g:gitmoji_insert_emoji*
3737
g:gitmoji_insert_emoji~
38-
When set to `1` or `v:true`, the actual emoji will be inserted on
38+
When set to or |v:true|, the actual emoji will be inserted on
3939
completion instead of the gitmoji text code. e.g., if selecting
40-
`test-tube`, and `g:gitmoji_insert_emoji` is `v:true`, 🧪 will be
41-
inserted, instead of the gitmoji code `:test_tube:`.
42-
The default is `v:true`.
40+
"test-tube", and |g:gitmoji_insert_emoji| is |v:true|, 🧪 will be
41+
inserted, instead of the gitmoji code ":test_tube:".
42+
The default is |v:true|.
4343

4444
*g:gitmoji_complete_anywhere*
4545
g:gitmoji_complete_anywhere~
46-
When set to `1` or `v:true`, both the 'omnifunc' and 'completefunc' can
46+
When set to |v:true|, both the 'omnifunc' and 'completefunc' can
4747
activate anywhere.
48-
The default is `v:false`
48+
The default is |v:false|
49+
50+
*g:gitmoji_abbreviations*
51+
g:gitmoji_abbreviations~
52+
If set to |v:true| and |g:gitmoji_insert_emoji| is also set to
53+
|v:true|, |:iabbrev| commands are injected that will also replace
54+
gitmoji codes with their respective emoji. This works separately from
55+
the 'omnifunc' or 'completefunc' that gitmoji sets.
56+
The default is |v:true|
4957

5058
===============================================================================
5159
vim:ft=help:tw=78

doc/tags

Lines changed: 0 additions & 6 deletions
This file was deleted.

plugin/gitmoji.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ endif
88
if !exists('g:gitmoji_complete_anywhere')
99
let g:gitmoji_complete_anywhere = v:false
1010
endif
11+
12+
" TODO: This is not yet implemented
13+
if !exists('g:gitmoji_abbreviations')
14+
let g:gitmoji_abbreviations = v:true
15+
endif

0 commit comments

Comments
 (0)