Wu, Zhenyu | 27f17a6 | 2024-04-10 22:48:57 +0200 | [diff] [blame] | 1 | " Vim indent file |
| 2 | " Language: asm |
| 3 | " Maintainer: Philip Jones <philj56@gmail.com> |
| 4 | " Upstream: https://github.com/philj56/vim-asm-indent |
| 5 | " Latest Revision: 2017-07-01 |
| 6 | |
| 7 | if exists("b:did_indent") |
| 8 | finish |
| 9 | endif |
| 10 | let b:did_indent = 1 |
| 11 | |
| 12 | setlocal indentexpr=s:getAsmIndent() |
| 13 | setlocal indentkeys=<:>,!^F,o,O |
| 14 | |
| 15 | let b:undo_ftplugin .= "indentexpr< indentkeys<" |
| 16 | |
| 17 | function! s:getAsmIndent() |
| 18 | let line = getline(v:lnum) |
| 19 | let ind = shiftwidth() |
| 20 | |
| 21 | " If the line is a label (starts with ':' terminated keyword), |
| 22 | " then don't indent |
| 23 | if line =~ '^\s*\k\+:' |
| 24 | let ind = 0 |
| 25 | endif |
| 26 | |
| 27 | return ind |
| 28 | endfunction |