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.

236 lines
9.5KB

  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 on " Enable syntax highlighting
  13. colorscheme gruvbox " 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. set spellfile=~/.vim-spell.en.utf-8.add " Add the spellfile
  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='gruvbox' " 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. " FIXME: Currently always set to dark due to issues with Termonad Solarized theme
  35. " Light during the day, dark during the night
  36. let hour = strftime("%H")
  37. if 7 <= hour && hour < 17
  38. set background=dark
  39. "hi Normal ctermbg=none " Set a transparent background
  40. "let g:airline_solarized_bg='dark' " Set the airline background
  41. else
  42. set background=dark
  43. "hi Normal ctermbg=none " Set a transparent background
  44. "let g:airline_solarized_bg='dark' " Set the airline background
  45. endif
  46. " Transparent editing of gpg encrypted files.
  47. " By Wouter Hanegraaff <wouter@blub.net>
  48. augroup encrypted
  49. au!
  50. " First make sure nothing is written to ~/.viminfo while editing an encrypted file.
  51. autocmd BufReadPre,FileReadPre *.gpg set viminfo=
  52. " We don't want a swap file, as it writes unencrypted data to disk
  53. autocmd BufReadPre,FileReadPre *.gpg set noswapfile
  54. " Switch to binary mode to read the encrypted file
  55. autocmd BufReadPre,FileReadPre *.gpg set bin
  56. autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
  57. autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
  58. " Switch to normal mode for editing
  59. autocmd BufReadPost,FileReadPost *.gpg set nobin
  60. autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
  61. autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
  62. " Convert all text to encrypted text before writing
  63. autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
  64. " Undo the encryption so we are back in the normal text, directly
  65. " after the file has been written.
  66. autocmd BufWritePost,FileWritePost *.gpg u
  67. augroup END
  68. " My Markdown environment
  69. function! MarkdownSettings()
  70. set textwidth=79
  71. set spell spelllang=en_au
  72. endfunction
  73. autocmd BufNewFile,BufFilePre,BufRead *.mdwn :call MarkdownSettings()
  74. autocmd BufNewFile,BufFilePre,BufRead *.md :call MarkdownSettings()
  75. " My ReStructured Text environment
  76. function! ReStructuredSettings()
  77. set textwidth=79
  78. set spell spelllang=en_au
  79. hi clear SpellBad " Clear any unwanted default settings
  80. hi SpellBad cterm=underline " Set the spell checking highlight style
  81. hi SpellBad ctermbg=NONE " Set the spell checking highlight background
  82. endfunction
  83. autocmd BufNewFile,BufFilePre,BufRead *.rst :call ReStructuredSettings()
  84. autocmd BufNewFile,BufFilePre,BufRead *.txt :call ReStructuredSettings()
  85. " My LaTeX environment:
  86. function! LaTeXSettings()
  87. set textwidth=79
  88. set spell spelllang=en_au
  89. endfunction
  90. autocmd BufNewFile,BufFilePre,BufRead *.tex :call LaTeXSettings()
  91. " Settings for my Haskell environment:
  92. function! HaskellSettings()
  93. set tabstop=2
  94. set shiftwidth=2
  95. set expandtab
  96. set textwidth=79
  97. endfunction
  98. autocmd BufNewFile,BufFilePre,BufRead *.hs :call HaskellSettings()
  99. " Settings for my Nix environment:
  100. function! NixSettings()
  101. set tabstop=2
  102. set shiftwidth=2
  103. set expandtab
  104. set textwidth=79
  105. set filetype=nix
  106. endfunction
  107. autocmd BufNewFile,BufFilePre,BufRead *.nix :call NixSettings()
  108. " Settings for my Crystal environment:
  109. function! CrystalSettings()
  110. set tabstop=2
  111. set shiftwidth=2
  112. set expandtab
  113. set textwidth=79
  114. set filetype=crystal
  115. endfunction
  116. autocmd BufNewFile,BufFilePre,BufRead *.cr :call CrystalSettings()
  117. " Settings for my Golang environment:
  118. function! GoSettings()
  119. set tabstop=7
  120. set shiftwidth=7
  121. set noexpandtab
  122. endfunction
  123. autocmd BufNewFile,BufFilePre,BufRead *.go :call GoSettings()
  124. " Settings for my Python environment:
  125. function! PythonSettings()
  126. set tabstop=4
  127. set shiftwidth=4
  128. set expandtab
  129. set textwidth=79
  130. set spell!
  131. endfunction
  132. autocmd BufNewFile,BufFilePre,BufRead *.py :call PythonSettings()
  133. " My Mutt environment
  134. function! MuttSettings()
  135. set textwidth=79
  136. set spell spelllang=en_au
  137. hi clear SpellBad " Clear any unwanted default settings
  138. hi SpellBad cterm=underline " Set the spell checking highlight style
  139. hi SpellBad ctermbg=NONE " Set the spell checking highlight background
  140. endfunction
  141. autocmd BufNewFile,BufFilePre,BufRead mutt-* :call MuttSettings()
  142. autocmd BufNewFile,BufFilePre,BufRead neomutt-* :call MuttSettings()
  143. " Settings for my C environment:
  144. function! CSettings()
  145. set tabstop=2
  146. set shiftwidth=2
  147. set expandtab
  148. set textwidth=79
  149. endfunction
  150. autocmd BufNewFile,BufFilePre,BufRead *.c :call CSettings()
  151. " Settings for my YAML environment:
  152. function! YAMLSettings()
  153. set tabstop=2
  154. set shiftwidth=2
  155. set expandtab
  156. set textwidth=79
  157. set spell spelllang=en_au
  158. hi clear SpellBad " Clear any unwanted default settings
  159. hi SpellBad cterm=underline " Set the spell checking highlight style
  160. hi SpellBad ctermbg=NONE " Set the spell checking highlight background
  161. endfunction
  162. autocmd BufNewFile,BufFilePre,BufRead *.yaml :call YAMLSettings()
  163. autocmd BufNewFile,BufFilePre,BufRead *.yml :call YAMLSettings()
  164. " Settings for my Bash environment:
  165. function! BashSettings()
  166. set tabstop=4
  167. set shiftwidth=4
  168. set expandtab
  169. set textwidth=79
  170. set spell!
  171. endfunction
  172. autocmd BufNewFile,BufFilePre,BufRead *.sh :call BashSettings()
  173. " My Bzr commit environment
  174. function! BzrSettings()
  175. set textwidth=79
  176. set spell spelllang=en_au
  177. set tabstop=4
  178. set shiftwidth=4
  179. set expandtab
  180. endfunction
  181. autocmd BufNewFile,BufFilePre,BufRead bzr_* :call BzrSettings()
  182. '';
  183. # store your plugins in Vim packages
  184. vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
  185. start = [ # Plugins loaded on launch
  186. airline # Lean & mean status/tabline for vim that's light as air
  187. ctrlp # Full path fuzzy file, buffer, mru, tag, ... finder for Vim
  188. fugitive # Vim Git wrapper
  189. gruvbox # Install the gruvbox theme
  190. haskell-vim # Syntax Highlighting and Indentation for Haskell
  191. neocomplete-vim # Keyword completion system
  192. nerdcommenter # Comment functions so powerful—no comment necessary
  193. nerdtree # File system explorer
  194. nerdtree-git-plugin # Plugin for nerdtree showing git status
  195. nord-vim # Nord theme for ViM
  196. snipmate # Concise vim script implementing TextMate's snippets features
  197. solarized # Solarized colours for Vim
  198. supertab # Allows you to use <Tab> for all your insert completion
  199. syntastic # Syntax checking hacks
  200. tabular # Script for text filtering and alignment
  201. vim-airline-themes # Collection of themes for airline
  202. vim-colorschemes # Collection of ViM colour schemes
  203. vim-nix # Support for writing Nix expressions in vim
  204. vim-addon-nix # Scripts assisting writing .nix files
  205. vim-polyglot # A solid language pack for Vim
  206. ];
  207. # manually loadable by calling `:packadd $plugin-name`
  208. # opt = [ phpCompletion elm-vim ];
  209. # To automatically load a plugin when opening a filetype, add vimrc lines like:
  210. # autocmd FileType php :packadd phpCompletion
  211. };
  212. }