]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(asm): add basic indent support
authorWu, Zhenyu <wuzhenyu@ustc.edu>
Wed, 10 Apr 2024 20:48:57 +0000 (22:48 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 10 Apr 2024 20:48:57 +0000 (22:48 +0200)
closes: #14383

Signed-off-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/indent/asm.vim [new file with mode: 0644]

diff --git a/runtime/indent/asm.vim b/runtime/indent/asm.vim
new file mode 100644 (file)
index 0000000..7f848c7
--- /dev/null
@@ -0,0 +1,28 @@
+" Vim indent file
+" Language:             asm
+" Maintainer:           Philip Jones <philj56@gmail.com>
+" Upstream:             https://github.com/philj56/vim-asm-indent
+" Latest Revision:      2017-07-01
+
+if exists("b:did_indent")
+  finish
+endif
+let b:did_indent = 1
+
+setlocal indentexpr=s:getAsmIndent()
+setlocal indentkeys=<:>,!^F,o,O
+
+let b:undo_ftplugin .= "indentexpr< indentkeys<"
+
+function! s:getAsmIndent()
+  let line = getline(v:lnum)
+  let ind = shiftwidth()
+
+  " If the line is a label (starts with ':' terminated keyword), 
+  " then don't indent
+  if line =~ '^\s*\k\+:'
+    let ind = 0
+  endif
+
+  return ind
+endfunction