Skip to content

Commit

Permalink
The indent for shifting lists should based on the parent/child list i…
Browse files Browse the repository at this point in the history
…tem length.
  • Loading branch information
gu-fan committed Jun 30, 2012
1 parent df426fd commit 7e19b53
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 111 deletions.
94 changes: 56 additions & 38 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Intro
=====

:Author: Rykka G.Forest
:Date: 2012-06-29 10:38:56
:Date: 2012-07-01 02:59:36
:Version: 0.66
:Github: https://github.com/Rykka/riv.vim

Expand All @@ -14,7 +14,6 @@ or writing documents in a neat way.

.. _reStructuredText: http://docutils.sourceforge.net/rst.html


Screenshot
----------

Expand Down Expand Up @@ -109,11 +108,11 @@ See Changelog in doc/riv_log.rst

* 0.65:

+ DONE 2012-06-27 take care of the slash of directory in windows .
+ TODO 2012-07-01 take care of the slash of directory in windows .
+ FIXED 2012-06-28 correct cursor position when creating todo items and list items.
+ FIXED 2012-06-28 link highlight group removed after open another buffer.
+ FIXED 2012-06-28 auto mkdir when write file to disk
+ DONE 2012-06-28 format the scratch index, sort with year/month/day
+ DONE 2012-06-28 format the scratch index, sort with year/month/day

This
~~~~~
Expand All @@ -139,10 +138,13 @@ Things todo in this version.
jumping and highlighting.
:Highlighting_: DONE 2012-07-01 4dc853c1_ fix doctest highlighting
:Table_: DONE 2012-07-01 38a8cebb_ Support simple table folding.
:Documents_: DONE 2012-07-01 help doc use doc/riv.rst which is link of README.rst
:Documents_: DONE 2012-07-01 Add reStructuredText hint and link in instructions
:Indent_: DONE 2012-07-01 The indent for shifting lists should based on
the parent/child list item length.

.. _38a8cebb:
https://github.com/Rykka/riv.vim/commit/38a8cebbc69f018cbc7caafa26473e2aee2dbe94

.. _4dc853c1:
https://github.com/Rykka/riv.vim/commit/4dc853c132848872810fdc549df3dc429f31fa56
.. _69555b21:
Expand All @@ -164,15 +166,13 @@ Things todo in next versions.
Maybe a sphinx doc ref as well.
:Documents_: Document part: options / commands.
:Documents_: Sreencast and screenshot of intro.
:Documents_: Seperate instruction and intro. help use instruction.rst
:Documents_: Add Specification/Intro of reStructuredText.
:Publish_: An option to enable highlighting todo items.
:Helpers_: An option Helper and option cache.
Let people use it even without touching ``.vimrc`` .
:Scratch_: Show Scratch sign in Calendar.
:Helpers_: A command helper?
:Links_: Link tags infile ?
:Links_: Github flavor: commit link, issue link?
:Links_: Link tags between files?
:Links_: Github flavor: create commit link, issue link?
:Todos_: Todo item priorities?
:Table_: Support simple table format?
:Table_: Support column span?
Expand All @@ -181,6 +181,10 @@ Things todo in next versions.
:Sections_: Adjust section level.
:Sections_: Shortcut to add sections references like the content directive?
:Folding_: A buf parser write in python for performance?
:Indent_: <Tab> should act when as <Bs> when indenting
:Indent_: The content space for field list should align with prev field list.
:Indent_: A command to format the indent of lists.


.. _Documents: Intro_

Expand All @@ -191,14 +195,23 @@ Instruction

* How to use?

+ For writing reStructuredText documents in a neat way.
+ If you are not familiar with reStructuredText, see QuickStart__

__ http://docutils.sourceforge.net/docs/user/rst/quickstart.html
..
+ For writing documents,

When editing an reStructuredText document (``*.rst`` ),
these settings will be automatically on.

These settings will be automatically on.
(make sure ``filetype on`` in your vimrc)

+ For managing documents in a wiki way, you should setup a project first,
see Project_.
See detail instruction in `For reStructuredText`_

+ For managing documents,

See detail instruction in `For Riv`_

* About the mapping

Expand All @@ -215,35 +228,36 @@ Instruction
+ ``g:riv_buf_leader`` : leader map for reStructuredText buffers.
+ ``g:riv_buf_ins_leader`` : leader map for reStructuredText buffers's insert mode.


For reStructuredText
--------------------

These features are for all reStructuredText files.

If you are not familiar with it, see QuickStart__

__ http://docutils.sourceforge.net/docs/user/rst/quickstart.html
These features are in all reStructuredText files.

