summaryrefslogtreecommitdiffstats
path: root/ftplugin
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2013-11-02 23:27:57 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2013-11-02 23:27:57 +0100
commit30c1920e4fa4e612238e1f435907c40ecfa47f33 (patch)
treef88ffb408895a5baf93fe81fdd12acba17f32d44 /ftplugin
parent57cfac7ae384466c3ff2543a9200319dc1d459a0 (diff)
downloadvim-polyglot-1.4.1.tar.gz
vim-polyglot-1.4.1.zip
Massive update :)v1.4.1
Diffstat (limited to 'ftplugin')
-rw-r--r--ftplugin/go/fmt.vim16
-rw-r--r--ftplugin/go/import.vim35
-rw-r--r--ftplugin/latex-box/complete.vim2
-rw-r--r--ftplugin/latex-box/motion.vim2
-rw-r--r--ftplugin/latextoc.vim61
-rw-r--r--ftplugin/perl.vim8
-rw-r--r--ftplugin/typescript.vim4
7 files changed, 94 insertions, 34 deletions
diff --git a/ftplugin/go/fmt.vim b/ftplugin/go/fmt.vim
index 30814fdf..5447d457 100644
--- a/ftplugin/go/fmt.vim
+++ b/ftplugin/go/fmt.vim
@@ -12,11 +12,25 @@
" It tries to preserve cursor position and avoids
" replacing the buffer with stderr output.
"
+" Options:
+"
+" g:go_fmt_commands [default=1]
+"
+" Flag to indicate whether to enable the commands listed above.
+"
if exists("b:did_ftplugin_go_fmt")
finish
endif
-command! -buffer Fmt call s:GoFormat()
+
+if !exists("g:go_fmt_commands")
+ let g:go_fmt_commands = 1
+endif
+
+
+if g:go_fmt_commands
+ command! -buffer Fmt call s:GoFormat()
+endif
function! s:GoFormat()
let view = winsaveview()
diff --git a/ftplugin/go/import.vim b/ftplugin/go/import.vim
index 1d969e46..91c8697a 100644
--- a/ftplugin/go/import.vim
+++ b/ftplugin/go/import.vim
@@ -24,23 +24,40 @@
" imported, an error will be displayed and the buffer will be
" untouched.
"
-" In addition to these commands, there are also two shortcuts mapped:
+" If you would like to add shortcuts, you can do so by doing the following:
"
-" \f - Runs :Import fmt
-" \F - Runs :Drop fmt
+" Import fmt
+" au Filetype go nnoremap <buffer> <LocalLeader>f :Import fmt<CR>
"
-" The backslash is the default maplocalleader, so it is possible that
+" Drop fmt
+" au Filetype go nnoremap <buffer> <LocalLeader>F :Drop fmt<CR>
+"
+" Import the word under your cursor
+" au Filetype go nnoremap <buffer> <LocalLeader>k
+" \ :exe 'Import ' . expand('<cword>')<CR>
+"
+" The backslash '\' is the default maplocalleader, so it is possible that
" your vim is set to use a different character (:help maplocalleader).
"
+" Options:
+"
+" g:go_import_commands [default=1]
+"
+" Flag to indicate whether to enable the commands listed above.
+"
if exists("b:did_ftplugin_go_import")
finish
endif
-command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', <f-args>)
-command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
-command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
-map <buffer> <LocalLeader>f :Import fmt<CR>
-map <buffer> <LocalLeader>F :Drop fmt<CR>
+if !exists("g:go_import_commands")
+ let g:go_import_commands = 1
+endif
+
+if g:go_import_commands
+ command! -buffer -nargs=? -complete=customlist,go#complete#Package Drop call s:SwitchImport(0, '', <f-args>)
+ command! -buffer -nargs=1 -complete=customlist,go#complete#Package Import call s:SwitchImport(1, '', <f-args>)
+ command! -buffer -nargs=* -complete=customlist,go#complete#Package ImportAs call s:SwitchImport(1, <f-args>)
+endif
function! s:SwitchImport(enabled, localname, path)
let view = winsaveview()
diff --git a/ftplugin/latex-box/complete.vim b/ftplugin/latex-box/complete.vim
index 2414be3c..af894777 100644
--- a/ftplugin/latex-box/complete.vim
+++ b/ftplugin/latex-box/complete.vim
@@ -457,7 +457,7 @@ function! s:GetLabelCache(file)
if !has_key(s:LabelCache , a:file) || s:LabelCache[a:file][0] != getftime(a:file)
" Open file in temporary split window for label extraction.
- silent execute '1sp +let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . a:file
+ silent execute '1sp +let\ labels=s:ExtractLabels()|let\ inputs=s:ExtractInputs()|quit! ' . fnameescape(a:file)
let s:LabelCache[a:file] = [ getftime(a:file), labels, inputs ]
endif
diff --git a/ftplugin/latex-box/motion.vim b/ftplugin/latex-box/motion.vim
index 72481753..04275aca 100644
--- a/ftplugin/latex-box/motion.vim
+++ b/ftplugin/latex-box/motion.vim
@@ -437,7 +437,7 @@ endfunction
function! s:FindClosestSection(toc, fileindices)
let file = expand('%:p')
if !has_key(a:fileindices, file)
- echoe 'Current file is not included in main tex file ' . LatexBox_GetMainTexFile() . '.'
+ return 0
endif
let imax = len(a:fileindices[file])
diff --git a/ftplugin/latextoc.vim b/ftplugin/latextoc.vim
index f753cea8..48f20e3b 100644
--- a/ftplugin/latextoc.vim
+++ b/ftplugin/latextoc.vim
@@ -80,24 +80,14 @@ function! s:TOCActivate(close)
execute b:calling_win . 'wincmd w'
- let bnr = bufnr(entry['file'])
- if bnr == -1
- execute 'badd ' . entry['file']
- let bnr = bufnr(entry['file'])
- endif
-
- execute 'buffer! ' . bnr
-
- " skip duplicates
- while duplicates > 0
- if search('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'ws')
- let duplicates -= 1
- endif
- endwhile
+ let files = [entry['file']]
+ for line in filter(readfile(entry['file']), 'v:val =~ ''\\input{''')
+ call add(files, matchstr(line, '{\zs.*\ze\(\.tex\)\?}') . '.tex')
+ endfor
- if search('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'ws')
- normal zv
- endif
+ " Find section in buffer (or inputted files)
+ call s:TOCFindMatch('\\' . entry['level'] . '\_\s*{' . titlestr . '}',
+ \ duplicates, files)
if a:close
if g:LatexBox_split_resize
@@ -109,6 +99,30 @@ function! s:TOCActivate(close)
endif
endfunction
+" {{{2 TOCFindMatch
+function! s:TOCFindMatch(strsearch,duplicates,files)
+
+ call s:TOCOpenBuf(a:files[0])
+ let dups = a:duplicates
+
+ " Skip duplicates
+ while dups > 0
+ if search(a:strsearch, 'w')
+ let dups -= 1
+ else
+ break
+ endif
+ endwhile
+
+ if search(a:strsearch, 'w')
+ normal! zv
+ return
+ endif
+
+ call s:TOCFindMatch(a:strsearch,dups,a:files[1:])
+
+endfunction
+
" {{{2 TOCFoldLevel
function! TOCFoldLevel(lnum)
let line = getline(a:lnum)
@@ -140,12 +154,25 @@ function! TOCFoldLevel(lnum)
" Return previous fold level
return "="
endfunction
+
" {{{2 TOCFoldText
function! TOCFoldText()
let parts = matchlist(getline(v:foldstart), '^\(.*\)\t\(.*\)$')
return printf('%-8s%-72s', parts[1], parts[2])
endfunction
+" {{{2 TOCOpenBuf
+function! s:TOCOpenBuf(file)
+
+ let bnr = bufnr(a:file)
+ if bnr == -1
+ execute 'badd ' . a:file
+ let bnr = bufnr(a:file)
+ endif
+ execute 'buffer! ' . bnr
+
+endfunction
+
" }}}1
" {{{1 Mappings
diff --git a/ftplugin/perl.vim b/ftplugin/perl.vim
index e31f8c0c..9e210428 100644
--- a/ftplugin/perl.vim
+++ b/ftplugin/perl.vim
@@ -33,14 +33,14 @@ endif
setlocal include=\\<\\(use\\\|require\\)\\>
setlocal includeexpr=substitute(substitute(substitute(v:fname,'::','/','g'),'->\*','',''),'$','.pm','')
setlocal define=[^A-Za-z_]
+setlocal iskeyword+=:
" The following line changes a global variable but is necessary to make
-" gf and similar commands work. The change to iskeyword was incorrect.
-" Thanks to Andrew Pimlott for pointing out the problem. If this causes a
-" problem for you, add an after/ftplugin/perl.vim file that contains
+" gf and similar commands work. Thanks to Andrew Pimlott for pointing
+" out the problem. If this causes a problem for you, add an
+" after/ftplugin/perl.vim file that contains
" set isfname-=:
set isfname+=:
-set iskeyword+=:
" Set this once, globally.
if !exists("perlpath")
diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim
index 3726194a..e4e39b60 100644
--- a/ftplugin/typescript.vim
+++ b/ftplugin/typescript.vim
@@ -1,8 +1,10 @@
compiler typescript
setlocal autoindent
-setlocal cindent
setlocal smartindent
setlocal indentexpr&
+setlocal cindent
+setlocal cino=j1J1
+
setlocal commentstring=//\ %s