~gpanders/dotfiles

ref: 2da1dde5ea566f82ebe6532bc6d3b8670fd77ce8 dotfiles/vim/.vim/autoload/snippets.vim -rw-r--r-- 671 bytes
2da1dde5Greg Anders Note 'open' subcommand opens editor in NOTES_DIR when no argument given 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function! snippets#expand() abort
    let lnum = line('.')
    let col = col('.')
    let line = getline('.')
    let curline = line[0:col-1]
    if curline =~# '^\s*$'
        return "\<Tab>"
    endif

    let token = split(curline[0:col-1])[-1]
    let ext = expand('%:e')
    if filereadable(g:snippets_dir . '/' . token . '.' . ext)
        let file = g:snippets_dir . '/' . token . '.' . ext
    elseif filereadable(g:snippets_dir . '/' . token . '.' . &filetype)
        let file = g:snippets_dir . '/' . token . '.' . &filetype
    else
        return "\<Tab>"
    endif

    delete _
    execute lnum-1 . 'read ' . file
    normal! =']
    return ''
endfunction