marshallward / vim-restructuredtext

Syntax file for reStructuredText on Vim.
26 stars 12 forks source link

tab-related settings #8

Closed anntzer closed 8 years ago

anntzer commented 8 years ago

I'd like to suggest setting tabstop, expandtap, shiftwidth and softtabstop in a plugin:

.. note
   content of the note

Note that

..  note
    content of the note

(4 spaces) is also accepted by Sphinx, but the syntax file doesn't highlight .. note (two spaces) properly. Meanwhile

.. note
    content of the note

is not accepted by Sphinx.

marshallward commented 8 years ago

Yes, I agree with this. I was already using this in my .vimrc:

tabstop = 3
softtabstop = 3
shiftwidth = 3

Not sure about the least intrusive way to configure this (apparently some sickos actually like tab characters) but I think it's a very good idea to enforce the 3-space indent.

I will look into it, but feel free to send your own pull request. I have a newborn at home and probably won't prioritise this!

anntzer commented 8 years ago

The default ftplugin/python.vim has the following snippet:

if !exists("g:python_recommended_style") || g:python_recommended_style != 0
    " As suggested by PEP8.
    setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
endif

Something similar sounds reasonable? (default to 3-spaces, provide an opt-out)

marshallward commented 8 years ago

Yeah, I think that would be fine.

I am going over the specs and it says that Tabs are expanded to 8 spaces, so maybe the way to go here is expandtab softtabstop=3 shiftwidth=3 tabstop=8.

That way, any stray tabs in the file will be shown as the 8 spaces that they will become (if they use docutils, at least) but anyone writing in vim will always produce spaces (as recommended in the spec) and will indent around 3 spaces.

Also, while this works well for comments, directives, and bullet lists, it goes a bit wrong for double-digit enumerated lists and code blocks, and maybe other stuff. Probably obvious, but figured I'd mention it. Setting these is still an improvement over the current state.

anntzer commented 8 years ago

I agree with your suggestion.

marshallward commented 8 years ago

I've just pushed an ftplugin file to the project (b65ff52eee3f73bfee9c30d316258e17edcb79b4) with the recommended changes. I have no experience with ftplugin files, so I'm guessing there's a lot room for improvement here.