about summary refs log tree commit diff
path: root/cfgfiles
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2014-10-13 06:15:48 +0200
committeraszlig <aszlig@redmoonstudios.org>2014-10-13 06:17:50 +0200
commite804bebf8cdd8ac467696a1c5de04fcd39703e71 (patch)
tree52419552c1b15ee97fe8a57843570815d2ecee99 /cfgfiles
parent37a57d2753f84c809a470693ad3afb6c4e791ade (diff)
cfgfiles: Add vim configuration without plugins.
Yep, it's only a rudimentary configuration without any plugins yet,
because so far I've been using VAM to manage plugins but in the end I
want to have them consistent among all my machines.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'cfgfiles')
-rw-r--r--cfgfiles/vim.nix91
1 files changed, 91 insertions, 0 deletions
diff --git a/cfgfiles/vim.nix b/cfgfiles/vim.nix
new file mode 100644
index 00000000..4da0a058
--- /dev/null
+++ b/cfgfiles/vim.nix
@@ -0,0 +1,91 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+let
+  generic = ''
+    syntax on
+    colorscheme elflord
+
+    " boolean
+    set nocompatible
+    set showcmd
+    set showmatch
+    set ignorecase
+    set smartcase
+    set incsearch
+    set modeline
+    set smarttab
+    set expandtab
+    set smartindent
+    set ruler
+
+    " non-boolean
+    set tabstop=4
+    set softtabstop=4
+    set shiftwidth=4
+    set textwidth=80
+    set termencoding=ascii
+    set backspace=indent,eol,start
+    set background=dark
+  '';
+
+  plugin = ''
+    " erlang
+    let erlang_folding = 0
+    let erlang_highlight_bif = 1
+    let erlang_force_use_vimerl_indent = 1
+
+    " python
+    let python_highlight_numbers = 1
+    let python_highlight_builtins = 1
+    let python_highlight_exceptions = 1
+  '';
+
+  autocmd = ''
+    " jump to last position
+    au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") |
+                   \ exe "normal! g'\"zz" | endif
+
+    " filetype defaults
+    filetype plugin indent on
+    au BufNewFile,BufRead *.as set filetype=actionscript
+    au BufNewFile,BufRead *.html set tabstop=4|set shiftwidth=4|set expandtab
+    au FileType python set textwidth=79
+    au FileType gitcommit set textwidth=72
+
+    " highlight unnecessary whitespace
+    highlight ExtraWhitespace ctermbg=red guibg=red
+    match ExtraWhitespace /\s\+$/
+    au BufWinEnter,InsertLeave * match ExtraWhitespace /\s\+$/
+    au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
+    " prevent colorscheme from overriding these highlights
+    au ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
+
+    " highlight everything exceeding 80 characters
+    au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
+  '';
+
+  misc = ''
+    " ASCII art mode
+    fun! AAMode()
+      highlight clear ExtraWhitespace
+      for m in getmatches()
+        if m.group == 'ErrorMsg' && m.pattern == '\%>80v.\+'
+          call matchdelete(m.id)
+        endif
+      endfor
+    endfun
+
+    " flake everything that has been *detected* as python (not just by suffix).
+    autocmd BufWritePost * if &ft ==# 'python' | call Flake8() | endif
+  '';
+
+in pkgs.writeText "vimrc" ''
+  ${generic}
+  ${plugin}
+
+  if has("autocmd")
+    ${autocmd}
+  endif
+
+  ${misc}
+''