NixOps repo for mcwhirter.io
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vim.nix 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. with import <nixpkgs> {};
  2. vim_configurable.customize {
  3. name = "vim"; # Specifies the vim binary name.
  4. # Below you can specify what usually goes into `~/.vimrc`
  5. vimrcConfig.customRC = ''
  6. " Preferred global default settings:
  7. set number " Enable line numbers by default
  8. set smartindent " Automatically insert extra level of indentation
  9. set tabstop=4 " Default tabstop
  10. set shiftwidth=4 " Default indent spacing
  11. set expandtab " Expand [TABS] to spaces
  12. syntax enable " Enable syntax highlighting
  13. colorscheme solarized " Set the default colour scheme
  14. set t_Co=256 " Use 265 colors in vim
  15. set spell spelllang=en_au " Defaul spell checking language
  16. hi clear SpellBad " Clear any unwanted default settings
  17. hi SpellBad cterm=underline " Set the spell checking highlight style
  18. hi SpellBad ctermbg=NONE " Set the spell checking highlight background
  19. match ErrorMsg '\s\+$' "
  20. let g:airline_powerline_fonts = 1 " Use powerline fonts
  21. let g:airline_theme='solarized' " Set the airline theme
  22. "call togglebg#map("<F10>") " Toggle background colour between dark|light
  23. set laststatus=2 " Set up the status line so it's coloured and always on
  24. " Removes trailing spaces:
  25. function! TrimWhiteSpace()
  26. %s/\s\+$//e
  27. endfunction
  28. nnoremap <silent> <Leader>RemoveTrailingWhiteSpace :call TrimWhiteSpace()<CR>
  29. autocmd FileWritePre * :call TrimWhiteSpace()
  30. autocmd FileAppendPre * :call TrimWhiteSpace()
  31. autocmd FilterWritePre * :call TrimWhiteSpace()
  32. autocmd BufWritePre * :call TrimWhiteSpace()
  33. " Solarized light during the day, solarized dark during the night
  34. let hour = strftime("%H")
  35. if 7 <= hour && hour < 17
  36. set background=light
  37. else
  38. set background=dark
  39. endif
  40. " Transparent editing of gpg encrypted files.
  41. " By Wouter Hanegraaff <wouter@blub.net>
  42. augroup encrypted
  43. au!
  44. " First make sure nothing is written to ~/.viminfo while editing an encrypted file.
  45. autocmd BufReadPre,FileReadPre *.gpg set viminfo=
  46. " We don't want a swap file, as it writes unencrypted data to disk
  47. autocmd BufReadPre,FileReadPre *.gpg set noswapfile
  48. " Switch to binary mode to read the encrypted file
  49. autocmd BufReadPre,FileReadPre *.gpg set bin
  50. autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
  51. autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
  52. " Switch to normal mode for editing
  53. autocmd BufReadPost,FileReadPost *.gpg set nobin
  54. autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
  55. autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
  56. " Convert all text to encrypted text before writing
  57. autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
  58. " Undo the encryption so we are back in the normal text, directly
  59. " after the file has been written.
  60. autocmd BufWritePost,FileWritePost *.gpg u
  61. augroup END
  62. " Add files ending in md to the list of files recognised as markdown:
  63. autocmd BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
  64. " My Markdown environment
  65. function! MarkdownSettings()
  66. set textwidth=79
  67. set spell spelllang=en_au
  68. endfunction
  69. autocmd BufNewFile,BufFilePre,BufRead *.mdwn :call MarkdownSettings()
  70. autocmd BufNewFile,BufFilePre,BufRead *.md :call MarkdownSettings()
  71. " My ReStructured Text environment
  72. function! ReStructuredSettings()
  73. set textwidth=79
  74. set spell spelllang=en_au
  75. endfunction
  76. autocmd BufNewFile,BufFilePre,BufRead *.rst :call ReStructuredSettings()
  77. autocmd BufNewFile,BufFilePre,BufRead *.txt :call ReStructuredSettings()
  78. " My LaTeX environment:
  79. function! LaTeXSettings()
  80. set textwidth=79
  81. set spell spelllang=en_au
  82. endfunction
  83. autocmd BufNewFile,BufFilePre,BufRead *.tex :call LaTeXSettings()
  84. " Settings for my Haskell environment:
  85. function! HaskellSettings()
  86. set tabstop=4
  87. set shiftwidth=4
  88. set expandtab
  89. set textwidth=79
  90. endfunction
  91. autocmd BufNewFile,BufFilePre,BufRead *.hs :call HaskellSettings()
  92. " Settings for my Nix environment:
  93. function! NixSettings()
  94. set tabstop=2
  95. set shiftwidth=2
  96. set expandtab
  97. set textwidth=79
  98. set filetype=nix
  99. endfunction
  100. autocmd BufNewFile,BufFilePre,BufRead *.nix :call NixSettings()
  101. " Settings for my Golang environment:
  102. function! GoSettings()
  103. set tabstop=7
  104. set shiftwidth=7
  105. set noexpandtab
  106. endfunction
  107. autocmd BufNewFile,BufFilePre,BufRead *.go :call GoSettings()
  108. " Settings for my Python environment:
  109. function! PythonSettings()
  110. set tabstop=4
  111. set shiftwidth=4
  112. set expandtab
  113. set textwidth=79
  114. set spell!
  115. endfunction
  116. autocmd BufNewFile,BufFilePre,BufRead *.py :call PythonSettings()
  117. " My Mutt environment
  118. function! MuttSettings()
  119. set textwidth=79
  120. set spell spelllang=en_au
  121. "set tabstop=4
  122. "set shiftwidth=4
  123. "set expandtab
  124. endfunction
  125. autocmd BufNewFile,BufFilePre,BufRead /tmp/mutt-* :call MuttSettings()
  126. autocmd BufNewFile,BufFilePre,BufRead /tmp/neomutt-* :call MuttSettings()
  127. " Settings for my C environment:
  128. function! CSettings()
  129. set tabstop=2
  130. set shiftwidth=2
  131. set expandtab
  132. set textwidth=79
  133. endfunction
  134. autocmd BufNewFile,BufFilePre,BufRead *.c :call CSettings()
  135. " Settings for my YAML environment:
  136. function! YAMLSettings()
  137. set tabstop=2
  138. set shiftwidth=2
  139. set expandtab
  140. set textwidth=79
  141. endfunction
  142. autocmd BufNewFile,BufFilePre,BufRead *.yaml :call YAMLSettings()
  143. " Settings for my Bash environment:
  144. function! BashSettings()
  145. set tabstop=4
  146. set shiftwidth=4
  147. set expandtab
  148. set textwidth=79
  149. set spell!
  150. endfunction
  151. autocmd BufNewFile,BufFilePre,BufRead *.sh :call BashSettings()
  152. " My Bzr commit environment
  153. function! BzrSettings()
  154. set textwidth=79
  155. set spell spelllang=en_au
  156. set tabstop=4
  157. set shiftwidth=4
  158. set expandtab
  159. endfunction
  160. autocmd BufNewFile,BufFilePre,BufRead bzr_* :call BzrSettings()
  161. '';
  162. # store your plugins in Vim packages
  163. vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
  164. start = [ # Plugins loaded on launch
  165. airline # Lean & mean status/tabline for vim that's light as air
  166. ctrlp # Full path fuzzy file, buffer, mru, tag, ... finder for Vim
  167. ghc-mod-vim # Happy Haskell programming on Vim, powered by ghc-mod
  168. neco-ghc # Completion plugin for Haskell, using ghc-mod
  169. neocomplete-vim # Keyword completion system
  170. nerdcommenter # Comment functions so powerful—no comment necessary
  171. nerdtree # File system explorer
  172. nerdtree-git-plugin # Plugin for nerdtree showing git status
  173. snipmate # Concise vim script implementing TextMate's snippets features
  174. solarized # Solarized colours for Vim
  175. supertab # Allows you to use <Tab> for all your insert completion
  176. syntastic # Syntax checking hacks
  177. tabular # Script for text filtering and alignment
  178. vim-airline-themes # Collection of themes for airline
  179. vim-nix # Support for writing Nix expressions in vim
  180. vimproc # Interactive command execution required by ghc-mod-vim
  181. ];
  182. # manually loadable by calling `:packadd $plugin-name`
  183. # opt = [ phpCompletion elm-vim ];
  184. # To automatically load a plugin when opening a filetype, add vimrc lines like:
  185. # autocmd FileType php :packadd phpCompletion
  186. };
  187. }