Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve vim syntax files. #226

Merged
merged 6 commits into from
Aug 11, 2023
Merged

Improve vim syntax files. #226

merged 6 commits into from
Aug 11, 2023

Conversation

erikcorry
Copy link

This adds autoindent, based on the Python indentation files from neovim.

The directory layout is modified so that the repo can be checked out unchanged in your .vim/pack directory for Vim 8 compatibility.

Erik Corry added 2 commits August 11, 2023 13:25
This adds autoindent, based on the Python indentation files
from neovim.

The directory layout is modified so that the repo can be
checked out unchanged in your .vim/pack directory for
Vim 8 compatibility.
Copy link
Member

@floitsch floitsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

"
" Vim indent file
" Language: Toit
" Maintainer: Bram Moolenaar <Bram@vim.org>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this.

" Language: Toit
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Original Author: David Bustos <bustos@caltech.edu>
" Last Change: 2021 Sep 26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too?

setlocal autoindent " indentexpr isn't much help otherwise

setlocal indentexpr=ToitGetIndent(v:lnum)
setlocal indentkeys+=<:>,=elif,=except
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elif and except don't make sense.


let b:undo_indent = "setl ai< inde< indk< lisp<"

" Support for Python indenting, see runtime/indent/python.vim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/python/toit

return indent(a:lnum) <= a:expected - s:normal_indent
endfunction

" Some other filetypes which embed Python have slightly different indent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment doesn't really apply.

endif

" If the current line begins with a keyword that lines up with "try"
if getline(a:lnum) =~ '^\s*\(except\|finally\)\>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have 'except'.

Is this trying to unindent?

if getline(a:lnum) =~ '^\s*\(except\|finally\)\>'
let lnum = a:lnum - 1
while lnum >= 1
if getline(lnum) =~ '^\s*\(try\|except\)\>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: we don't have 'except'.

endif

" If the current line begins with a header keyword, dedent
if getline(a:lnum) =~ '^\s*\(elif\|else\)\>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toit doesn't have 'elif'

if getline(a:lnum) =~ '^\s*\(elif\|else\)\>'

" Unless the previous line was a one-liner
if getline(plnumstart) =~ '^\s*\(for\|if\|elif\|try\)\>'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: we don't have elif.
and the try probably doesn't behave the same.

return plindent - s:normal_indent
endif

" When after a () construct we probably want to go back to the start line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that's really true for Toit.

@erikcorry erikcorry merged commit 1eea955 into master Aug 11, 2023
@erikcorry erikcorry deleted the vim-indentation branch August 11, 2023 13:16
Copy link
Member

@floitsch floitsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants