From 86cce3627d9cda83d80c0fc7f0f341c0b546d4f6 Mon Sep 17 00:00:00 2001 From: Alex C Date: Fri, 10 Feb 2023 12:19:30 +0000 Subject: [PATCH 1/2] Add option to choose the TOC location: left or right --- README.md | 10 ++++++++++ ftplugin/markdown.vim | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3197253..0e6980d9 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,16 @@ Try `:help concealcursor` and `:help conceallevel` for details. let g:vim_markdown_toc_autofit = 1 +### Choose TOC window location + +- `g:vim_markdown_toc_location` + + Choose location of the TOC window: left or right. + By default it's `left` + + let g:vim_markdown_toc_location = 'right' + + ### Text emphasis restriction to single-lines - `g:vim_markdown_emphasis_multiline` diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index d6e51c21..10e59859 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -392,7 +392,11 @@ function! s:Toc(...) if l:window_type ==# 'horizontal' lopen elseif l:window_type ==# 'vertical' - vertical lopen + if g:vim_markdown_toc_location ==# 'right' + vertical botright lopen + else + vertical topleft lopen + endif " auto-fit toc window when possible to shrink it if (&columns/2) > l:header_max_len && l:vim_markdown_toc_autofit == 1 " header_max_len + 1 space for first header + 3 spaces for line numbers From 8d569823e4c20bdfffc6ce1b94a9d6930c9835a4 Mon Sep 17 00:00:00 2001 From: Alex Constantino Date: Wed, 24 Apr 2024 11:28:31 +0000 Subject: [PATCH 2/2] fix failure when g:vim_markdown_toc_location is not defined --- ftplugin/markdown.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index b2a56a5d..39a895b5 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -392,7 +392,7 @@ function! s:Toc(...) if l:window_type ==# 'horizontal' lopen elseif l:window_type ==# 'vertical' - if g:vim_markdown_toc_location ==# 'right' + if exists('g:vim_markdown_toc_location') && g:vim_markdown_toc_location ==# 'right' vertical botright lopen else vertical topleft lopen