diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-21 18:09:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-21 18:09:37 +0200 |
commit | 11e3c5ba820325b69cb56f70e13c21d7b8808d33 (patch) | |
tree | fce34aa15c9f5fbd6244f451dd37e8580fdb2cf3 /runtime/indent | |
parent | 459fbdbf9216bc7b4721fc192e08b35039036caa (diff) |
Update runtime files
Diffstat (limited to 'runtime/indent')
-rw-r--r-- | runtime/indent/raku.vim (renamed from runtime/indent/perl6.vim) | 21 | ||||
-rw-r--r-- | runtime/indent/rmd.vim | 32 | ||||
-rw-r--r-- | runtime/indent/vim.vim | 5 |
3 files changed, 36 insertions, 22 deletions
diff --git a/runtime/indent/perl6.vim b/runtime/indent/raku.vim index 51c7923182..3f9b49ec77 100644 --- a/runtime/indent/perl6.vim +++ b/runtime/indent/raku.vim @@ -36,7 +36,7 @@ let b:did_indent = 1 " Is syntax highlighting active ? let b:indent_use_syntax = has("syntax") -setlocal indentexpr=GetPerl6Indent() +setlocal indentexpr=GetRakuIndent() " we reset it first because the Perl 5 indent file might have been loaded due " to a .pl/pm file extension, and indent files don't clean up afterwards @@ -50,7 +50,7 @@ endif let s:cpo_save = &cpo set cpo-=C -function! GetPerl6Indent() +function! GetRakuIndent() " Get the line to be indented let cline = getline(v:lnum) @@ -60,11 +60,6 @@ function! GetPerl6Indent() return 0 endif - " Don't reindent coments on first column - if cline =~ '^#' - return 0 - endif - " Get current syntax item at the line's first char let csynid = '' if b:indent_use_syntax @@ -72,7 +67,7 @@ function! GetPerl6Indent() endif " Don't reindent POD and heredocs - if csynid =~ "^p6Pod" + if csynid =~ "^rakuPod" return indent(v:lnum) endif @@ -92,7 +87,7 @@ function! GetPerl6Indent() let skippin = 2 while skippin let synid = synIDattr(synID(lnum,1,0),"name") - if (synid =~ "^p6Pod" || synid =~ "p6Comment") + if (synid =~ "^rakuPod" || synid =~ "rakuComment") let lnum = prevnonblank(lnum - 1) if lnum == 0 return 0 @@ -107,19 +102,19 @@ function! GetPerl6Indent() endif if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$' - let ind = ind + shiftwidth() + let ind = ind + &sw endif if cline =~ '^\s*[)}\]»>]' - let ind = ind - shiftwidth() + let ind = ind - &sw endif " Indent lines that begin with 'or' or 'and' if cline =~ '^\s*\(or\|and\)\>' if line !~ '^\s*\(or\|and\)\>' - let ind = ind + shiftwidth() + let ind = ind + &sw endif elseif line =~ '^\s*\(or\|and\)\>' - let ind = ind - shiftwidth() + let ind = ind - &sw endif return ind diff --git a/runtime/indent/rmd.vim b/runtime/indent/rmd.vim index 83fe4e4fed..8fd57257fa 100644 --- a/runtime/indent/rmd.vim +++ b/runtime/indent/rmd.vim @@ -2,7 +2,7 @@ " Language: Rmd " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Sun Aug 19, 2018 09:14PM +" Last Change: Sun Mar 28, 2021 08:05PM " Only load this indent file when no other was loaded. @@ -13,7 +13,7 @@ runtime indent/r.vim let s:RIndent = function(substitute(&indentexpr, "()", "", "")) let b:did_indent = 1 -setlocal indentkeys=0{,0},:,!^F,o,O,e +setlocal indentkeys=0{,0},<:>,!^F,o,O,e setlocal indentexpr=GetRmdIndent() if exists("*GetRmdIndent") @@ -23,6 +23,21 @@ endif let s:cpo_save = &cpo set cpo&vim +" Simple Python indentation algorithm +function s:GetPyIndent() + let plnum = prevnonblank(v:lnum - 1) + let pline = getline(plnum) + let cline = getline(v:lnum) + if pline =~ '^s```\s*{\s*python ' + return 0 + elseif pline =~ ':$' + return indent(plnum) + &shiftwidth + elseif cline =~ 'else:$' + return indent(plnum) - &shiftwidth + endif + return indent(plnum) +endfunction + function s:GetMdIndent() let pline = getline(v:lnum - 1) let cline = getline(v:lnum) @@ -37,13 +52,14 @@ function s:GetMdIndent() endfunction function s:GetYamlIndent() - let pline = getline(v:lnum - 1) + let plnum = prevnonblank(v:lnum - 1) + let pline = getline(plnum) if pline =~ ':\s*$' - return indent(v:lnum) + shiftwidth() + return indent(plnum) + shiftwidth() elseif pline =~ '^\s*- ' return indent(v:lnum) + 2 endif - return indent(prevnonblank(v:lnum - 1)) + return indent(plnum) endfunction function GetRmdIndent() @@ -52,9 +68,11 @@ function GetRmdIndent() endif if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW") return s:RIndent() - elseif v:lnum > 1 && search('^---$', "bnW") == 1 && - \ (search('^---$', "nW") > v:lnum || search('^...$', "nW") > v:lnum) + elseif v:lnum > 1 && (search('^---$', "bnW") == 1 && + \ (search('^---$', "nW") > v:lnum || search('^\.\.\.$', "nW") > v:lnum)) return s:GetYamlIndent() + elseif search('^[ \t]*```{python', "bncW") > search('^[ \t]*```$', "bncW") + return s:GetPyIndent() else return s:GetMdIndent() endif diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 5c022642b5..ca1e4725af 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Vim script " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Feb 18 +" Last Change: 2021 Apr 18 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -71,7 +71,8 @@ function GetVimIndentIntern() " End of heredoc: use indent of matching start line let lnum = v:lnum - 1 while lnum > 0 - if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc' + let attr = synIDattr(synID(lnum, 1, 1), "name") + if attr != '' && attr !~ 'vimLetHereDoc' return indent(lnum) endif let lnum -= 1 |