home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / runtime / indent / make.vim < prev    next >
Encoding:
Text File  |  2002-04-09  |  1.1 KB  |  57 lines

  1. "  vim: set sw=4 sts=4:
  2. "  Maintainer    : Nikolai 'pcp' Weibull <da.box@home.se>
  3. "  URL        : http://www.pcppopper.org/
  4. "  Revised on    : Mon, 08 Apr 2002 23:52:55 +0200
  5. "  Language    : Makefile
  6.  
  7. " Only load this indent file when no other was loaded.
  8. if exists("b:did_indent")
  9.     finish
  10. endif
  11.  
  12. let b:did_indent = 1
  13.  
  14. setlocal indentexpr=GetMakeIndent()
  15. setlocal indentkeys=!^F,o,O
  16.  
  17. " Only define the function once.
  18. if exists("*GetMakeIndent")
  19.     finish
  20. endif
  21.  
  22. function s:GetStringWidth(line, str)
  23.     let end = matchend(a:line, a:str)
  24.     let width = 0
  25.     let i = 0
  26.     while i < end
  27.     if a:line[i] != "\t"
  28.         let width = width + 1
  29.     else
  30.         let width = width + &ts - (width % &ts)
  31.     endif
  32.     let i = i + 1
  33.     endwhile
  34.     return width
  35. endfunction
  36.  
  37. function GetMakeIndent()
  38.     if v:lnum == 1
  39.     return 0
  40.     endif
  41.  
  42.     let ind = indent(v:lnum - 1)
  43.     let line = getline(v:lnum - 1)
  44.  
  45.     if line == ''
  46.     let ind = 0
  47.     elseif line =~ '^[^ \t#:][^#:]*:\{1,2}\([^=:]\|$\)'
  48.     let ind = ind + &ts
  49.     elseif line =~ '^\s*\h\w*\s*=\s*.\+\\$'
  50.     let ind = s:GetStringWidth(line, '=\s*')
  51.     elseif line !~ '\\$'
  52.     let ind = indent(v:lnum)
  53.     endif
  54.  
  55.     return ind
  56. endfunction
  57.