reciproka-ops/profiles/neovim.nix

302 lines
14 KiB
Nix
Raw Permalink Normal View History

2022-08-15 07:32:25 +00:00
{pkgs, ...}: {
environment.variables = {EDITOR = "vim";};
2021-10-07 02:13:48 +00:00
environment.systemPackages = with pkgs; [
2022-08-15 07:32:25 +00:00
(
neovim.override {
vimAlias = true;
configure = {
packages.myPlugins = with pkgs.vimPlugins; {
start = [
airline # Lean & mean status/tabline for vim that's light as air
dracula-vim # Dracula theme for vim
fugitive # Vim Git wrapper
fzf-vim # Full path fuzzy file, buffer, mru, tag, finder for Vim
haskell-vim # Syntax Highlighting and Indentation for Haskell
indentLine # Display thin vertical lines at each indentation level
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
supertab # Allows you to use <Tab> for all your insert completion
syntastic # Syntax checking hacks
vim-addon-nix # Scripts assisting writing .nix files
vim-autoformat # Automatically format code
vim-cue # Cue filetype plugin for Vim
vim-lastplace
vim-markdown-toc # Generate table of contents for Markdown files
vim-nix # Support for writing Nix expressions in vim
vim-numbertoggle # Toggle between relative / absolute line numbers automatically
vim-one
];
opt = [];
};
customRC = ''
" Preferred global default settings:
set nocompatible
set backspace=indent,eol,start
set number relativenumber " Enable relative line numbers by default
set cursorline " Highlight the current line number
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
packadd! dracula-vim
syntax on " Enable syntax highlighting
set t_Co=256 " Use 265 colors in vim
set background=dark " Set the default background scheme
colorscheme dracula " Set the default colour scheme
"let g:one_allow_italics = 1 " I love italic for comments
set spell spelllang=en_au " Defaul spell checking language
set spellfile=~/.vim-spell.en.utf-8.add " Add the spellfile
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
match ErrorMsg '\s\+$' "
nnoremap <silent> <C-p> :Files<CR>
nnoremap <silent> <Leader>f :Rg<CR>
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
let g:airline_powerline_fonts = 1 " Use powerline fonts
let g:airline_theme='dracula' " Set the airline theme
"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
" Trigger for numbertoggle to switch modes
nnoremap <silent> <C-n> :set relativenumber!<CR>
" Tab settings
let g:SuperTabDefaultCompletionType = 'context'
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc','&completefunc']
let g:SuperTabRetainCompletionType=2
inoremap <expr><Enter> pumvisible() ? "\<C-Y>" : "\<Enter>"
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
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
" FIXME: Currently always set to dark due to issues with Termonad Solarized theme
" 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
"let g:airline_solarized_bg='dark' " Set the airline background
else
"set background=dark
"hi Normal ctermbg=none " Set a transparent background
"let g:airline_solarized_bg='dark' " Set the airline background
endif
" 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
" 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
" JFDIC 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()
" JFDIC ReStructured Text environment
function! ReStructuredSettings()
set textwidth=79
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
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.rst :call ReStructuredSettings()
autocmd BufNewFile,BufFilePre,BufRead *.txt :call ReStructuredSettings()
" JFDIC LaTeX environment:
function! LaTeXSettings()
set textwidth=79
set spell spelllang=en_au
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.tex :call LaTeXSettings()
" Settings for JFDIC Haskell environment:
function! HaskellSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.hs :call HaskellSettings()
" Settings for JFDIC 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()
" Settings for JFDIC Cue environment:
function! CueSettings()
set noexpandtab
set tabstop=2
set shiftwidth=2
set textwidth=79
let g:cue_fmt_on_save = 1
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.cue :call CueSettings()
" Settings for JFDIC 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()
" Settings for JFDIC 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()
" Settings for JFDIC Golang environment:
function! GoSettings()
set tabstop=7
set shiftwidth=7
set noexpandtab
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.go :call GoSettings()
" Settings for JFDIC 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()
" JFDIC Mutt environment
function! MuttSettings()
set textwidth=79
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
endfunction
autocmd BufNewFile,BufFilePre,BufRead mutt-* :call MuttSettings()
autocmd BufNewFile,BufFilePre,BufRead neomutt-* :call MuttSettings()
" Settings for JFDIC 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 JFDIC YAML environment:
function! YAMLSettings()
set tabstop=2
set shiftwidth=2
set expandtab
set textwidth=79
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
endfunction
autocmd BufNewFile,BufFilePre,BufRead *.yaml :call YAMLSettings()
autocmd BufNewFile,BufFilePre,BufRead *.yml :call YAMLSettings()
" Settings for JFDIC 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()
'';
2021-10-07 02:13:48 +00:00
};
2022-08-15 07:32:25 +00:00
}
)
];
2021-10-07 02:13:48 +00:00
}