summaryrefslogtreecommitdiff
path: root/runtime/ftplugin
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-04-06 14:09:13 +0200
committerBram Moolenaar <Bram@vim.org>2014-04-06 14:09:13 +0200
commit75b8156a445fb4788dc3d1946764af30b5c50ac4 (patch)
tree7430b073f6771ca2b5bb1d45b627eefe91e6773d /runtime/ftplugin
parent7e38ea2fb6a781213c85824dcf9ccb582fbc5c43 (diff)
downloadvim-git-75b8156a445fb4788dc3d1946764af30b5c50ac4.tar.gz
Updated runtime files.
Diffstat (limited to 'runtime/ftplugin')
-rw-r--r--runtime/ftplugin/j.vim60
1 files changed, 58 insertions, 2 deletions
diff --git a/runtime/ftplugin/j.vim b/runtime/ftplugin/j.vim
index 496acb1f9..bcd606ffa 100644
--- a/runtime/ftplugin/j.vim
+++ b/runtime/ftplugin/j.vim
@@ -2,14 +2,17 @@
" Language: J
" Maintainer: David Bürgin <676c7473@gmail.com>
" URL: https://github.com/glts/vim-j
-" Last Change: 2014-03-17
+" Last Change: 2014-04-05
if exists('b:did_ftplugin')
finish
endif
let b:did_ftplugin = 1
-setlocal iskeyword=48-57,65-90,_,97-122
+let s:save_cpo = &cpo
+set cpo&vim
+
+setlocal iskeyword=48-57,A-Z,_,a-z
setlocal comments=:NB.
setlocal commentstring=NB.\ %s
setlocal formatoptions-=t
@@ -17,3 +20,56 @@ setlocal shiftwidth=2 softtabstop=2 expandtab
setlocal matchpairs=(:)
let b:undo_ftplugin = 'setlocal matchpairs< expandtab< softtabstop< shiftwidth< formatoptions< commentstring< comments< iskeyword<'
+
+" Section movement with ]] ][ [[ []. The start/end patterns below are amended
+" inside the function in order to avoid matching on the current cursor line.
+let s:sectionstart = '.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\>.*'
+let s:sectionend = '\s*)\s*'
+
+function! s:SearchSection(end, backwards, visualmode) abort
+ if a:visualmode !=# ''
+ normal! gv
+ endif
+ let flags = a:backwards ? 'bsW' : 'sW'
+ if a:end
+ call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), flags)
+ else
+ call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), flags)
+ endif
+endfunction
+
+noremap <script> <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR>
+xnoremap <script> <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR>
+sunmap <buffer> ]]
+noremap <script> <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR>
+xnoremap <script> <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR>
+sunmap <buffer> ][
+noremap <script> <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR>
+xnoremap <script> <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR>
+sunmap <buffer> [[
+noremap <script> <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR>
+xnoremap <script> <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR>
+sunmap <buffer> []
+
+let b:undo_ftplugin .= ' | silent! execute "unmap <buffer> ]]"'
+ \ . ' | silent! execute "unmap <buffer> ]["'
+ \ . ' | silent! execute "unmap <buffer> [["'
+ \ . ' | silent! execute "unmap <buffer> []"'
+
+" Browse dialog filter on Windows (see ":help browsefilter")
+if has('gui_win32') && !exists('b:browsefilter')
+ let b:browsefilter = "J Script Files (*.ijs)\t*.ijs\n"
+ \ . "All Files (*.*)\t*.*\n"
+ let b:undo_ftplugin .= ' | unlet! b:browsefilter'
+endif
+
+" Enhanced "%" matching (see ":help matchit")
+if exists('loaded_matchit') && !exists('b:match_words')
+ let b:match_ignorecase = 0
+ let b:match_words = '^.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(\:\s*0\|def\s\+0\|define\)\>:^\s*\:\s*$:^\s*)\s*$'
+ \ . ',\<\%(for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.:\<\%(case\|catch[dt]\=\|else\%(if\)\=\|fcase\)\.:\<end\.'
+ let b:undo_ftplugin .= ' | unlet! b:match_ignorecase b:match_words'
+endif
+
+let &cpo = s:save_cpo
+unlet s:save_cpo