From bc9757916ed09763d96283ee62dbed58bd713a11 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 6 Oct 2020 18:54:19 +0200 Subject: Add all vim filetypes --- indent/sshconfig.vim | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 indent/sshconfig.vim (limited to 'indent/sshconfig.vim') diff --git a/indent/sshconfig.vim b/indent/sshconfig.vim new file mode 100644 index 00000000..c25e297d --- /dev/null +++ b/indent/sshconfig.vim @@ -0,0 +1,38 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'sshconfig') == -1 + +" Vim indent file +" Language: ssh config file +" Maintainer: JasonKim +" Last Change: 2020 May 16 + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetSshconfigIndent(v:lnum) +setlocal indentkeys=o,O,*,0=~host\ ,0=~match\ ,0#,!^F + +let b:undo_indent = "setlocal autoindent< indentexpr< indentkeys<" + +if exists("*GetSshconfigIndent") + finish +endif + +function GetSshconfigIndent(lnum) + let sw = shiftwidth() + let prev_lnum = prevnonblank(a:lnum - 1) + let curr_lnum = a:lnum + let prev_line = getline(prev_lnum) + let curr_line = getline(curr_lnum) + if curr_line =~? '^\s*\(host\|match\)\s' + return 0 + elseif prev_line =~? '^\s*\(host\|match\)\s' + return sw + else + return indent(prev_lnum) + endif +endfunction + +endif -- cgit v1.2.3