Sections
~~~~~~~~~

Section levels and numbers are auto detected.
The section number will be shown when folded.

* Actions:

Normal and Insert:
Normal and Insert Mode

+ Create:

+ Create: Use ``:RivTitle1`` ``<C-E>s1`` ... ``:RivTitle6`` ``<C-E>s6`` ,
Use ``:RivTitle1`` ``<C-E>s1`` ... ``:RivTitle6`` ``<C-E>s6`` ,
To create level 1 to level 6 section title from current word.

If it's empty, you will be asked to input one.

+ Folding:

Pressing ``<Enter>`` or double clicking on section title will toggle the folding
of the section.

The section number will be shown when folded.

+ Jumping:

Clicking on the section reference will bring you to the section title.

e.g. Features_ link will bring you to the `Feature` Section (in vim)
Expand Down Expand Up @@ -298,10 +312,10 @@ Auto numbered and auto leveled bullet and enumerated list.
You can use any of them as a list item, but the changing sequence is hard coded.

This means when you shift right or add a child list with a ``-`` list item,
it will auto change to ``1.``
the new one will be ``1.``

And if you shift left or add a parent list item with a ``a.`` list item ,
it will auto change to ``A.``
the new one will be ``A.``

* Auto Number:

Expand Down Expand Up @@ -417,7 +431,7 @@ The Block elements of the document.
> It have a punctuation '' at the line beginning.
> The quoting characters are preserved in the processed document

They are highlighted and folded.
It's highlighted and folded.

See `Literal Blocks`__

Expand Down Expand Up @@ -480,14 +494,11 @@ __ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#doctest-bl

It's folded , and it's highlighted depending on it's role.

And for the ``code`` directives(also ``sourcecode`` and ``code-block``).
syntax highlighting is on.

You can set which languages to be highlighted by ``g:riv_highlight_code``,
default is ``lua,python,cpp,javascript,vim,sh``
See `Explicit Markup Blocks`__

And for the ``code`` directives, syntax highlighting is on.
See `code block syntax highlighting`_

__ http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#explicit-markup-blocks

Links
Expand Down Expand Up @@ -739,13 +750,16 @@ Highlighting

Improved syntax file.

* Lists Highlightings
* Code Block syntax highlighting::
* Imporoved Section,Lists,Blocks,Links Highlightings
* _`Code Block Syntax Highlighting`

for the ``code`` directives (also ``sourcecode`` and ``code-block``).
syntax highlighting is on ::
.. code:: python
# python highlighting
# github does not support syntax highlighting for rst file yet.
# github does not support syntax highlighting rendering for rst file yet.
x = [0 for i in range(100)]

You can use ``g:riv_highlight_code`` to set which languages to be highlighted.
Expand All @@ -755,11 +769,13 @@ Improved syntax file.
python pygments_ package must installed for ``docutils``
parsing syntax highlighting.

see http://docutils.sourceforge.net/sandbox/code-block-directive/tools/pygments-enhanced-front-ends/
See http://docutils.sourceforge.net/sandbox/code-block-directive/tools/pygments-enhanced-front-ends/

* The links under cursor are highlighted.
* The local files are highlighted by ``rstFileLink``,
you can change the color if needed.
* The links under cursor are highlighted by ``hl-difftext``
Disable it by set ``g:riv_hover_link_hl`` to 0
* Todo Item highlightings
* Todo Item are highlighted only in vim, not in converted files.

Indent
~~~~~~
Expand Down Expand Up @@ -863,7 +879,9 @@ Some wrapper to convert rst files to html/xml/latex/odt/...
For Riv
-------

These features are for the Riv Project.
These features are for documents in a Riv Project,
Though some can be used in a document without a project.
They have no full support.

