From 45273d44d4b1bd9a1be431c1a98f9046ed3a5c79 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 8 Jun 2014 13:18:33 +0200 Subject: Major update --- ftplugin/csv.vim | 52 +++++++++++++++++++++++++-------------------------- ftplugin/go.vim | 4 +++- ftplugin/html.vim | 7 +++++++ ftplugin/latextoc.vim | 5 ++++- ftplugin/mustache.vim | 16 ++++++++++++---- 5 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 ftplugin/html.vim (limited to 'ftplugin') diff --git a/ftplugin/csv.vim b/ftplugin/csv.vim index 0b3eee19..b6414d9f 100644 --- a/ftplugin/csv.vim +++ b/ftplugin/csv.vim @@ -483,7 +483,7 @@ fu! GetDelimiter(first, last) "{{{3 if !exists("b:csv_fixed_width_cols") let _cur = getpos('.') let _s = @/ - let Delim= {0: ';', 1: ',', 2: '|', 3: ' '} + let Delim= {0: ';', 1: ',', 2: '|', 3: ' ', 4: '\^'} let temp = {} " :silent :s does not work with lazyredraw let _lz = &lz @@ -525,12 +525,16 @@ fu! WColumn(...) "{{{3 let fields=(split(line[0:end],b:col.'\zs')) let ret=len(fields) if exists("a:1") && a:1 > 0 - " bang attribute + " bang attribute: Try to get the column name let head = split(getline(1),b:col.'\zs') " remove preceeding whitespace - let ret = substitute(head[ret-1], '^\s\+', '', '') - " remove delimiter - let ret = substitute(ret, b:delimiter. '$', '', '') + if len(head) < ret + call Warn("Header has no field ". ret) + else + let ret = substitute(head[ret-1], '^\s\+', '', '') + " remove delimiter + let ret = substitute(ret, b:delimiter. '$', '', '') + endif endif else let temp=getpos('.')[2] @@ -1002,7 +1006,8 @@ fu! MoveCol(forward, line, ...) "{{{3 elseif a:forward < 0 if colnr > 0 || cpos == spos call search('.\ze'.pat, 'bWe') - while getpos('.')[2] == cpos + let stime=localtime() + while getpos('.')[2] == cpos && Timeout(stime) " make sure loop terminates " cursor didn't move, move cursor one cell to the left norm! h if colnr > 0 @@ -1208,8 +1213,10 @@ fu! AddColumn(start, stop, ...) range "{{{3 if exists("a:1") if a:1 == '$' || a:1 >= max let pos = max - elseif a:1 <= 0 + elseif a:1 < 0 let pos = col + else + let pos = a:1 endif else let pos = col @@ -1217,7 +1224,7 @@ fu! AddColumn(start, stop, ...) range "{{{3 let cnt=(exists("a:2") && a:2 > 0 ? a:2 : 1) " translate 1 based columns into zero based list index - let pos -= 1 + "let pos -= 1 let col -= 1 if pos == 0 @@ -1772,7 +1779,7 @@ endfu fu! NewRecord(line1, line2, count) "{{{3 if a:count =~ "\D" - call WarningMsg("Invalid count specified") + call Warn("Invalid count specified") return endif @@ -1848,20 +1855,13 @@ fu! CSVMappings() "{{{3 call Map('noremap', 'E', ':call MoveCol(-1, line("."))') call Map('noremap', '', ':call MoveCol(-1, line("."))') call Map('noremap', 'H', ':call MoveCol(-1, line("."), 1)') - call Map('noremap', 'K', ':call MoveCol(0, - \ line(".")-v:count1)') - call Map('noremap', '', ':call MoveCol(0, - \ line(".")-v:count1)') - call Map('noremap', 'J', ':call MoveCol(0, - \ line(".")+v:count1)') - call Map('noremap', '', ':call MoveCol(0, - \ line(".")+v:count1)') - call Map('nnoremap', '', ':call PrepareFolding(1, - \ 1)') - call Map('nnoremap', '', ':call PrepareFolding(1, - \ 0)') - call Map('nnoremap', '', ':call PrepareFolding(0, - \ 1)') + call Map('noremap', 'K', ':call MoveCol(0, line(".")-v:count1)') + call Map('noremap', '', ':call MoveCol(0, line(".")-v:count1)') + call Map('noremap', 'J', ':call MoveCol(0, line(".")+v:count1)') + call Map('noremap', '', ':call MoveCol(0, line(".")+v:count1)') + call Map('nnoremap', '', ':call PrepareFolding(1, 1)') + call Map('nnoremap', '', ':call PrepareFolding(1, 0)') + call Map('nnoremap', '', ':call PrepareFolding(0, 1)') call Map('imap', '', 'ColumnMode()', 'expr') " Text object: Field call Map('vnoremap', 'if', ':call MoveOver(0)') @@ -1937,9 +1937,6 @@ fu! CommandDefinitions() "{{{3 \ '-nargs=1 -complete=custom,CompleteColumnNr') call LocalCmd('Transpose', ':call Transpose(, )', \ '-range=%') - call LocalCmd('Tabularize', ':call Tabularize(0,,)', - \ '-bang -range=%') - " Alias for :Tabularize, might be taken by Tabular plugin call LocalCmd('CSVTabularize', ':call Tabularize(0,,)', \ '-bang -range=%') call LocalCmd("AddColumn", @@ -2391,6 +2388,9 @@ fu! ColumnMode() "{{{3 return "\" endif endfu +fu! Timeout(start) "{{{3 + return localtime()-a:start < 2 +endfu " Global functions "{{{2 fu! csv#EvalColumn(nr, func, first, last) range "{{{3 diff --git a/ftplugin/go.vim b/ftplugin/go.vim index 8066733c..532fb172 100644 --- a/ftplugin/go.vim +++ b/ftplugin/go.vim @@ -9,9 +9,11 @@ if exists("b:did_ftplugin") endif let b:did_ftplugin = 1 +setlocal formatoptions-=t + setlocal comments=s1:/*,mb:*,ex:*/,:// setlocal commentstring=//\ %s -let b:undo_ftplugin = "setl com< cms<" +let b:undo_ftplugin = "setl fo< com< cms<" " vim:ts=4:sw=4:et diff --git a/ftplugin/html.vim b/ftplugin/html.vim new file mode 100644 index 00000000..4c0d9d07 --- /dev/null +++ b/ftplugin/html.vim @@ -0,0 +1,7 @@ +" Maintainer: othree +" URL: http://github.com/othree/html5.vim +" Last Change: 2014-05-02 +" License: MIT +" Changes: Add - to keyword + +setlocal iskeyword+=- diff --git a/ftplugin/latextoc.vim b/ftplugin/latextoc.vim index 01fd9bb0..d5d7e58c 100644 --- a/ftplugin/latextoc.vim +++ b/ftplugin/latextoc.vim @@ -97,6 +97,10 @@ endfunction " {{{2 TOCFindMatch function! s:TOCFindMatch(strsearch,duplicates,files) + if len(a:files) == 0 + echoerr "Could not find: " . a:strsearch + return + endif call s:TOCOpenBuf(a:files[0]) let dups = a:duplicates @@ -116,7 +120,6 @@ function! s:TOCFindMatch(strsearch,duplicates,files) endif call s:TOCFindMatch(a:strsearch,dups,a:files[1:]) - endfunction " {{{2 TOCFoldLevel diff --git a/ftplugin/mustache.vim b/ftplugin/mustache.vim index 38901654..592ed09d 100644 --- a/ftplugin/mustache.vim +++ b/ftplugin/mustache.vim @@ -59,10 +59,18 @@ xnoremap ]] :call sectionmovement('{{','' ,'v',v:cou " Operator pending mappings -onoremap ie :call wrap_inside() -onoremap ae :call wrap_around() -xnoremap ie :call wrap_inside() -xnoremap ae :call wrap_around() +" Operators are available by default. Set `let g:mustache_operators = 0` in +" your .vimrc to disable them. +if ! exists("g:mustache_operators") + let g:mustache_operators = 1 +endif + +if exists("g:mustache_operators") && g:mustache_operators + onoremap ie :call wrap_inside() + onoremap ae :call wrap_around() + xnoremap ie :call wrap_inside() + xnoremap ae :call wrap_around() +endif function! s:wrap_around() " If the cursor is at the end of the tag element, move back -- cgit v1.2.3