Skip to content

Commit

Permalink
Add a minor indentation rule for multi-line strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Sutic committed Nov 16, 2014
1 parent d9c94d5 commit 771a2a4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog # Changelog


### master ### master
- add a minor indentation rule for multi-line strings.


### v2.3.0, 2014-11-16 ### v2.3.0, 2014-11-16
- add `g!` - add `g!`
Expand Down
48 changes: 48 additions & 0 deletions indent/tmux.vim
@@ -0,0 +1,48 @@
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
let b:current_indent = "tmux"

setlocal nosmartindent

setlocal indentexpr=GetTmuxIndent()

setlocal indentkeys=o

" Only define the function once.
if exists("*GetTmuxIndent")
finish
endif

let s:cpo_save = &cpo
set cpo&vim

function! s:highlight_group(line, col)
return synIDattr(synID(a:line, a:col, 1), "name")
endfunction

function! s:prev_line_ends_with_open_string(lnum)
if a:lnum > 1
let prev_line_len = len(getline(a:lnum - 1))
if s:highlight_group(a:lnum - 1, prev_line_len) ==# 'tmuxString'
return 1
endif
endif
return 0
endfunction

function! GetTmuxIndent()
" If the string is not closed and was previously indented, then keep the
" indentation.
if s:prev_line_ends_with_open_string(v:lnum)
return indent('.')
else
return 0
endif
endfunction

let &cpo = s:cpo_save
unlet s:cpo_save

" vim:set sw=2 sts=2 ts=8 et:

0 comments on commit 771a2a4

Please sign in to comment.