Ajout syntaxe et début indentation

This commit is contained in:
Rick 2020-10-08 19:10:30 +02:00
parent 86f72a07ef
commit 748cb6af3d
Signed by: Rick
GPG Key ID: 9570A7DB7CB2F436
3 changed files with 85 additions and 0 deletions

8
ftdetect/testalgo.vim Normal file
View File

@ -0,0 +1,8 @@
" syntaxe de testalgo
" Maintainer: rick@gnous.eu
" Contributor:
" Last Changes: 07 Octobre 2020
" Gnous Repository: https://git.gnous.eu/Rick/vim-testalgo
" Licence: GPL3 only
au BufNewFile,BufRead *.talg set filetype=testalgo

36
indent/testalgo.vim Normal file
View File

@ -0,0 +1,36 @@
setlocal indentexpr=TestalgoIndent()
function! TestalgoIndent()
let line = getline(v:lnum)
let previousNum = prevnonblank(v:lnum-1)
let nextNum = prevnonblank(v:lnum+1)
let previous = getline(previousNum)
let next = getline(nextNum)
if previous =~ "^var$"
return indent(previousNum) + &tabstop
endif
if previous =~ "alors" && previous !~ "finsi" && line !~ "finsi"
call append(line(1), 'finsi')
return indent(previousNum) + &tabstop
endif
if previous =~ "alors" && previous !~ "finsi" && line !~ "finsi" && line !~ "alors"
return indent(previousNum) + &tabstop
endif
if previous =~ "tantque \(.*\)$" && previous !~ "fintantque" && line !~ "fintantque" && line !~ "tantque \(.*\)$"
return indent(previousNum) + &tabstop
endif
if previous =~ "repeter" && previous !~ "finrepeter" && line !~ "finrepeter" && line !~ "repeter"
return indent(previousNum) + &tabstop
endif
if previous =~ "pas .*" && previous !~ "finpour" && line !~ "finpour" && line !~ "pas .*"
return indent(previousNum) + &tabstop
endif
endfunction

41
syntax/testalgo.vim Normal file
View File

@ -0,0 +1,41 @@
" syntaxe de testalgo
" Maintainer: rick@gnous.eu
" Contributor:
" Last Changes: 07 Octobre 2020
" Gnous Repository: https://git.gnous.eu/Rick/vim-testalgo
" Licence: GPL3 only
if exists("b:current_syntax")
finish
endif
syntax keyword testalgoKeyword var algo debut fin
syntax keyword testalgoConditional si alors sinon finsi
syntax keyword testalgoRepeat tantque fintantque pour finpour à pas
syntax keyword testalgoRepeat repeter finrepeter jusqua
syntax keyword testalgoFunction saisir afficher afficherln alaligne
highlight link testalgoKeyword Keyword
highlight link testalgoConditional Conditional
highlight link testalgoRepeat Repeat
highlight link testalgoFunction Function
syntax keyword testalgoBoolean vrai faux
syntax keyword testalgoType entier reel booleen chaine caractere
highlight link testalgoBoolean Boolean
highlight link testalgoType Type
"TODO tableau_de (permet de faire un tableau)
"TODO procedure fonction (définessent des fonctions)
"TODO principal (main)
syntax match testalgoComment "\v#.*$"
highlight link testalgoComment Comment
syntax match testalgoString "\v\".*\""
highlight link testalgoString String
"syntax match testalgoOperator "\v:\="
"highlight link testalgoOperator Operator
let b:current_syntax = "testalgo"