Skip to content

Commit

Permalink
skip indentation for single line comments
Browse files Browse the repository at this point in the history
In certain cases (like visual block mode) the indentation rules can
apply before the syntax updates, resulting in incorrect indentation and
weird insertion behaviour.

Fixes NixOS#13
  • Loading branch information
LnL7 committed Feb 25, 2018
1 parent 71ec774 commit 1e32fe7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions indent/nix.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ function! GetNixIndent()
return 0
endif

" Skip indentation for single line comments explicitly, in case a
" comment was just inserted (eg. visual block mode)
if getline(v:lnum) =~ '^\s*#'
return indent(v:lnum)
endif

if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax
let current_line = getline(v:lnum)
let last_line = getline(lnum)
Expand Down

0 comments on commit 1e32fe7

Please sign in to comment.