Project
~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions after/syntax/rst.vim
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let s:lists = '\c%(^\s*%('
\.'|%(\d+|[#a-z]|[imlcxvd]+)[.)]'
\.'|\(%(#|\d+|[a-z]|[imlcxvd]+)\)'
\.')\s+)'
let s:datestamp = '%(\s\d{4}-\d{2}-\d{2})=%(\s\~ \d{4}-\d{2}-\d{2})='
let s:datestamp = '%(\s+\d{4}-\d{2}-\d{2})=%(\s\~ \d{4}-\d{2}-\d{2})='
exe 'syn match rstTodoBoxRegion '
\.'`\v' . s:lists . '@<='
\.'%(' . s:td_box . '|'. s:td_key .')'
Expand All @@ -74,9 +74,9 @@ exe 'syn match rstTodoBoxRegionDone '
" relink "{{{

if &background == 'light'
hi def rstFileLink guifg=#437727 gui=underline
hi def rstFileLink guifg=#437727 gui=underline ctermfg=28 cterm=underline
else
hi def rstFileLink guifg=#58A261 gui=underline
hi def rstFileLink guifg=#58A261 gui=underline ctermfg=77 cterm=underline
endif

hi def link rstTodoBoxList Include
Expand Down
20 changes: 15 additions & 5 deletions autoload/riv.vim
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ let s:default.maps = {
\'RivLinkNext' : 'call riv#link#finder("f")',
\'RivLinkPrev' : 'call riv#link#finder("b")',
\'RivLinkDBClick' : 'call riv#action#db_click(1)',
\'RivLinkEnter' : 'call riv#action#db_click(0)',
\'RivListShiftRight' : 'call riv#list#shift("+")',
\'RivListShiftLeft' : 'call riv#list#shift("-")',
\'RivListNewList' : 'call riv#list#new(0)',
Expand Down Expand Up @@ -197,7 +198,8 @@ let s:default.fold_maps = {
" c => scratch
" 2 => convert
let s:default.buf_maps = {
\'RivLinkDBClick' : [['<CR>', '<KEnter>', '<2-LeftMouse>'], '', ''],
\'RivLinkDBClick' : [['<2-LeftMouse>'], '', ''],
\'RivLinkEnter' : [['<CR>', '<KEnter>'], '', ''],
\'RivLinkOpen' : ['', 'n', 'ko'],
\'RivLinkNext' : ['<TAB>', 'n', 'kn'],
\'RivLinkPrev' : ['<S-TAB>', 'n', 'kp'],
Expand Down Expand Up @@ -517,16 +519,24 @@ if !exists("g:_riv_c")
\ '(v:val+1).".". td_key_list[v:val]')
let g:_riv_t.td_keyword_groups = map(td_key_list,
\ 's:normlist(split(v:val,'',''))')
" create a keyword index dic for query
let g:_riv_t.td_keyword_dic = {}
for i in range(len(g:_riv_t.td_keyword_groups))
for j in range(len(g:_riv_t.td_keyword_groups[i]))
" the 0 group is for td box.
let g:_riv_t.td_keyword_dic[g:_riv_t.td_keyword_groups[i][j]] = [i+1,j]
endfor
endfor
let g:_riv_p.td_keywords = '\v%('.join(s:normlist(split(g:riv_todo_keywords,'[,;]')),'|').')'

let g:_riv_t.time_fmt = "%Y-%m-%d"

let g:_riv_p.todo_box = '\v('. g:_riv_p.list_all .')(\[.\] )'
let g:_riv_p.todo_box = '\v('. g:_riv_p.list_all .')(\[.\]\s+)'
let g:_riv_p.todo_key = '\v('. g:_riv_p.list_all .')('
\ . g:_riv_p.td_keywords.' )'
\ . g:_riv_p.td_keywords.'\s+)'
" sub1 list sub2 todo box sub3 todo key
let g:_riv_p.todo_all = '\v('. g:_riv_p.list_all .')%((\[.\] )'
\ .'|('. g:_riv_p.td_keywords.' ))'
let g:_riv_p.todo_all = '\v('. g:_riv_p.list_all .')%((\[.\]\s+)'
\ .'|('. g:_riv_p.td_keywords.'\s+))'
" sub4 timestamp
let g:_riv_p.timestamp = '(\d{4}-\d{2}-\d{2}%( |$))'
let g:_riv_p.todo_tm_bgn = g:_riv_p.todo_all . g:_riv_p.timestamp
Expand Down
6 changes: 5 additions & 1 deletion autoload/riv/fold.vim
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,13 @@ fun! s:check(row) "{{{
\ && line !~ '^\.\.\_s*$'
let b:state.s_chk = {'type': 'sect' , 'bgn': a:row, 'attr': line[0]}
return 1
elseif line=~ '^__\s'
" it's anonymous link
let b:state.e_chk= {'type': 'exp', 'bgn':a:row,}
return 1
elseif line=~'^\s*\w'
return
elseif b:foldlevel > 2 && line=~s:p.exp_m
elseif b:foldlevel > 2 && (line=~s:p.exp_m )
if (line=~'^\.\.\s*$' && a:row!=line('$')
\ && b:lines[a:row+1]=~'^\s*$')
call add(b:state.matcher,{'type': 'exp', 'mark': 'ignored',
Expand Down
Loading

0 comments on commit 7e19b53

Please sign in to comment.