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 7.9KB

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