abaqus.vim 3.3 KB

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