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