From 748cb6af3d9b62231ca113ed55a7b887f37b7016 Mon Sep 17 00:00:00 2001 From: Rick Date: Thu, 8 Oct 2020 19:10:30 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20syntaxe=20et=20d=C3=A9but=20indentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ftdetect/testalgo.vim | 8 ++++++++ indent/testalgo.vim | 36 ++++++++++++++++++++++++++++++++++++ syntax/testalgo.vim | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 ftdetect/testalgo.vim create mode 100644 indent/testalgo.vim create mode 100644 syntax/testalgo.vim diff --git a/ftdetect/testalgo.vim b/ftdetect/testalgo.vim new file mode 100644 index 0000000..6e54f12 --- /dev/null +++ b/ftdetect/testalgo.vim @@ -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 diff --git a/indent/testalgo.vim b/indent/testalgo.vim new file mode 100644 index 0000000..5c8bc36 --- /dev/null +++ b/indent/testalgo.vim @@ -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 diff --git a/syntax/testalgo.vim b/syntax/testalgo.vim new file mode 100644 index 0000000..3306005 --- /dev/null +++ b/syntax/testalgo.vim @@ -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"