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.

227 lines
8.7KB

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