Add org_clean_folds option
This commit is contained in:
1
TODO
1
TODO
@@ -1,7 +1,6 @@
|
||||
MAYBE:
|
||||
- Better link syntax highlighting (more similar to links in vim-markdown)
|
||||
- Syntax highlight bullets and checkboxes
|
||||
- Option to enable/disable folding (similar to g:markdown_folding)
|
||||
- Different syntax group for heading delimiters
|
||||
- Change log in Vim doc
|
||||
|
||||
|
||||
@@ -4,9 +4,23 @@
|
||||
" License: Vim (see `:help license`)
|
||||
" Location: autoload/org.vim
|
||||
" Website: https://github.com/axvr/org.vim
|
||||
" Last Change: 2019-09-22
|
||||
" Last Change: 2020-01-04
|
||||
|
||||
" Fallback chain for options. Buffer local --> Global --> default.
|
||||
function org#option(name, default)
|
||||
function org#option(name, default) abort
|
||||
return get(b:, a:name, get(g:, a:name, a:default))
|
||||
endfunction
|
||||
|
||||
" Emacs-like fold text.
|
||||
function org#fold_text() abort
|
||||
return getline(v:foldstart) . '...'
|
||||
endfunction
|
||||
|
||||
" Check fold depth of a line.
|
||||
function org#fold_expr()
|
||||
let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=')
|
||||
if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') =~# '\m^o\(rg\|utline\)Heading'
|
||||
return ">" . l:depth
|
||||
endif
|
||||
return "="
|
||||
endfunction
|
||||
|
||||
39
doc/org.txt
39
doc/org.txt
@@ -106,6 +106,23 @@ following command.
|
||||
==============================================================================
|
||||
4. CONFIGURATION *org-configuration*
|
||||
|
||||
*org-folding*
|
||||
|
||||
To control how Org.vim handles folding, just use the standard Vim |folding|
|
||||
options and commands.
|
||||
|
||||
For example if you want to enable or disable folding, use 'foldenable'.
|
||||
>
|
||||
autocmd FileType org,outline setlocal nofoldenable
|
||||
<
|
||||
Or if you want folding enabled and all folds opened by default, use
|
||||
'foldlevelstart'.
|
||||
>
|
||||
autocmd FileType org,outline setlocal foldenable foldlevelstart=99
|
||||
<
|
||||
For more information on folding in Vim, refer to |fold.txt|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'b:org_state_keywords'* *'g:org_state_keywords'*
|
||||
Value: list of strings~
|
||||
Default: ['TODO', 'NEXT', 'DONE']~
|
||||
@@ -149,6 +166,26 @@ an |autocmd| like so.
|
||||
>
|
||||
autocmd FileType org setlocal conceallevel=2 concealcursor=nc
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'b:org_clean_folds'* *'g:org_clean_folds'*
|
||||
Value: numeric~
|
||||
Default: 0~
|
||||
|
||||
Vim's default styling for folds is quite ugly. Enabling this option will
|
||||
remove much of the visual noise and suffix the folded heading text with an
|
||||
ellipsis (`...`) making folds look the same as they do in Emacs' Org mode (and
|
||||
Outline mode).
|
||||
>
|
||||
* Heading 1...
|
||||
<
|
||||
This option can be enabled for all buffers like so:
|
||||
>
|
||||
let g:org_clean_folds = 1
|
||||
<
|
||||
Alternatively it can be enabled for specific buffers:
|
||||
>
|
||||
let b:org_clean_folds = 1
|
||||
<
|
||||
------------------------------------------------------------------------------
|
||||
*'b:org_use_italics'* *'g:org_use_italics'*
|
||||
Value: numeric~
|
||||
@@ -180,7 +217,7 @@ works are:
|
||||
|
||||
Org.vim is distributed under the same terms as Vim itself.
|
||||
|
||||
Copyright (c) 2018-2019, Alex Vear.
|
||||
Copyright (c) 2018-2020, Alex Vear.
|
||||
|
||||
A copy of the full licence text should have been provided with this extension
|
||||
in the `LICENCE` file. The license can also be viewed on the web [3] or by
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
" License: Vim (see `:help license`)
|
||||
" Location: ftplugin/org.vim
|
||||
" Website: https://github.com/axvr/org.vim
|
||||
" Last Change: 2019-09-22
|
||||
" Last Change: 2020-01-04
|
||||
"
|
||||
" Reference Specification: Org mode manual
|
||||
" GNU Info: `$ info Org`
|
||||
@@ -12,17 +12,15 @@
|
||||
|
||||
setlocal commentstring=#%s
|
||||
|
||||
function! OrgFold()
|
||||
let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=')
|
||||
if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') =~# 'orgHeading'
|
||||
return ">" . l:depth
|
||||
endif
|
||||
return "="
|
||||
endfunction
|
||||
|
||||
setlocal foldexpr=OrgFold()
|
||||
setlocal foldexpr=org#fold_expr()
|
||||
setlocal foldmethod=expr
|
||||
|
||||
if org#option('org_clean_folds', 0)
|
||||
setlocal foldtext=org#fold_text()
|
||||
setlocal fillchars-=fold:-
|
||||
setlocal fillchars-=fold:\
|
||||
endif
|
||||
|
||||
" Conceal Org mode link syntax
|
||||
if org#option('org_conceal_links', 1)
|
||||
setlocal conceallevel=2
|
||||
|
||||
@@ -4,19 +4,17 @@
|
||||
" License: Vim (see `:help license`)
|
||||
" Location: ftplugin/outline.vim
|
||||
" Website: https://github.com/axvr/org.vim
|
||||
" Last Change: 2019-09-22
|
||||
" Last Change: 2020-01-04
|
||||
"
|
||||
" Reference Specification: GNU Emacs Manual, section 'Outline Mode'
|
||||
" GNU Info: `$ info Emacs Outline Mode`
|
||||
" Web: <https://www.gnu.org/software/emacs/manual/html_node/emacs/Outline-Mode.html>
|
||||
|
||||
function! OutlineFold()
|
||||
let l:depth = match(getline(v:lnum), '\(^\*\+\)\@<=\( .*$\)\@=')
|
||||
if l:depth > 0 && synIDattr(synID(v:lnum, 1, 1), 'name') =~# 'outlineHeading'
|
||||
return ">" . l:depth
|
||||
endif
|
||||
return "="
|
||||
endfunction
|
||||
|
||||
setlocal foldexpr=OutlineFold()
|
||||
setlocal foldexpr=org#fold_expr()
|
||||
setlocal foldmethod=expr
|
||||
|
||||
if org#option('org_clean_folds', 0)
|
||||
setlocal foldtext=org#fold_text()
|
||||
setlocal fillchars-=fold:-
|
||||
setlocal fillchars-=fold:\
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user