summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2015-07-18 23:22:55 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2015-07-18 23:22:55 +0200
commitcf1e53bc39c96b9f5586a68efa118a13c615da13 (patch)
treeeb6c96a71098df7fc2a38df4606f32a3bfcc925e /ftplugin
parent92ab75408df8bff49bb29e113b3cc159d1ac3105 (diff)
downloadvim-polyglot-cf1e53bc39c96b9f5586a68efa118a13c615da13.tar.gz
vim-polyglot-cf1e53bc39c96b9f5586a68efa118a13c615da13.zip
Changed haskell provider to raichoo/haskell-vim, closes #63
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/cabal.vim69
-rw-r--r--ftplugin/haskell.vim25
2 files changed, 94 insertions, 0 deletions
diff --git a/ftplugin/cabal.vim b/ftplugin/cabal.vim
new file mode 100644
index 00000000..0942397c
--- /dev/null
+++ b/ftplugin/cabal.vim
@@ -0,0 +1,69 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
+
+if exists("g:loaded_haskellvim_cabal")
+ finish
+endif
+
+let g:loaded_haskellvim_cabal = 1
+
+function! s:makeSection(content)
+ return "\n" . join(a:content, "\n")
+endfunction
+
+function! s:exeTmpl(name, src)
+ let l:exetmpl = [ 'executable ' . a:name,
+ \ '-- ghc-options:',
+ \ 'main-is: ' . a:src,
+ \ '-- other-modules:',
+ \ '-- other-extensions:',
+ \ 'build-depends: base',
+ \ '-- hs-source-dirs:',
+ \ 'default-language: Haskell2010'
+ \ ]
+
+ return s:makeSection(l:exetmpl)
+endfunction
+
+function! s:libTmpl()
+ let l:libtmpl = [ 'library',
+ \ '-- ghc-options:',
+ \ '-- other-modules:',
+ \ '-- other-extensions:',
+ \ 'build-depends: base',
+ \ '-- hs-source-dirs:',
+ \ 'default-language: Haskell2010'
+ \ ]
+
+ return s:makeSection(l:libtmpl)
+endfunction
+
+function! s:flagTmpl(name)
+ let l:flagtmpl = [ 'flag ' . a:name,
+ \ 'description:',
+ \ 'default: False',
+ \ 'manual: True',
+ \ ]
+
+ return s:makeSection(l:flagtmpl)
+endfunction
+
+function! cabal#addExecutable()
+ let l:name = input("Enter executable name: ")
+ let l:src = input("Enter source file: ")
+ exe "normal Go" . s:exeTmpl(l:name, l:src)
+endfunction
+
+function! cabal#addLibrary()
+ exe "normal Go" . s:libTmpl()
+endfunction
+
+function! cabal#addFlag()
+ let l:name = input("Enter flag name: ")
+ exe "normal Go" . s:flagTmpl(l:name)
+endfunction
+
+command! -buffer CabalAddExecutable call cabal#addExecutable()
+command! -buffer CabalAddLibrary call cabal#addLibrary()
+command! -buffer CabalAddFlag call cabal#addFlag()
+
+endif
diff --git a/ftplugin/haskell.vim b/ftplugin/haskell.vim
new file mode 100644
index 00000000..3e9c43f8
--- /dev/null
+++ b/ftplugin/haskell.vim
@@ -0,0 +1,25 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'haskell') == -1
+
+if exists("g:loaded_haskellvim_haskell")
+ finish
+endif
+
+let g:loaded_haskellvim_haskell = 1
+
+function! haskell#makeModuleCommentBlock()
+ let l:commenttmpl = [ '{-|',
+ \ 'Module : ',
+ \ 'Description : ',
+ \ 'Copyright : ',
+ \ 'License : ',
+ \ 'Maintainer : ',
+ \ 'Stability : ',
+ \ 'Portability : ',
+ \ '-}']
+
+ exe "normal ggO" . join(l:commenttmpl, "\n")
+endfunction
+
+command! -buffer -nargs=0 HaskellAddModuleComment call haskell#makeModuleCommentBlock()
+
+endif