~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to runtime/ftplugin/j.vim

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-02-20 22:41:32 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: package-import@ubuntu.com-20160220224132-e24n8lh3yo5ylt23
Tags: upstream-0.1.2
Import upstream version 0.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
" Language:     J
3
3
" Maintainer:   David Bürgin <676c7473@gmail.com>
4
4
" URL:          https://github.com/glts/vim-j
5
 
" Last Change:  2014-04-05
 
5
" Last Change:  2015-03-27
6
6
 
7
7
if exists('b:did_ftplugin')
8
8
  finish
16
16
setlocal comments=:NB.
17
17
setlocal commentstring=NB.\ %s
18
18
setlocal formatoptions-=t
19
 
setlocal shiftwidth=2 softtabstop=2 expandtab
20
19
setlocal matchpairs=(:)
21
20
 
22
 
let b:undo_ftplugin = 'setlocal matchpairs< expandtab< softtabstop< shiftwidth< formatoptions< commentstring< comments< iskeyword<'
 
21
let b:undo_ftplugin = 'setlocal matchpairs< formatoptions< commentstring< comments< iskeyword<'
23
22
 
24
23
" Section movement with ]] ][ [[ []. The start/end patterns below are amended
25
24
" inside the function in order to avoid matching on the current cursor line.
26
 
let s:sectionstart = '.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>.*'
 
25
let s:sectionstart = '\%(\s*Note\|.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\)\>.*'
27
26
let s:sectionend = '\s*)\s*'
28
27
 
29
28
function! s:SearchSection(end, backwards, visualmode) abort
30
29
  if a:visualmode !=# ''
31
30
    normal! gv
32
31
  endif
33
 
  let flags = a:backwards ? 'bsW' : 'sW'
 
32
  let l:flags = a:backwards ? 'bsW' : 'sW'
34
33
  if a:end
35
 
    call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), flags)
 
34
    call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags)
36
35
  else
37
 
    call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), flags)
 
36
    call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags)
38
37
  endif
39
38
endfunction
40
39
 
41
 
noremap <script> <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR>
42
 
xnoremap <script> <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR>
 
40
noremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR>
 
41
xnoremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR>
43
42
sunmap <buffer> ]]
44
 
noremap <script> <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR>
45
 
xnoremap <script> <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR>
 
43
noremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR>
 
44
xnoremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR>
46
45
sunmap <buffer> ][
47
 
noremap <script> <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR>
48
 
xnoremap <script> <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR>
 
46
noremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR>
 
47
xnoremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR>
49
48
sunmap <buffer> [[
50
 
noremap <script> <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR>
51
 
xnoremap <script> <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR>
 
49
noremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR>
 
50
xnoremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR>
52
51
sunmap <buffer> []
53
52
 
54
53
let b:undo_ftplugin .= ' | silent! execute "unmap <buffer> ]]"'
66
65
" Enhanced "%" matching (see ":help matchit")
67
66
if exists('loaded_matchit') && !exists('b:match_words')
68
67
  let b:match_ignorecase = 0
69
 
  let b:match_words = '^.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(\:\s*0\|def\s\+0\|define\)\>:^\s*\:\s*$:^\s*)\s*$'
 
68
  let b:match_words = '^\%(\s*Note\|.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(\:\s*0\|def\s\+0\|define\)\)\>:^\s*\:\s*$:^\s*)\s*$'
70
69
                  \ . ',\<\%(for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.:\<\%(case\|catch[dt]\=\|else\%(if\)\=\|fcase\)\.:\<end\.'
71
70
  let b:undo_ftplugin .= ' | unlet! b:match_ignorecase b:match_words'
72
71
endif