Hello, I tried to write syntax and indent files (attachment) for .brf files, http://brouter.de/brouter/costfunctions.html
It is the first time I do something with vim more than simple usage, so probably it needs some fixes. Moreover, what is the simplest way to "pull request" this to the official repo? Can someone do it please? Thank you. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/695a62250a997e2356f8631fb07e67f2828dff02.camel%40gmail.com.
" Vim indent file " Language: Brouter routing file " Author: Tyr4 <[email protected]> " Last Change: 2019-08-01 if exists('b:did_indent') finish endif let b:did_indent = 1 setlocal nolisp setlocal autoindent setlocal indentexpr=GetBrfIndent(v:lnum) setlocal indentkeys+=<:>,=switch if exists("GetBrfIndent") finish endif function PreviousNonBlankLine(lnum) let l:plnum = a:lnum-1 while l:plnum > 1 && match(getline(l:plnum), '^\s*$') == 0 let l:plnum -= 1 endwhile return l:plnum endfunction function GetBrfIndent(lnum) let l:kws1 = '\<\(not\|or\|and\|xor\|multiply\|add\|sub\|max\|min\|equal\|greater\|lesser\|switch\|if\|then\|else\)\>' let l:kws2 = '^assign\s\+\k\+\s\+\S\+\s*$' let l:kws3 = '\<\(assign\)\>' "let l:plnum = PreviousNonBlankLine(a:lnum) let l:plnum = a:lnum-1 let l:line = getline(l:plnum) let l:sharp = match(l:line, '#') let s = matchend(l:line, l:kws1) if s > -1 && (l:sharp == -1 || l:sharp > match(l:line, l:kws1)) return s + 1 endif let s = matchend(l:line, l:kws2) if s > -1 && (l:sharp == -1 || l:sharp > match(l:line, l:kws1)) return 0 endif let s = matchend(l:line, l:kws3) if s > -1 && (l:sharp == -1 || l:sharp > match(l:line, l:kws1)) return s + 1 endif return match(l:line, '\S') endfunction function BrfITabIndent() let l:pos=getcurpos() let l:col=l:pos[2] let l:lnum=l:pos[1] if match(getline(l:lnum), '^assign') == 0 let l:col=getcurpos()[2] let l:spaces = 2 - (((l:col-1)/&softtabstop) % 2) return repeat(' ', l:spaces) endif if l:lnum > 1 "let l:line=getline(PreviousNonBlankLine(l:lnum)) let l:line=getline(l:lnum-1) let l:n=matchend(l:line,'\>',l:col) if l:n > -1 let l:r=l:n-l:col+2 return repeat(' ', l:r) else return " " endif else return " " endif echo l:lnum endfunction imap <Tab> <C-R>=BrfITabIndent()<CR> set ts=8 sts=8 sw=8 expandtab tw=80
" Vim syntax file " Language: Brouter routing file " Maintainer: Tyr4 <[email protected]> " Latest Revision: 2019-08-01 if exists("b:current_syntax") finish endif syntax case match syntax iskeyword 48-57,-,_,65-90,97-122 setlocal iskeyword+=48-57,-,_,65-90,97-122 syn keyword brfTodo contained TODO FIXME NOTE STOPHERE syn keyword brfAssign assign syn keyword brfOperators not or and xor multiply add sub max min equal greater lesser switch if then else syn keyword brfGlobalVar processunusedtags turnInstructionMode turnInstructionCatchingRange turnInstructionRoundabouts syn keyword brfGlobalVar downhillcost downhillcutoff uphillcost uphillcutoff elevationpenaltybuffer elevationmaxbuffer elevationbufferreduce syn keyword brfGlobalVar validForBikes validForFoot validForCars syn keyword brfGlobalVar pass1coefficient pass2coefficient syn keyword brfWayVar turncost initialcost costfactor uphillcostfactor downhillcostfactor nodeaccessgranted initialclassifier syn keyword brfNodeVar initialcost syn keyword brfConstant true false syn cluster brfAnyVar contains=brfGlobalVar,brfWayVar,brfNodeVar syn match brfContext /^---context:\(global\|way\|node\)/ syn match brfLookupKey /\<\(:\|\k\)\+=/ nextgroup=brfLookupValue syn match brfLookupValue contained /\<\(\k\+\(|\k\+\)*\>\)/ contains=brfChoice syn match brfComment /#.*$/ contains=brfTodo syn match brfNumeric /\<-\?\d\+\(\.\d\+\)\?\>/ syn match brfChoice contained /|/ let b:current_syntax = "brf" hi def link brfTodo Todo hi def link brfAssign Statement hi def link brfOperators Statement hi def link brfGlobalVar Identifier hi def link brfWayVar Identifier hi def link brfNodeVar Identifier hi def link brfContext Special hi def link brfComment Comment hi def link brfNumeric Constant hi def link brfConstant Constant hi def link brfLookupKey Type hi def link brfLookupValue Special hi def link brfChoice Function "hi def link brfError Error "syntax sync fromstart " TODO: see /help :syn-sync-fourth ""syn keyword brfUnaryKw contained not ""syn keyword brfBinaryKw contained or and xor ""syn keyword brfBinaryKw contained multiply add sub max min ""syn keyword brfBinaryKw contained equal greater lesser ""syn keyword brfTernaryKw contained switch ""syn keyword brfIfThenElseKw contained if then else ""syn keyword brfBoolKw contained true false ""syn keyword brfGlobalVarKw contained downhillcost downhillcutoff uphillcost uphillcutoff elevationpenaltybuffer elevationmaxbuffer elevationbufferreduce ""syn keyword brfGlobalVarKw contained validForBikes validForFoot validForCars ""syn keyword brfGlobalVarKw contained pass1coefficient pass2coefficient ""syn keyword brfWayVarKw contained turncost initialcost costfactor uphillcostfactor downhillcostfactor nodeaccessgranted initialclassifier ""syn keyword brfNodeVarKw contained initialcost "syn keyword brfTodo contained TODO FIXME NOTE STOPHERE " ""syn match brfNumeric '-\?\d\+\(\.\d\+\)\?' ""syn match brfLookup /\<[a-zA-Z:-_0-9]\+=\([a-zA-Z:-_0-9]\+\(|[a-zA-Z:-_0-9]\+\)*\)\?\>/ ""syn match brfAssignment /assign\s\+[a-zA-Z-_0-9]\+\(=\s\+\)\?/ contains=brfVariable "syn match brfAssignment /\<assign\>/ contains=brfVariable "syn match brfVariable contained /\<[a-zA-Z-_0-9]\+\>/ " ""hi def link brfNumeric Constant "hi def link brfContextsKw Title "hi def link brfTodo Todo "hi def link brfAssignment Statement ""hi def link brfVariable "hi def link brfComment Comment
