summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2016-05-02 10:42:37 +0200
committerAdam Stankiewicz <sheerun@sher.pl>2016-05-02 10:42:37 +0200
commit5dd1a7e83966c92d220073185f1738dfe441f59e (patch)
tree9c4bee389a51a9bb111dcc894c9db0f6d1809d81 /ftplugin
parentbc098370c1bb81840734f5764f431dee270e75ce (diff)
downloadvim-polyglot-5dd1a7e83966c92d220073185f1738dfe441f59e.tar.gz
vim-polyglot-5dd1a7e83966c92d220073185f1738dfe441f59e.zip
Update
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/ansible_hosts.vim13
-rw-r--r--ftplugin/cabal.vim60
-rw-r--r--ftplugin/elixir.vim39
-rw-r--r--ftplugin/git.vim2
-rw-r--r--ftplugin/gitcommit.vim8
-rw-r--r--ftplugin/haskell.vim19
-rw-r--r--ftplugin/markdown.vim2
-rw-r--r--ftplugin/pug.vim (renamed from ftplugin/jade.vim)6
-rw-r--r--ftplugin/typescript.vim2
9 files changed, 72 insertions, 79 deletions
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(<bang>0,b:git_dir,<f-args>)
+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(<line1>, <line2>)
+command! -buffer -range HaskellFormatImport call haskell#formatImport(<line1>, <line2>)
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=<!--%s-->
setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:
diff --git a/ftplugin/jade.vim b/ftplugin/pug.vim
index 1cf5015f..c2b622f7 100644
--- a/ftplugin/jade.vim
+++ b/ftplugin/pug.vim
@@ -1,7 +1,7 @@
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jade') == -1
" Vim filetype plugin
-" Language: Jade
+" Language: Pug
" Maintainer: Joshua Borton
" Credits: Tim Pope
@@ -39,7 +39,7 @@ 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
+ let b:browsefilter="Pug Files (*.pug)\t*.pug\n" . s:browsefilter
endif
" Load the combined list of match_words for matchit.vim
@@ -49,7 +49,7 @@ endif
setlocal comments=://-,:// commentstring=//\ %s
-setlocal suffixesadd+=.jade
+setlocal suffixesadd+=.pug
let b:undo_ftplugin = "setl cms< com< "
\ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
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 <CR> 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