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.6KB

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