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