robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
2f5b8a0092
master
1" Vim filetype plugin file 2" Language: Abaqus finite element input file (www.abaqus.com) 3" Maintainer: Carl Osterwisch <costerwi@gmail.com> 4" Last Change: 2022 Oct 08 5" 2024 Jan 14 by Vim Project (browsefilter) 6" 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring') 7 8" Only do this when not done yet for this buffer 9if exists ( "b:did_ftplugin" ) |finish |endif 10 11" Don't load another plugin for this buffer 12let b: did_ftplugin = 1 13 14" Save the compatibility options and temporarily switch to vim defaults 15let s: cpo_save = & cpoptions 16set cpoptions & vim 17 18" Set the format of the include file specification for Abaqus 19" Used in :check gf ^wf [i and other commands 20setlocal include = \\<\\cINPUT\\s*= 21 22" Remove characters up to the first = when evaluating filenames 23setlocal includeexpr = substitute (v:fname,'.\\{-}=','','') 24 25" Remove comma from valid filename characters since it is used to 26" separate keyword parameters 27setlocal isfname -= , 28 29" Define format of comment lines (see 'formatoptions' for uses) 30setlocal comments = :** 31setlocal commentstring = **\ %s 32 33" Definitions start with a * and assign a NAME, NSET, or ELSET 34" Used in [d ^wd and other commands 35setlocal define = ^\\*\\a.*\\c\\(NAME\\\|NSET\\\|ELSET\\)\\s*= 36 37" Abaqus keywords and identifiers may include a - character 38setlocal iskeyword += - 39 40let b: undo_ftplugin = "setlocal include< includeexpr< isfname<" 41 \. " comments< commentstring< define< iskeyword<" 42 43if has ( "folding" ) 44" Fold all lines that do not begin with * 45setlocal foldexpr = getline (v:lnum)[0]!=\"\*\" 46setlocal foldmethod = expr 47let b: undo_ftplugin .= " foldexpr< foldmethod<" 48endif 49 50" Set the file browse filter (currently only supported under Win32 gui) 51if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 52let b: browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" . 53 \"Abaqus Results (*.dat)\t*.dat\n" . 54 \"Abaqus Messages (*.pre, *.msg, *.sta)\t*.pre;*.msg;*.sta\n" 55if has ( "win32" ) 56let b: browsefilter .= "All Files (*.*)\t*\n" 57else 58let b: browsefilter .= "All Files (*)\t*\n" 59endif 60let b: undo_ftplugin .= "|unlet! b:browsefilter" 61endif 62 63" Define patterns for the matchit plugin 64if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 65let b: match_ignorecase = 1 66let b: match_words = 67 \'\*part:\*end\s*part,' . 68 \'\*assembly:\*end\s*assembly,' . 69 \'\*instance:\*end\s*instance,' . 70 \'\*step:\*end\s*step' 71let b: undo_ftplugin .= "|unlet! b:match_ignorecase b:match_words" 72endif 73 74if ! exists ( "no_plugin_maps" ) && ! exists ( "no_abaqus_maps" ) 75" Map [[ and ]] keys to move [count] keywords backward or forward 76nnoremap <silent><buffer> ]] :call< SID > Abaqus_NextKeyword(1)< CR > 77nnoremap <silent><buffer> [[ :call< SID > Abaqus_NextKeyword(-1)< CR > 78function ! <SID> Abaqus_NextKeyword ( direction ) 79 .mark ' 80if a: direction < 0 81let flags = 'b' 82else 83let flags = '' 84endif 85let l: count = abs ( a: direction ) * v: count1 86while l: count > 0 && search ( "^\\*\\a" , flags ) 87let l: count -= 1 88endwhile 89endfunction 90 91" Map \\ to toggle commenting of the current line or range 92noremap <silent><buffer> < LocalLeader > <LocalLeader > 93 \ :call< SID > Abaqus_ToggleComment()< CR > j 94function ! <SID> Abaqus_ToggleComment () range 95if strpart ( getline ( a: firstline ), 0 , 2 ) == "**" 96" Un-comment all lines in range 97silent execute a: firstline . ',' . a: lastline . 's/^\*\*//' 98else 99" Comment all lines in range 100silent execute a: firstline . ',' . a: lastline . 's/^/**/' 101endif 102endfunction 103 104" Map \s to swap first two comma separated fields 105noremap <silent><buffer> < LocalLeader > s :call< SID > Abaqus_Swap()< CR > 106function ! <SID> Abaqus_Swap () range 107silent execute a: firstline . ',' . a: lastline . 's/\([^*,]*\),\([^,]*\)/\2,\1/' 108endfunction 109 110let b: undo_ftplugin .= "|unmap <buffer> [[|unmap <buffer> ]]" 111 \. "|unmap <buffer> <LocalLeader><LocalLeader>" 112 \. "|unmap <buffer> <LocalLeader>s" 113endif 114 115" Undo must be done in nocompatible mode for <LocalLeader>. 116let b: undo_ftplugin = "let b:cpo_save = &cpoptions|" 117 \. "set cpoptions&vim|" 118 \. b: undo_ftplugin 119 \. "|let &cpoptions = b:cpo_save" 120 \. "|unlet b:cpo_save" 121 122" Restore saved compatibility options 123let & cpoptions = s: cpo_save 124unlet s: cpo_save