Skip to content

Instantly share code, notes, and snippets.

@isovector
Created April 8, 2018 12:22
Show Gist options
  • Select an option

  • Save isovector/9db983fd0f66621c6828d8c86ecd7d1d to your computer and use it in GitHub Desktop.

Select an option

Save isovector/9db983fd0f66621c6828d8c86ecd7d1d to your computer and use it in GitHub Desktop.
haskell vim pragmas
Plug 'junegunn/vim-easy-align'
function! AddHsPragma()
" Add a new HS pragma, and sort the list so it's pretty
let pragma = input("LANGUAGE ")
normal! ms
if match(getline(1), "module") == 0
execute "normal! ggO\<ESC>"
endif
if pragma != ""
execute "normal! ggO{-# LANGUAGE " . pragma . " #-}\<ESC>"
endif
execute "normal! ggvip:sort\<CR>gv:EasyAlign -#\<CR>"
normal `s
endfunction
let g:easy_align_delimiters = {
\ '#': { 'pattern': '#', 'left_margin': 1, 'right_margin': 0, 'stick_to_left': 0 },
\ }
nnoremap <leader>l :call AddHsPragma()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment