vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

j.vim (3664B)


      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 
      8 if exists('b:did_ftplugin')
      9   finish
     10 endif
     11 let b:did_ftplugin = 1
     12 
     13 let s:save_cpo = &cpo
     14 set cpo&vim
     15 
     16 setlocal iskeyword=48-57,A-Z,a-z,_
     17 setlocal comments=:NB.
     18 setlocal commentstring=NB.\ %s
     19 setlocal formatoptions-=t
     20 setlocal matchpairs=(:)
     21 setlocal 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/".
     25 setlocal include=\\v^\\s*(load\|require)\\s*'\\zs\\f+\\ze'
     26 setlocal includeexpr=substitute(substitute(tr(v:fname,'\\','/'),'\\v^[^~][^/.]*(/[^/.]+)$','&\\1',''),'\\v^\\~[^/]+/','','')
     27 setlocal suffixesadd=.ijs
     28 
     29 let 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.
     33 if !exists('no_plugin_maps') && !exists('no_j_maps')
     34   let s:sectionstart = '\%(\s*Note\|.\{-}\<\%([0-4]\|13\|noun\|adverb\|conjunction\|verb\|monad\|dyad\)\s\+\%(:\s*0\|def\s\+0\|define\)\)\>.*'
     35   let s:sectionend = '\s*)\s*'
     36 
     37   function! s:SearchSection(end, backwards, visualmode) abort
     38     if a:visualmode !=# ''
     39       normal! gv
     40     endif
     41     let l:flags = a:backwards ? 'bsW' : 'sW'
     42     if a:end
     43       call search('^' . s:sectionend . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags)
     44     else
     45       call search('^' . s:sectionstart . (a:backwards ? '\n\_.\{-}\%#' : '$'), l:flags)
     46     endif
     47   endfunction
     48 
     49   noremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, '')<CR>
     50   xnoremap <buffer> <silent> ]] :<C-U>call <SID>SearchSection(0, 0, visualmode())<CR>
     51   sunmap <buffer> ]]
     52   noremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, '')<CR>
     53   xnoremap <buffer> <silent> ][ :<C-U>call <SID>SearchSection(1, 0, visualmode())<CR>
     54   sunmap <buffer> ][
     55   noremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, '')<CR>
     56   xnoremap <buffer> <silent> [[ :<C-U>call <SID>SearchSection(0, 1, visualmode())<CR>
     57   sunmap <buffer> [[
     58   noremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, '')<CR>
     59   xnoremap <buffer> <silent> [] :<C-U>call <SID>SearchSection(1, 1, visualmode())<CR>
     60   sunmap <buffer> []
     61 
     62   let b:undo_ftplugin .= ' | silent! execute "unmap <buffer> ]]"'
     63                      \ . ' | silent! execute "unmap <buffer> ]["'
     64                      \ . ' | silent! execute "unmap <buffer> [["'
     65                      \ . ' | silent! execute "unmap <buffer> []"'
     66 endif
     67 
     68 " Browse dialog filter on Windows and GTK (see ":help browsefilter")
     69 if (has('gui_win32') || has('gui_gtk')) && !exists('b:browsefilter')
     70   let b:browsefilter = "J Script Files (*.ijs)\t*.ijs\n"
     71   if has("win32")
     72     let b:browsefilter .= "All Files (*.*)\t*\n"
     73   else
     74     let b:browsefilter .= "All Files (*)\t*\n"
     75   endif
     76   let b:undo_ftplugin .= ' | unlet! b:browsefilter'
     77 endif
     78 
     79 " Enhanced "%" matching (see ":help matchit")
     80 if exists('loaded_matchit') && !exists('b:match_words')
     81   let b:match_ignorecase = 0
     82   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*$'
     83                   \ . ',\<\%(for\%(_\a\k*\)\=\|if\|select\|try\|whil\%(e\|st\)\)\.:\<\%(case\|catch[dt]\=\|else\%(if\)\=\|fcase\)\.:\<end\.'
     84   let b:undo_ftplugin .= ' | unlet! b:match_ignorecase b:match_words'
     85 endif
     86 
     87 let &cpo = s:save_cpo
     88 unlet s:save_cpo