272 lines
7.4 KiB
Nix
Executable file
272 lines
7.4 KiB
Nix
Executable file
{ pkgs
|
|
, extraPlugins ? []
|
|
, extraOptions ? ""
|
|
, ...
|
|
}:
|
|
|
|
# At first, largely adapted from:
|
|
# https://www.mpscholten.de/nixos/2016/04/11/setting-up-vim-on-nixos.html
|
|
# Changed quite a bit since
|
|
|
|
with pkgs;
|
|
|
|
let
|
|
plugins = let inherit (vimUtils) buildVimPluginFrom2Nix; in {
|
|
"vim-hcl" = buildVimPluginFrom2Nix { # created by nix#NixDerivation
|
|
name = "vim-hcl";
|
|
src = fetchgit {
|
|
url = "git://github.com/jvirtanen/vim-hcl";
|
|
rev = "c64a006facad8c3cc0f16ba324e63524932a96e7";
|
|
sha256 = "0547xgbk725rnib8ka775a8r57dlywkyw1kjwma78n93h64dwnlr";
|
|
};
|
|
dependencies = [];
|
|
};
|
|
"systemd-syntax" = buildVimPluginFrom2Nix { # created by nix#NixDerivation
|
|
name = "systemd-syntax";
|
|
src = fetchgit {
|
|
url = "git://github.com/Matt-Deacalion/vim-systemd-syntax";
|
|
rev = "394a516f524e74ac8808ede1496b25d8b9824827";
|
|
sha256 = "0fqk5fxrdf8nazic244ia4bi75midmpj896vdkdmxnv563lnhkcy";
|
|
};
|
|
dependencies = [];
|
|
};
|
|
"opencl-syntax" = buildVimPluginFrom2Nix { # created by nix#NixDerivation
|
|
name = "opencl-syntax";
|
|
src = fetchgit {
|
|
url = "git://github.com/petRUShka/vim-opencl";
|
|
rev = "7668b018fe9461c6b51e0b736ed84aa84d6bafce";
|
|
sha256 = "0z8qasymkkaa272bjxmkp4sgd8qr4ypcqxlyzxgh5imp3gmrc6n1";
|
|
};
|
|
dependencies = [];
|
|
};
|
|
"vim-gnupg" = buildVimPluginFrom2Nix { # created by nix#NixDerivation
|
|
name = "vim-gnupg";
|
|
src = fetchFromGitHub {
|
|
owner = "jamessan";
|
|
repo = "vim-gnupg";
|
|
rev = "f663d0e857bd88cb39c16ca45c37a27488648562";
|
|
sha256 = "0y0g3br54sj0h8s6ashny2km2260qw8psqxq00jn0l2chjwsi0d9";
|
|
};
|
|
dependencies = [];
|
|
};
|
|
vim-timedot = buildVimPluginFrom2Nix {
|
|
pname = "vim-timedot";
|
|
version = "2019-10-08";
|
|
src = fetchFromGitHub {
|
|
owner = "jpotier";
|
|
repo = "vim-timedot";
|
|
rev = "ab48ee1002e25ae705dd84bb3db8b88bb0c2dc93";
|
|
sha256 = "0vgga3fmppb71apd31bwji98d62vs1p77c1hssshmh2fc7yck6s8";
|
|
};
|
|
};
|
|
vim-selinux = buildVimPluginFrom2Nix {
|
|
name = "vim-selinux";
|
|
src = fetchFromGitHub {
|
|
owner = "lzap";
|
|
repo = "vim-selinux";
|
|
rev = "735743a3539431c33824cb432b92267a0fc82251";
|
|
sha256 = "16pk2zscyiayfccn760p2zki4cjfhp26bikisgswjg900zwr5yns";
|
|
};
|
|
};
|
|
vim-lilypond = buildVimPluginFrom2Nix { # created by nix#NixDerivation
|
|
name = "vim-lilypond";
|
|
src = "${pkgs.lilypond.outPath}/share/lilypond/${pkgs.lilypond.version}/vim";
|
|
dependencies = [];
|
|
};
|
|
}; in vim_configurable.customize {
|
|
name = "vim";
|
|
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; with plugins; {
|
|
# loaded on launch
|
|
start = [
|
|
calendar-vim
|
|
dhall-vim
|
|
editorconfig-vim
|
|
fzf-vim
|
|
fzfWrapper
|
|
goyo
|
|
gundo
|
|
nerdtree
|
|
opencl-syntax
|
|
repeat
|
|
surround
|
|
systemd-syntax
|
|
vim-abolish
|
|
vim-airline
|
|
vim-airline-themes
|
|
vim-better-whitespace
|
|
vim-gnupg
|
|
vim-hcl
|
|
vim-ledger
|
|
vim-lilypond
|
|
vim-nix
|
|
vim-orgmode
|
|
vim-selinux
|
|
vim-speeddating
|
|
vim-terraform
|
|
vim-timedot
|
|
vimtex
|
|
vimwiki
|
|
] ++ extraPlugins;
|
|
# manually loadable by calling `:packadd $plugin-name`
|
|
opt = [
|
|
];
|
|
# To automatically load a plugin when opening a filetype, add vimrc lines like:
|
|
# autocmd FileType php :packadd phpCompletion
|
|
};
|
|
vimrcConfig.customRC = ''
|
|
" Must have for vim
|
|
set nocompatible
|
|
|
|
" Display nbsp
|
|
set listchars=tab:\|\ ,nbsp:·
|
|
set list
|
|
|
|
" Remap ESC on ,,
|
|
map ,, <ESC>
|
|
imap ,, <ESC>
|
|
|
|
scriptencoding utf-8
|
|
|
|
" Must be *after* pathogen (not using pathogen anymore)
|
|
filetype plugin indent on
|
|
|
|
" Leader
|
|
let mapleader=","
|
|
nnoremap <leader>a :echo("\<leader\> works! It is set to <leader>")<CR>
|
|
" let maplocalleader = "-"
|
|
|
|
" Highlighting
|
|
syntax enable
|
|
if has('gui_running')
|
|
" When gui is running, it pretty much sets its own colors
|
|
set guifont=Victor\ Mono\ 14
|
|
set notitle
|
|
set guioptions=a
|
|
else
|
|
" If we're in a terminal, then we stay default, terminal will choose
|
|
" which colors it likes.
|
|
endif
|
|
|
|
|
|
" Set line numbering
|
|
set number
|
|
|
|
" Don't wrap lines, it's ugly
|
|
set nowrap
|
|
|
|
" Deal with tabs
|
|
set softtabstop=2
|
|
set tabstop=2 " 1 tab = 2 spaces
|
|
set shiftwidth=2 " Indent with 2 spaces
|
|
set expandtab " Insert spaces instead of tabs
|
|
|
|
" Set par as default wrapper
|
|
set formatprg=${par.outPath}/bin/par\ -w80
|
|
|
|
" Set mouse on
|
|
set mouse=a
|
|
|
|
" Don't set timeout - this breaks the leader use
|
|
set notimeout
|
|
set ttimeout
|
|
|
|
" Color lines in a different shade up to 80 columns
|
|
let &colorcolumn=join(range(81,999),",")
|
|
|
|
" automatically jump to the end of the text you just copied/pasted:
|
|
xnoremap <silent> y y`]
|
|
nnoremap <silent> yy yy`]
|
|
xnoremap <silent> p p`]
|
|
xnoremap <silent> P P`]
|
|
nnoremap <silent> p p`]
|
|
nnoremap <silent> P P`]
|
|
|
|
" vimtex options
|
|
let g:vimtex_fold_enabled=1
|
|
let g:vimtex_fold_manual=1
|
|
let g:vimtex_compiler_enabled=0
|
|
let g:tex_flavor = 'latex'
|
|
|
|
" conceal to unicode symbols
|
|
nnoremap <leader>l :silent let &conceallevel = (&conceallevel+1)%4<CR>
|
|
set conceallevel=0
|
|
set concealcursor=nvc
|
|
let g:tex_conceal="abdmgs"
|
|
|
|
" nice pluginless stuff
|
|
set path+=**
|
|
set wildmenu
|
|
|
|
" Tag generation
|
|
command! MakeTags !${universal-ctags}/bin/ctags -R .
|
|
|
|
" Less noise in netrw
|
|
let g:netrw_altv=1
|
|
let g:netrw_banner=0
|
|
let g:netrw_browse_split=4
|
|
let g:netrw_list_hide=netrw_gitignore#Hide()
|
|
let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+'
|
|
let g:netrw_liststyle=3
|
|
let g:netrw_winsize=25
|
|
|
|
" Normal backspace
|
|
set backspace=indent,eol,start
|
|
|
|
" Set filetype tex for tikz files
|
|
au BufNewFile,BufRead *.tikz set filetype=tex
|
|
|
|
" vimwiki stuff
|
|
let g:vimwiki_global_ext = 0
|
|
let g:vimwiki_conceallevel = 0
|
|
let g:vimwiki_auto_chdir = 1
|
|
let g:vimwiki_list = [
|
|
\{'path': '~/zk/'},
|
|
\{'path': '~/vimwiki/personal.wiki'}
|
|
\]
|
|
:autocmd FileType vimwiki map <leader>d :VimwikiMakeDiaryNote
|
|
:autocmd FileType vimwiki Goyo 80x20
|
|
|
|
function! ToggleCalendar()
|
|
execute ":Calendar"
|
|
if exists("g:calendar_open")
|
|
if g:calendar_open == 1
|
|
execute "q"
|
|
unlet g:calendar_open
|
|
else
|
|
g:calendar_open = 1
|
|
end
|
|
else
|
|
let g:calendar_open = 1
|
|
end
|
|
endfunction
|
|
:autocmd FileType vimwiki map <leader>c :call ToggleCalendar()
|
|
|
|
" Thx Mats for the following
|
|
:cnoremap <C-A> <Home>
|
|
:cnoremap <C-B> <Left>
|
|
:cnoremap <C-F> <Right>
|
|
:cnoremap <C-E> <End>
|
|
|
|
" NERDTree when starting
|
|
"autocmd vimenter * NERDTree
|
|
let g:NERDTreeDirArrowExpandable = '+'
|
|
let g:NERDTreeDirArrowCollapsible = '-'
|
|
|
|
" SmartCase (only search by case if capital letter is used)
|
|
set ignorecase
|
|
set smartcase
|
|
|
|
" Allow for more than 10 tabs to be opened at once
|
|
set tabpagemax=40
|
|
|
|
" Help ledger
|
|
let g:ledger_bin = '${hledger}/bin/hledger'
|
|
let g:ledger_extra_options = '--pedantic --explicit --check-payees'
|
|
|
|
" Virtual Edit maaan
|
|
set ve=block
|
|
|
|
" Extra options
|
|
${extraOptions}
|
|
'';
|
|
}
|