1" Vim filetype plugin 2" Language: J 3" Maintainer: David Bürgin <[email protected]> 4" URL: https://gitlab.com/glts/vim-j 5" Last Change: 2015-10-27 6 7if exists('b:did_ftplugin') 8 finish 9endif 10let b:did_ftplugin = 1 11 12let s:save_cpo = &cpo 13set cpo&vim 14 15setlocal iskeyword=48-57,A-Z,a-z,_ 16setlocal comments=:NB. 17setlocal commentstring=NB.\ %s 18setlocal formatoptions-=t 19setlocal matchpairs=(:) 20setlocal path-=/usr/include 21 22" Includes. To make the shorthand form "require 'web/cgi'" work, double the 23" last path component. Also strip off leading folder names like "~addons/". 24setlocal include=\\v^\\s*(load\|require)\\s*'\\zs\\f+\\ze' 25setlocal includeexpr=substitute(substitute(tr(v:fname,'\\','/'),'\\v^[^~][^/.]*(/[^/.]+)$','&\\1',''),'\\v^\\~[^/]+/','','') 26setlocal suffixesadd=.ijs 27 28let b:undo_ftplugin = 'setlocal suffixesadd< includeexpr< include< path< matchpairs< formatoptions< commentstring< comments< iskeyword<' 29 30" Section movement with ]] ][ [[ []. The start/end patterns below are amended 31" inside the function in order to avoid matching on the current cursor line. 32let s:sectionstart = '\%(\s*Note\|.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\)\>.*' 33let s:sectionend = '\s*)\s*' 34 35function! s:SearchSection(end, backwards, visualmode) abort 36 if a:visualmode !=# '' 37 normal! gv 38 endif 39 let l:flags = a:backwards ? 'bsW' : 'sW' 40 if a:end 41 call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags) 42 else 43 call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags) 44 endif 45endfunction 46 47noremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR> 48xnoremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR> 49sunmap <buffer> ]] 50noremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR> 51xnoremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR> 52sunmap <buffer> ][ 53noremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR> 54xnoremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR> 55sunmap <buffer> [[ 56noremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR> 57xnoremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR> 58sunmap <buffer> [] 59 60let b:undo_ftplugin .= ' | silent! execute "unmap <buffer> ]]"' 61 \ . ' | silent! execute "unmap <buffer> ]["' 62 \ . ' | silent! execute "unmap <buffer> [["' 63 \ . ' | silent! execute "unmap <buffer> []"' 64 65" Browse dialog filter on Windows (see ":help browsefilter") 66if has('gui_win32') && !exists('b:browsefilter') 67 let b:browsefilter = "J Script Files (*.ijs)\t*.ijs\n" 68 \ . "All Files (*.*)\t*.*\n" 69 let b:undo_ftplugin .= ' | unlet! b:browsefilter' 70endif 71 72" Enhanced "%" matching (see ":help matchit") 73if exists('loaded_matchit') && !exists('b:match_words') 74 let b:match_ignorecase = 0 75 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*$' 76 \ . ',\<\%(for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.:\<\%(case\|catch[dt]\=\|else\%(if\)\=\|fcase\)\.:\<end\.' 77 let b:undo_ftplugin .= ' | unlet! b:match_ignorecase b:match_words' 78endif 79 80let &cpo = s:save_cpo 81unlet s:save_cpo 82