From 5dd1a7e83966c92d220073185f1738dfe441f59e Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 2 May 2016 10:42:37 +0200 Subject: Update --- ftplugin/ansible_hosts.vim | 13 ++++++++++ ftplugin/cabal.vim | 60 --------------------------------------------- ftplugin/elixir.vim | 39 ++++++++++++++++++++++++++++- ftplugin/git.vim | 2 ++ ftplugin/gitcommit.vim | 8 ++++-- ftplugin/haskell.vim | 19 ++++++--------- ftplugin/jade.vim | 61 ---------------------------------------------- ftplugin/markdown.vim | 2 +- ftplugin/pug.vim | 61 ++++++++++++++++++++++++++++++++++++++++++++++ ftplugin/typescript.vim | 2 ++ 10 files changed, 130 insertions(+), 137 deletions(-) create mode 100644 ftplugin/ansible_hosts.vim delete mode 100644 ftplugin/jade.vim create mode 100644 ftplugin/pug.vim (limited to 'ftplugin') diff --git a/ftplugin/ansible_hosts.vim b/ftplugin/ansible_hosts.vim new file mode 100644 index 00000000..7dbd8ec4 --- /dev/null +++ b/ftplugin/ansible_hosts.vim @@ -0,0 +1,13 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'ansible') == -1 + +if exists("b:did_ftplugin") + finish +else + let b:did_ftplugin = 1 +endif + +setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions-=c + +let b:undo_ftplugin = "setl comments< commentstring< formatoptions<" + +endif diff --git a/ftplugin/cabal.vim b/ftplugin/cabal.vim index 0942397c..5c041bd3 100644 --- a/ftplugin/cabal.vim +++ b/ftplugin/cabal.vim @@ -6,64 +6,4 @@ 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/elixir.vim b/ftplugin/elixir.vim index 04388efd..225e2772 100644 --- a/ftplugin/elixir.vim +++ b/ftplugin/elixir.vim @@ -5,7 +5,6 @@ if (exists("b:did_ftplugin")) endif let b:did_ftplugin = 1 - " Matchit support if exists("loaded_matchit") && !exists("b:match_words") let b:match_ignorecase = 0 @@ -21,4 +20,42 @@ endif setlocal comments=:# setlocal commentstring=#\ %s +function! GetElixirFilename(word) + let word = a:word + + " get first thing that starts uppercase, until the first space or end of line + let word = substitute(word,'^\s*\(\u[^ ]\+\).*$','\1','g') + + " remove any trailing characters that don't look like a nested module + let word = substitute(word,'\.\U.*$','','g') + + " replace module dots with slash + let word = substitute(word,'\.','/','g') + + " remove any special chars + let word = substitute(word,'[^A-z0-9-_/]','','g') + + " convert to snake_case + let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') + let word = substitute(word,'\(\u\+\)\(\u\l\)','\1_\2','g') + let word = substitute(word,'\(\l\|\d\)\(\u\)','\1_\2','g') + let word = substitute(word,'-','_','g') + let word = tolower(word) + + return word +endfunction + +let &l:path = + \ join([ + \ getcwd().'/lib', + \ getcwd().'/src', + \ getcwd().'/deps/**/lib', + \ getcwd().'/deps/**/src', + \ &g:path + \ ], ',') +setlocal includeexpr=GetElixirFilename(v:fname) +setlocal suffixesadd=.ex,.exs,.eex,.erl,.yrl,.hrl + +setlocal formatoptions-=t formatoptions+=croqlj + endif diff --git a/ftplugin/git.vim b/ftplugin/git.vim index 444d7562..38b9493b 100644 --- a/ftplugin/git.vim +++ b/ftplugin/git.vim @@ -14,6 +14,8 @@ let b:did_ftplugin = 1 if !exists('b:git_dir') if expand('%:p') =~# '[\/]\.git[\/]modules[\/]' " Stay out of the way + elseif expand('%:p') =~# '[\/]\.git[\/]worktrees' + let b:git_dir = matchstr(expand('%:p'),'.*\.git[\/]worktrees[\/][^\/]\+\>') elseif expand('%:p') =~# '\.git\>' let b:git_dir = matchstr(expand('%:p'),'.*\.git\>') elseif $GIT_DIR != '' diff --git a/ftplugin/gitcommit.vim b/ftplugin/gitcommit.vim index 82602a12..dc6a581a 100644 --- a/ftplugin/gitcommit.vim +++ b/ftplugin/gitcommit.vim @@ -13,8 +13,10 @@ endif runtime! ftplugin/git.vim let b:did_ftplugin = 1 -setlocal nomodeline tabstop=8 formatoptions-=croq formatoptions+=tl textwidth=72 -let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw<' +setlocal comments=:# commentstring=#\ %s +setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 +setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q +let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms<' if exists("g:no_gitcommit_commands") || v:version < 700 finish @@ -26,6 +28,8 @@ endif command! -bang -bar -buffer -complete=custom,s:diffcomplete -nargs=* DiffGitCached :call s:gitdiffcached(0,b:git_dir,) +let b:undo_ftplugin = b:undo_ftplugin . "|delc DiffGitCached" + function! s:diffcomplete(A,L,P) let args = "" if a:P <= match(a:L." -- "," -- ")+3 diff --git a/ftplugin/haskell.vim b/ftplugin/haskell.vim index 3e9c43f8..b1028620 100644 --- a/ftplugin/haskell.vim +++ b/ftplugin/haskell.vim @@ -6,20 +6,15 @@ endif let g:loaded_haskellvim_haskell = 1 -function! haskell#makeModuleCommentBlock() - let l:commenttmpl = [ '{-|', - \ 'Module : ', - \ 'Description : ', - \ 'Copyright : ', - \ 'License : ', - \ 'Maintainer : ', - \ 'Stability : ', - \ 'Portability : ', - \ '-}'] +function! haskell#sortImports(line1, line2) + exe a:line1 . "," . a:line2 . "sort /import\\s\\+\\(qualified\\s\\+\\)\\?/" +endfunction - exe "normal ggO" . join(l:commenttmpl, "\n") +function! haskell#formatImport(line1, line2) + exec a:line1 . ",". a:line2 . "s/import\\s\\+\\([A-Z].*\\)/import \\1" endfunction -command! -buffer -nargs=0 HaskellAddModuleComment call haskell#makeModuleCommentBlock() +command! -buffer -range HaskellSortImports call haskell#sortImports(, ) +command! -buffer -range HaskellFormatImport call haskell#formatImport(, ) endif diff --git a/ftplugin/jade.vim b/ftplugin/jade.vim deleted file mode 100644 index 1cf5015f..00000000 --- a/ftplugin/jade.vim +++ /dev/null @@ -1,61 +0,0 @@ -if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1 - -" Vim filetype plugin -" Language: Jade -" Maintainer: Joshua Borton -" Credits: Tim Pope - -" Only do this when not done yet for this buffer -if exists("b:did_ftplugin") - finish -endif - -let s:save_cpo = &cpo -set cpo-=C - -setlocal iskeyword+=- - -" Define some defaults in case the included ftplugins don't set them. -let s:undo_ftplugin = "" -let s:browsefilter = "All Files (*.*)\t*.*\n" -let s:match_words = "" - -runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim -unlet! b:did_ftplugin - -" Override our defaults if these were set by an included ftplugin. -if exists("b:undo_ftplugin") - let s:undo_ftplugin = b:undo_ftplugin - unlet b:undo_ftplugin -endif -if exists("b:browsefilter") - let s:browsefilter = b:browsefilter - unlet b:browsefilter -endif -if exists("b:match_words") - let s:match_words = b:match_words - unlet b:match_words -endif - -" Change the browse dialog on Win32 to show mainly Haml-related files -if has("gui_win32") - let b:browsefilter="Jade Files (*.jade)\t*.jade\n" . s:browsefilter -endif - -" Load the combined list of match_words for matchit.vim -if exists("loaded_matchit") - let b:match_words = s:match_words -endif - -setlocal comments=://-,:// commentstring=//\ %s - -setlocal suffixesadd+=.jade - -let b:undo_ftplugin = "setl cms< com< " - \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin - -let &cpo = s:save_cpo - -" vim:set sw=2: - -endif diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index 4fe53d0b..2f0f3974 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -11,7 +11,7 @@ endif runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim -setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s +setlocal comments=fb:*,fb:-,fb:+,n:> commentstring= setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]: diff --git a/ftplugin/pug.vim b/ftplugin/pug.vim new file mode 100644 index 00000000..c2b622f7 --- /dev/null +++ b/ftplugin/pug.vim @@ -0,0 +1,61 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1 + +" Vim filetype plugin +" Language: Pug +" Maintainer: Joshua Borton +" Credits: Tim Pope + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +let s:save_cpo = &cpo +set cpo-=C + +setlocal iskeyword+=- + +" Define some defaults in case the included ftplugins don't set them. +let s:undo_ftplugin = "" +let s:browsefilter = "All Files (*.*)\t*.*\n" +let s:match_words = "" + +runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim +unlet! b:did_ftplugin + +" Override our defaults if these were set by an included ftplugin. +if exists("b:undo_ftplugin") + let s:undo_ftplugin = b:undo_ftplugin + unlet b:undo_ftplugin +endif +if exists("b:browsefilter") + let s:browsefilter = b:browsefilter + unlet b:browsefilter +endif +if exists("b:match_words") + let s:match_words = b:match_words + unlet b:match_words +endif + +" Change the browse dialog on Win32 to show mainly Haml-related files +if has("gui_win32") + let b:browsefilter="Pug Files (*.pug)\t*.pug\n" . s:browsefilter +endif + +" Load the combined list of match_words for matchit.vim +if exists("loaded_matchit") + let b:match_words = s:match_words +endif + +setlocal comments=://-,:// commentstring=//\ %s + +setlocal suffixesadd+=.pug + +let b:undo_ftplugin = "setl cms< com< " + \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin + +let &cpo = s:save_cpo + +" vim:set sw=2: + +endif diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim index 9508fba4..2a9af1e2 100644 --- a/ftplugin/typescript.vim +++ b/ftplugin/typescript.vim @@ -15,6 +15,8 @@ setlocal commentstring=//\ %s " " and insert the comment leader when hitting or using "o". setlocal formatoptions-=t formatoptions+=croql +setlocal suffixesadd+=.ts + let b:undo_ftplugin = "setl fo< ofu< com< cms<" let &cpo = s:cpo_save -- cgit v1.2.3