let b:quickrun_config = { \ 'command': 'gleam', \ 'cmdopt': '--module', \ 'exec': '%c run %o %s:p:t:r %a', \ } setlocal commentstring=//\ %s let s:undo_abbrev = [] function s:abbrev(original, converted) abort " call mi#utils#eatchar('\s') call mi#cmp#findstart() if mi#cmp#get_info().before_cursor =~# $'^\s*{a:original}$' return a:converted endif return a:original endfunction inoreabbrev le abbrev('le', 'let =') inoreabbrev la abbrev('la', 'let assert =') inoreabbrev fn abbrev('fn', 'fn () -> {}') inoreabbrev pfn abbrev('pfn', 'pub fn () -> {}' .. repeat('', 5)) inoreabbrev tfn abbrev('pfn', 'pub fn _test() {}' .. repeat('', 5)) inoreabbrev afn abbrev('afn', 'fn() {}' .. repeat('', 4)) inoreabbrev case abbrev('case', 'case {}' .. repeat('', 3)) inoreabbrev ty abbrev('ty', 'type {}' .. repeat('', 3)) inoreabbrev pty abbrev('pty', 'pub type {}' .. repeat('', 7)) inoreabbrev im abbrev('im', 'import gleam') let s:undo_abbrev += ['le', 'la', 'fn', 'pfn', 'tfn', 'afn', 'cs', 'ty', 'pty', 'im'] if !has('nvim') augroup user_ftplugin_gleam autocmd! autocmd ColorScheme * if &filetype == 'gleam' \ | syntax enable \ | endif augroup END endif if exists('b:undo_ftplugin') let b:undo_ftplugin ..= '|' else let b:undo_ftplugin = '' endif let b:undo_ftplugin ..= 'unlet! b:quickrun_config' let b:undo_ftplugin ..= '| setlocal commentstring<' let b:undo_ftplugin ..= '| iunmap ;' let b:undo_ftplugin ..= s:undo_abbrev->copy()->map('"| iunabbrev " .. v:val')->join('')