Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Abaqus finite element input file (www.abaqus.com) |
| 3 | " Maintainer: Carl Osterwisch <osterwischc@asme.org> |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 4 | " Last Change: 2012 Mar 11 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | |
| 6 | " Only do this when not done yet for this buffer |
| 7 | if exists("b:did_ftplugin") | finish | endif |
| 8 | |
| 9 | " Don't load another plugin for this buffer |
| 10 | let b:did_ftplugin = 1 |
| 11 | |
| 12 | " Save the compatibility options and temporarily switch to vim defaults |
| 13 | let s:cpo_save = &cpoptions |
| 14 | set cpoptions&vim |
| 15 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 16 | " Set the format of the include file specification for Abaqus |
| 17 | " Used in :check gf ^wf [i and other commands |
| 18 | setlocal include=\\<\\cINPUT\\s*= |
| 19 | |
| 20 | " Remove characters up to the first = when evaluating filenames |
| 21 | setlocal includeexpr=substitute(v:fname,'.\\{-}=','','') |
| 22 | |
Bram Moolenaar | 8299df9 | 2004-07-10 09:47:34 +0000 | [diff] [blame] | 23 | " Remove comma from valid filename characters since it is used to |
| 24 | " separate keyword parameters |
| 25 | setlocal isfname-=, |
| 26 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 27 | " Define format of comment lines (see 'formatoptions' for uses) |
| 28 | setlocal comments=:** |
| 29 | setlocal commentstring=**%s |
| 30 | |
| 31 | " Definitions start with a * and assign a NAME, NSET, or ELSET |
| 32 | " Used in [d ^wd and other commands |
| 33 | setlocal define=^\\*\\a.*\\c\\(NAME\\\|NSET\\\|ELSET\\)\\s*= |
| 34 | |
| 35 | " Abaqus keywords and identifiers may include a - character |
| 36 | setlocal iskeyword+=- |
| 37 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 38 | let b:undo_ftplugin = "setlocal include< includeexpr< isfname<" |
| 39 | \ . " comments< commentstring< define< iskeyword<" |
| 40 | |
| 41 | if has("folding") |
| 42 | " Fold all lines that do not begin with * |
| 43 | setlocal foldexpr=getline(v:lnum)[0]!=\"\*\" |
| 44 | setlocal foldmethod=expr |
| 45 | let b:undo_ftplugin .= " foldexpr< foldmethod<" |
| 46 | endif |
| 47 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 48 | " Set the file browse filter (currently only supported under Win32 gui) |
| 49 | if has("gui_win32") && !exists("b:browsefilter") |
| 50 | let b:browsefilter = "Abaqus Input Files (*.inp *.inc)\t*.inp;*.inc\n" . |
| 51 | \ "Abaqus Results (*.dat)\t*.dat\n" . |
| 52 | \ "Abaqus Messages (*.pre *.msg *.sta)\t*.pre;*.msg;*.sta\n" . |
| 53 | \ "All Files (*.*)\t*.*\n" |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 54 | let b:undo_ftplugin .= "|unlet b:browsefilter" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 55 | endif |
| 56 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 57 | " Define patterns for the matchit plugin |
| 58 | if exists("loaded_matchit") && !exists("b:match_words") |
| 59 | let b:match_ignorecase = 1 |
| 60 | let b:match_words = |
| 61 | \ '\*part:\*end\s*part,' . |
| 62 | \ '\*assembly:\*end\s*assembly,' . |
| 63 | \ '\*instance:\*end\s*instance,' . |
| 64 | \ '\*step:\*end\s*step' |
| 65 | let b:undo_ftplugin .= "|unlet b:match_ignorecase b:match_words" |
| 66 | endif |
| 67 | |
| 68 | " Define keys used to move [count] keywords backward or forward. |
| 69 | noremap <silent><buffer> [[ ?^\*\a<CR>:nohlsearch<CR> |
| 70 | noremap <silent><buffer> ]] /^\*\a<CR>:nohlsearch<CR> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 71 | |
| 72 | " Define key to toggle commenting of the current line or range |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 73 | noremap <silent><buffer> <LocalLeader><LocalLeader> |
| 74 | \ :call <SID>Abaqus_ToggleComment()<CR>j |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 75 | function! <SID>Abaqus_ToggleComment() range |
| 76 | if strpart(getline(a:firstline), 0, 2) == "**" |
| 77 | " Un-comment all lines in range |
| 78 | silent execute a:firstline . ',' . a:lastline . 's/^\*\*//' |
| 79 | else |
| 80 | " Comment all lines in range |
| 81 | silent execute a:firstline . ',' . a:lastline . 's/^/**/' |
| 82 | endif |
| 83 | endfunction |
| 84 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 85 | let b:undo_ftplugin .= "|unmap <buffer> [[|unmap <buffer> ]]" |
| 86 | \ . "|unmap <buffer> <LocalLeader><LocalLeader>" |
| 87 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 88 | " Restore saved compatibility options |
| 89 | let &cpoptions = s:cpo_save |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 90 | unlet s:cpo_save |