mio-ops/profiles/vim.nix

289 lines
12 KiB
Nix
Raw Normal View History

2021-03-19 01:53:01 +00:00
with import <nixpkgs> { overlays = [ (import ../overlays/vim-cue.nix) ]; };
2019-09-10 11:13:48 +00:00
vim_configurable.customize {
name = "vim"; # Specifies the vim binary name.
# Below you can specify what usually goes into `~/.vimrc`
vimrcConfig.customRC = ''
" Preferred global default settings:
2019-09-11 23:28:57 +00:00
set number " Enable line numbers by default
2019-09-10 11:13:48 +00:00
set smartindent " Automatically insert extra level of indentation
set tabstop=4 " Default tabstop
set shiftwidth=4 " Default indent spacing
set expandtab " Expand [TABS] to spaces
2020-01-06 02:03:32 +00:00
syntax on " Enable syntax highlighting
2020-05-27 11:58:50 +00:00
colorscheme gruvbox " Set the default colour scheme
2019-09-11 23:28:57 +00:00
set t_Co=256 " Use 265 colors in vim
2019-09-10 11:13:48 +00:00
set spell spelllang=en_au " Defaul spell checking language
2020-09-30 08:26:30 +00:00
set spellfile=~/.vim-spell.en.utf-8.add " Add the spellfile
2019-09-11 23:28:57 +00:00
hi clear SpellBad " Clear any unwanted default settings
2019-09-10 11:13:48 +00:00
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
match ErrorMsg '\s\+$' "
let g:airline_powerline_fonts = 1 " Use powerline fonts
2020-05-27 11:58:50 +00:00
let g:airline_theme='gruvbox' " Set the airline theme
2019-09-10 11:13:48 +00:00
"call togglebg#map("<F10>") " Toggle background colour between dark|light
set laststatus=2 " Set up the status line so it's coloured and always on
" Removes trailing spaces:
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
nnoremap <silent> <Leader>RemoveTrailingWhiteSpace :call TrimWhiteSpace()<CR>
autocmd FileWritePre * :call TrimWhiteSpace()
autocmd FileAppendPre * :call TrimWhiteSpace()
autocmd FilterWritePre * :call TrimWhiteSpace()
autocmd BufWritePre * :call TrimWhiteSpace()
"autocmd BufWrite * :Autoformat
2019-09-10 11:13:48 +00:00
" FIXME: Currently always set to dark due to issues with Termonad Solarized theme
2020-01-06 02:03:32 +00:00
" Light during the day, dark during the night
let hour = strftime("%H")
if 7 <= hour && hour < 17
set background=dark
"hi Normal ctermbg=none " Set a transparent background
2020-05-27 11:58:50 +00:00
"let g:airline_solarized_bg='dark' " Set the airline background
else
set background=dark
"hi Normal ctermbg=none " Set a transparent background
2020-05-27 11:58:50 +00:00
"let g:airline_solarized_bg='dark' " Set the airline background
endif
2019-09-10 11:13:48 +00:00
" Transparent editing of gpg encrypted files.
" By Wouter Hanegraaff <wouter@blub.net>
augroup encrypted
au!
" First make sure nothing is written to ~/.viminfo while editing an encrypted file.
autocmd BufReadPre,FileReadPre *.gpg set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.gpg set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.gpg set bin
autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.gpg set nobin
autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.gpg u
augroup END
2021-03-08 06:10:33 +00:00
" Manage ISO files
augroup iso
au!
" First make sure nothing is written to ~/.viminfo while editing an encrypted file.
autocmd BufReadPre,FileReadPre *.iso set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk
autocmd BufReadPre,FileReadPre *.iso set noswapfile
" Switch to binary mode to read the encrypted file
autocmd BufReadPre,FileReadPre *.iso set bin
autocmd BufReadPre,FileReadPre *.iso let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.iso '[,']!gpg --decrypt 2> /dev/null
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.iso set nobin
autocmd BufReadPost,FileReadPost *.iso let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.iso execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.iso '[,']!gpg --default-key=A4122FF3971B6865 --default-recipient-self -ae 2>/dev/null
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.iso u
augroup END
" Use persistent history.
if !isdirectory("/tmp/.vim-undo-dir")
call mkdir("/tmp/.vim-undo-dir", "", 0700)
endif
set undodir=/tmp/.vim-undo-dir
set undofile
2019-09-10 11:13:48 +00:00
" My Markdown environment
function! MarkdownSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.mdwn :call MarkdownSettings()
autocmd BufNewFile,BufFilePre,BufRead *.md :call MarkdownSettings()
" My ReStructured Text environment
function! ReStructuredSettings()
set textwidth=79
set spell spelllang=en_au
2020-09-17 01:23:25 +00:00
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
2019-09-10 11:13:48 +00:00
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rst :call ReStructuredSettings()
autocmd BufNewFile,BufFilePre,BufRead *.txt :call ReStructuredSettings()
" My LaTeX environment:
function! LaTeXSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.tex :call LaTeXSettings()
" Settings for my Haskell environment:
function! HaskellSettings()
2020-09-30 08:26:30 +00:00
set tabstop=2
set shiftwidth=2
2019-09-10 11:13:48 +00:00
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.hs :call HaskellSettings()
" Settings for my Nix environment:
function! NixSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set filetype=nix
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.nix :call NixSettings()
2021-03-19 01:53:01 +00:00
" Settings for my Cue environment:
function! CueSettings()
set tabstop=2
set shiftwidth=2
set textwidth=79
let g:cue_fmt_on_save = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cue :call CueSettings()
2021-03-19 04:25:03 +00:00
" Settings for my Rust environment:
function! RustSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
let g:rustfmt_autosave = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rs :call RustSettings()
2020-01-21 15:12:26 +00:00
" Settings for my Crystal environment:
function! CrystalSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
set filetype=crystal
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cr :call CrystalSettings()
2019-09-10 11:13:48 +00:00
" Settings for my Golang environment:
function! GoSettings()
set tabstop=7
set shiftwidth=7
set noexpandtab
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.go :call GoSettings()
" Settings for my Python environment:
function! PythonSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
set spell!
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.py :call PythonSettings()
" My Mutt environment
function! MuttSettings()
set textwidth=79
set spell spelllang=en_au
2020-10-10 03:49:29 +00:00
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
2019-09-10 11:13:48 +00:00
endfunction
2020-10-10 03:49:29 +00:00
autocmd BufNewFile,BufFilePre,BufRead mutt-* :call MuttSettings()
autocmd BufNewFile,BufFilePre,BufRead neomutt-* :call MuttSettings()
2019-09-10 11:13:48 +00:00
" Settings for my C environment:
function! CSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.c :call CSettings()
" Settings for my YAML environment:
function! YAMLSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
2020-09-17 01:23:25 +00:00
set spell spelllang=en_au
hi clear SpellBad " Clear any unwanted default settings
hi SpellBad cterm=underline " Set the spell checking highlight style
hi SpellBad ctermbg=NONE " Set the spell checking highlight background
2019-09-10 11:13:48 +00:00
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.yaml :call YAMLSettings()
2020-09-17 01:23:25 +00:00
autocmd BufNewFile,BufFilePre,BufRead *.yml :call YAMLSettings()
2019-09-10 11:13:48 +00:00
" Settings for my Bash environment:
function! BashSettings()
set tabstop=4
set shiftwidth=4
set expandtab
set textwidth=79
set spell!
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.sh :call BashSettings()
" My Bzr commit environment
function! BzrSettings()
set textwidth=79
set spell spelllang=en_au
set tabstop=4
set shiftwidth=4
set expandtab
endfunction
autocmd BufNewFile,BufFilePre,BufRead bzr_* :call BzrSettings()
'';
# store your plugins in Vim packages
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
start = [ # Plugins loaded on launch
airline # Lean & mean status/tabline for vim that's light as air
ctrlp # Full path fuzzy file, buffer, mru, tag, ... finder for Vim
2020-01-29 00:41:03 +00:00
fugitive # Vim Git wrapper
2020-01-06 02:26:14 +00:00
gruvbox # Install the gruvbox theme
2020-03-25 10:12:03 +00:00
haskell-vim # Syntax Highlighting and Indentation for Haskell
2019-09-10 11:13:48 +00:00
neocomplete-vim # Keyword completion system
nerdcommenter # Comment functions so powerful—no comment necessary
nerdtree # File system explorer
nerdtree-git-plugin # Plugin for nerdtree showing git status
2020-01-06 02:26:14 +00:00
nord-vim # Nord theme for ViM
2019-09-10 11:13:48 +00:00
snipmate # Concise vim script implementing TextMate's snippets features
solarized # Solarized colours for Vim
supertab # Allows you to use <Tab> for all your insert completion
syntastic # Syntax checking hacks
tabular # Script for text filtering and alignment
2021-03-19 04:25:03 +00:00
vim-addon-nix # Scripts assisting writing .nix files
2019-09-11 23:28:57 +00:00
vim-airline-themes # Collection of themes for airline
2021-03-19 05:13:02 +00:00
vim-autoformat # Automatically format code
2020-01-06 02:03:32 +00:00
vim-colorschemes # Collection of ViM colour schemes
2021-03-19 01:53:01 +00:00
vim-cue # Cue filetype plugin for Vim
2019-09-10 11:13:48 +00:00
vim-nix # Support for writing Nix expressions in vim
2020-03-17 00:02:54 +00:00
vim-polyglot # A solid language pack for Vim
2019-09-10 11:13:48 +00:00
];
# manually loadable by calling `:packadd $plugin-name`
# opt = [ phpCompletion elm-vim ];
# To automatically load a plugin when opening a filetype, add vimrc lines like:
# autocmd FileType php :packadd phpCompletion
};
}