-
Notifications
You must be signed in to change notification settings - Fork 12
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
Allow one to set a default language for code blocks #17
Comments
I would love this, but is it possible to do this at the reST level? If not, then I wonder if it could be misleading. |
Sphinx has |
Supporting this is no problem, I wasn't familiar with the As you can tell from the other tickets I don't have much time to devote to the stylesheet these days. The biggest hurdle is just a general lack of familiarity with vimscript. Getting this working might take more a community effort. (And as always, I'm happy to hand over maintenance to someone with more vimscript experience.) |
There's no hurry, I'm fine with this issue tracker being a TODO list :-) |
That's a relief to hear! I love reST and vim, so I'm happy there's someone else out there who feels the same, and would hate to get in the way of that :). |
Note for whoever tries to implement this (perhaps myself): it may be possible (or not) to implement this in a reasonably robust manner by having |
I was about to file a new issue, but this seems fitting! :) Sphinx allows for using highlighting with literal code blocks by default (via It would be great if this would be supported by the syntax. It seems like this might warrant a setting, and maybe/also a general setting to enable Sphinx's extensions in general? It might also be enough documenting how you can extend it yourself - since it only adds to the "contains" after all. diff --git i/runtime/syntax/rst.vim w/runtime/syntax/rst.vim
index c865cf690..fa6356542 100644
--- i/runtime/syntax/rst.vim
+++ w/runtime/syntax/rst.vim
@@ -20,9 +20,15 @@ syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasi>
\ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference,
\ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference
+" NOTE: Sphinx uses Python by default, via "highlight_language" setting.
+" Therefore add @rstpython, for:
+"
+" Some code::
+"
+" print("python!")
syn region rstLiteralBlock matchgroup=rstDelimiter
\ start='::\_s*\n\ze\z(\s\+\)' skip='^$' end='^\z1\@!'
- \ contains=@NoSpell
+ \ contains=@NoSpell,@rstpython
syn region rstQuotedLiteralBlock matchgroup=rstDelimiter
\ start="::\_s*\n\ze\z([!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]\)" |
Seems like a great idea, and I agree that some sort of "Sphinx-mode" might be useful in other situations too. I'm a bit out of time at the moment, but if you send in something then I can merge it. |
Cool. I do not have much time myself, and the above works good for me already. I have not yet investigated/check how easy it would be to do the above patch via vimrc, but is likely not hard, and more flexible then altogether - this would mean it could be added to docs for now then only. |
Maybe the simplest path for now is to just introduce a default syntax for code blocks, since it's the only Sphinx-specific we're talking about at the moment. Sphinx uses I could see a suite of Sphinx-friendly flags being added over time, since there are several directives and things which are slightly different in reST and Sphinx. One that comes to mind is the |
It would be practical if one could set a default language for highlighting code blocks -- e.g. through a buffer-local variable.
A use case is of course python documentation where
::
will most often introduce a python code block. For example, https://github.com/davidhalter/jedi-vim/blob/master/autoload/jedi.vim#L351 could benefit from this.A more complex use case may be perhaps to have a ftplugin look for a
.. highlight::
(set default highlighting language) and set the config appropriately, but that's more hypothetical.The text was updated successfully, but these errors were encountered: