]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge pull request #70 from beyondwdq/master
authorCiro Santilli <ciro.santilli@gmail.com>
Wed, 23 Apr 2014 12:22:45 +0000 (14:22 +0200)
committerCiro Santilli <ciro.santilli@gmail.com>
Wed, 23 Apr 2014 12:22:45 +0000 (14:22 +0200)
Disable automatically inserting bullets when auto-wrapping.

indent/mkd.vim [new file with mode: 0755]
syntax/mkd.vim

diff --git a/indent/mkd.vim b/indent/mkd.vim
new file mode 100755 (executable)
index 0000000..a26ac0e
--- /dev/null
@@ -0,0 +1,46 @@
+if exists("b:did_indent") | finish | endif
+let b:did_indent = 1
+
+setlocal indentexpr=GetMkdIndent()
+setlocal nolisp
+setlocal nosmartindent
+setlocal autoindent
+
+" Only define the function once
+if exists("*GetMkdIndent") | finish | endif
+
+function! s:is_li_start(line)
+    return a:line =~ '^\s*[\*+-]'
+endfunction
+
+function! s:is_blank_line(line)
+    return a:line =~ '^$'
+endfunction
+
+function! s:prevnonblank(lnum)
+    let i = a:lnum
+    while i > 1 && s:is_blank_line(getline(i))
+        let i -= 1
+    endwhile
+    return i
+endfunction
+
+function GetMkdIndent()
+    let list_ind = 4
+    " Find a non-blank line above the current line.
+    let lnum = prevnonblank(v:lnum - 1)
+    " At the start of the file use zero indent.
+    if lnum == 0 | return 0 | endif
+    let ind = indent(lnum)
+    let line = getline(lnum)    " Last line
+    let cline = getline(v:lnum) " Current line
+    if s:is_li_start(cline) 
+        " Current line is the first line of a list item, do not change indent
+        return indent(v:lnum)
+    elseif s:is_li_start(line)
+        " Last line is the first line of a list item, increase indent
+        return ind + list_ind
+    else
+        return ind
+    endif
+endfunction
index d6233d24c99e60d29886bee18795a2b966994d6c..e10bbc33f5223a7fe5ff91e3fa33b59ce3bd7187 100644 (file)
@@ -119,6 +119,8 @@ HtmlHiLink mkdDelimiter     Delimiter
 
 " Automatically insert bullets
 setlocal formatoptions+=r
+" Do not automatically insert bullets when auto-wrapping with text-width
+setlocal formatoptions-=c
 " Accept various markers as bullets
 setlocal comments=b:*,b:+,b:-