Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
logtalk.vim68 linesDownload Raw Back to indent
1"  Maintainer:	Paulo Moura <pmoura@logtalk.org>2"  Revised on:	2018.08.043"		2023 Aug 28 by Vim Project (undo_indent)4"  Language:	Logtalk5 6" This Logtalk indent file is a modified version of the Prolog7" indent file written by Gergely Kontra8 9" Only load this indent file when no other was loaded.10if exists("b:did_indent")11	finish12endif13 14let b:did_indent = 115 16setlocal indentexpr=GetLogtalkIndent()17setlocal indentkeys-=:,0#18setlocal indentkeys+=0%,-,0;,>,0)19 20let b:undo_indent = "setlocal indentexpr< indentkeys<"21 22" Only define the function once.23if exists("*GetLogtalkIndent")24	finish25endif26 27function! GetLogtalkIndent()28	" Find a non-blank line above the current line.29	let pnum = prevnonblank(v:lnum - 1)30	" Hit the start of the file, use zero indent.31	if pnum == 032		return 033	endif34	let line = getline(v:lnum)35	let pline = getline(pnum)36 37	let ind = indent(pnum)38	" Previous line was comment -> use previous line's indent39	if pline =~ '^\s*%'40		retu ind41	endif42	" Check for entity opening directive on previous line43	if pline =~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$'44		let ind = ind + shiftwidth()45	" Check for clause head on previous line46	elseif pline =~ ':-\s*\(%.*\)\?$'47		let ind = ind + shiftwidth()48	" Check for grammar rule head on previous line49	elseif pline =~ '-->\s*\(%.*\)\?$'50		let ind = ind + shiftwidth()51	" Check for entity closing directive on previous line52	elseif pline =~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\?$'53		let ind = ind - shiftwidth()54	" Check for end of clause on previous line55	elseif pline =~ '\.\s*\(%.*\)\?$'56		let ind = ind - shiftwidth()57	endif58	" Check for opening conditional on previous line59	if pline =~ '^\s*\([(;]\|->\)' && pline !~ '\.\s*\(%.*\)\?$' && pline !~ '^.*\([)][,]\s*\(%.*\)\?$\)'60		let ind = ind + shiftwidth()61	endif62	" Check for closing an unclosed paren, or middle ; or ->63	if line =~ '^\s*\([);]\|->\)'64		let ind = ind - shiftwidth()65	endif66	return ind67endfunction68 
codekingpro/portable-devtools · Team Ai