From 8cbadb61604667b407b53ee1258433994fa4765a Mon Sep 17 00:00:00 2001 From: coasteen Date: Thu, 9 Jul 2026 10:42:28 +0330 Subject: init --- config/nvim-2/vscript/scp.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 config/nvim-2/vscript/scp.vim (limited to 'config/nvim-2/vscript/scp.vim') diff --git a/config/nvim-2/vscript/scp.vim b/config/nvim-2/vscript/scp.vim new file mode 100644 index 0000000..6824c18 --- /dev/null +++ b/config/nvim-2/vscript/scp.vim @@ -0,0 +1,29 @@ +function! Sc(char) + let closing = {'(': ')', '[': ']', '{': '}', '<': '>', '"': '"', "'": "'"} + + if has_key(closing, a:char) + let line = getline('.') + let col = col('.') - 1 + let before = col > 0 ? line[col-1] : '' + let after = col < len(line) ? line[col] : '' + if before =~ '\w' && after =~ '\w' + return a:char + endif + if (a:char == '"' || a:char == "'") && before == a:char + return a:char + endif + if after == closing[a:char] + return "\" + endif + return a:char . closing[a:char] . "\" + endif + + return a:char +endfunction + +inoremap ( =Sc('(') +inoremap [ =Sc('[') +inoremap { =Sc('{') +inoremap < =Sc('<') +inoremap " =Sc('"') +inoremap ' =Sc("'") -- cgit v1.2.3