-
-
Save taktoa/9d821622177edf159e56cca91fa405c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FIXME: replace @NIX_RUSTRACER@ and @NIX_RUSTC@ using `substituteAllInPlace` | |
# and pkgs.runCommand | |
{ pkgs }: | |
pkgs.vim_configurable.customize { | |
name = "vim"; | |
vimrcConfig = { | |
customRC = builtins.readFile ./vimrc; | |
vam.pluginDictionaries = [ { | |
names = [ | |
"YUNOcommit-vim" | |
"airline" | |
"colors-solarized" | |
"ctrlp" | |
"easy-align" | |
"easymotion" | |
"fugitive" | |
"ghcmod" | |
"gitgutter" | |
"haskellconceal" | |
"hoogle" | |
"idris-vim" | |
"latex-live-preview" | |
"lushtags" | |
"neco-ghc" | |
"nerdcommenter" | |
"nerdtree" | |
"quickfixstatus" | |
"quickrun" | |
"rainbow_parentheses" | |
"rust-vim" | |
"shabadou-vim" | |
"signature" | |
"surround" | |
"syntastic" | |
"table-mode" | |
"tabmerge" | |
"tagbar" | |
"taglist" | |
"thumbnail-vim" | |
"undotree" | |
"vim-addon-nix" | |
"vim-autoformat" | |
"vim-gista" | |
"vim-hardtime" | |
"vim-hier" | |
"vim-racer" | |
"vim-wakatime" | |
"vim-xkbswitch" | |
"vimproc-vim" | |
"vundle" | |
"watchdogs" | |
"webapi-vim" | |
"youcompleteme" | |
"vim-orgmode" | |
]; | |
} ]; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Based on https://github.com/jagajaga/my_configs/blob/master/.nixpkgs/vimrc.nix | |
set history=700 | |
set confirm | |
set cindent | |
set t_Co=256 | |
set tabpagemax=1000 | |
set colorcolumn=80 | |
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o | |
set hidden | |
vmap <Enter> <Plug>(EasyAlign) | |
nmap s <Plug>(easymotion-s2) | |
map / <Plug>(easymotion-sn) | |
omap / <Plug>(easymotion-tn) | |
map n <Plug>(easymotion-next) | |
map N <Plug>(easymotion-prev) | |
let g:calendar_google_calendar = 1 | |
let g:calendar_google_task = 1 | |
let g:gista#interactive_description = 0 | |
let NERDTreeShowHidden=1 | |
let NERDTreeQuitOnOpen=1 | |
let g:necoghc_enable_detailed_browse = 1 | |
let g:haskellmode_completion_ghc = 0 | |
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc | |
let g:YUNOcommit_after = 20 | |
let g:XkbSwitchEnabled = 1 | |
let g:XkbSwitchIMappings = ['ru'] | |
au VimEnter * RainbowParenthesesToggle | |
au Syntax * RainbowParenthesesLoadRound | |
au Syntax * RainbowParenthesesLoadSquare | |
au Syntax * RainbowParenthesesLoadBraces | |
let g:airline#extensions#branch#enabled = 1 | |
let g:airline#extensions#syntastic#enabled = 1 | |
let g:airline#extensions#ctrlp#enabled = 1 | |
let g:airline#extensions#hunks#enabled = 1 | |
let g:airline#extensions#undotree#enabled = 1 | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline_theme='dark' | |
let g:airline_powerline_fonts = 1 | |
let g:airline_detect_modified=1 | |
let g:airline_detect_paste=1 | |
" How many lines should be searched for context | |
let g:hasksyn_indent_search_backward = 100 | |
" Should we try to de-indent after a return | |
let g:hasksyn_dedent_after_return = 1 | |
" Should we try to de-indent after a catchall case in a case .. of | |
let g:hasksyn_dedent_after_catchall_case = 1 | |
let tagbar_autofocus=1 | |
let tagbar_autoclose=1 | |
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py' | |
autocmd FileType c let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/c/ycm/.ycm_extra_conf.py' | |
let g:ycm_semantic_triggers = { | |
\ 'c' : ['->', '.'], | |
\ 'cpp' : ['->', '.', '::'], | |
\ 'objc' : ['->', '.'], | |
\ 'ocaml' : ['.', '#'], | |
\ 'cpp,objcpp' : ['->', '.', '::'], | |
\ 'perl' : ['->'], | |
\ 'php' : ['->', '::'], | |
\ 'cs,java,javascript,d,vim,python,perl6,scala,vb,elixir,go' : ['.'], | |
\ 'ruby' : ['.', '::'], | |
\ 'lua' : ['.', ':'], | |
\ 'erlang' : [':'], | |
\ 'haskell' : ['.'] | |
\ } | |
nnoremap <C-E> <ESC>:YcmCompleter GoToDefinitionElseDeclaration<CR> | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlPMixed' | |
let g:ctrlp_working_path_mode = 'ra' | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux | |
"set statusline+=%#warningmsg# | |
"set statusline+=%{SyntasticStatuslineFlag()} | |
"set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:solarized_termcolors=256 | |
colorscheme solarized "desert | |
"colorscheme desert | |
set background=dark | |
let g:racer_cmd = "racer" | |
let g:racer_experimental_completer = 1 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => General | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
command WQ wq | |
command Wq wq | |
command W w | |
command Q q | |
autocmd vimenter * cd %:p:h | |
autocmd FileType cpp call CppMake() | |
function! CppMake() | |
if filereadable("Makefile") | |
set makeprg=make\ -s | |
else | |
set makeprg=clang++\ -Wall\ -g\ -std=c++11\ -o\ %<\ % | |
endif | |
endfunction | |
autocmd FileType c set makeprg=clang\ -Wall\ -g\ -o\ %<\ % | |
autocmd FileType asm set makeprg=yasm\ -g\ dwarf2\ -f\ elf32\ -o\ %<.o\ %\ &&\ gcc\ -m32\ -g\ -o\ %<\ %<.o | |
autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" | |
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m | |
autocmd BufRead *.hs set makeprg=ghc\ -O3\ --make\ % | |
autocmd BufRead *.hs map <C-D> <Esc>:%!stylish-haskell<CR><CR> | |
autocmd BufRead,BufNewFile *.rs set filetype=rust | |
autocmd FileType rust set makeprg=rustc\ % | |
"au BufWrite * :Autoformat | |
let g:formatdef_rustfmt = '"rustfmt"' | |
let g:formatters_rust = ['rustfmt'] | |
let g:racer_cmd = "@NIX_RUSTRACER@/bin/racer" | |
let $RUST_SRC_PATH="@NIX_RUSTC@/src" | |
autocmd BufRead,BufNewFile *.idr set filetype=idris | |
autocmd FileType idris set makeprg=idris\ %\ -o\ %< | |
set fencs=utf-8,cp1251,koi8-r,ucs-2,cp866 | |
au FileType qf call AdjustWindowHeight(3, 10) | |
function! AdjustWindowHeight(minheight, maxheight) | |
exe max([min([line("$")+1, a:maxheight]), a:minheight]) . "wincmd _" | |
endfunction | |
set iminsert=0 | |
set imsearch=0 | |
imap <F10> <Esc>:TagbarToggle<CR> | |
nmap <F10> <Esc>:TagbarToggle<CR> | |
imap <F11> <Esc>:NERDTreeToggle<CR> | |
nmap <F11> <Esc>:NERDTreeToggle<CR> | |
" Num strings | |
set nu! | |
set ai! | |
set cin! | |
imap <C-S-v> <S-Insert> | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
set viminfo='10,\"100,:20,%,n~/.viminfo | |
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm | |
$"|endif|endif | |
map <leader>Q :let @+ = system("pastebinit " . " -f " . &filetype . " " . expand("%"))<CR> | |
" Fast saving | |
vnoremap p "_dP | |
nnoremap <C-u> :UndotreeToggle<CR> | |
imap <F5> <Esc> :tabprev<CR> | |
nmap <leader>w :w!<cr> | |
map <F2> <Esc>:w !sudo tee %<CR> | |
imap <F2> <Esc>:w<CR> | |
imap <F4> <Esc>:browse tabnew<CR> | |
map <F4> <Esc>:browse tabnew<CR> | |
imap <F5> <Esc> :tabprev<CR> | |
map <F5> :tabprev<CR> | |
imap <F6> <Esc> :tabnext<CR> | |
map <F6> :tabnext <CR> | |
function! GAC() | |
call inputsave() | |
let commit = input('Commit message: ') | |
call inputrestore() | |
let aaa = system("git add " . expand("%") . " && git commit -m \"" . commit . "\"") | |
echom aaa | |
endfunction | |
map <F7> :call GAC() <CR> | |
let Tlist_Exit_OnlyWindow = 1 | |
" put from clipboard | |
nmap <leader>p "+p | |
map cn <ESC>:cn<CR> | |
map cb <ESC>:cp<CR> | |
" yank to clipboard | |
map <leader>m :call SaveAndInsertType()<CR> | |
map <leader>y "+y | |
map <leader>x "+x | |
func! SaveAndInsertType() | |
exec ":w" | |
exec "GhcModTypeInsert" | |
endfunc | |
imap <F8> <ESC>:w<CR><ESC>:!clear<CR><ESC>:make<CR> | |
imap <F9> <ESC>:!clear<CR><ESC>:!./%<<CR> | |
map <F8> <ESC>:w<CR><ESC>:!clear<CR><ESC>:make<CR> | |
map <F9> <ESC>:!clear<CR><ESC>:!./%<<CR> | |
map <leader><F9> :call CompileRunGcc()<CR> | |
func! CompileRunGcc() | |
exec ":w" | |
exec ":!clear" | |
exec ":!g++ -std=c++11 % -o %<" | |
exec ":! ./%<" | |
endfunc | |
autocmd FileType python nmap <F9> <ESC>:!clear<CR><ESC>:!python %<CR> | |
set wildmenu | |
set wcm=<Tab> | |
menu Exit.quit :quit<CR> | |
menu Exit.quit! :quit!<CR> | |
menu Exit.save :exit<CR> | |
map <F3> :emenu Exit.<Tab> | |
function! InsertTabWrapper(direction) | |
let col = col('.') - 1 | |
if !col || getline('.')[col - 1] !~ '\k' | |
return "\<tab>" | |
elseif "backward" == a:direction | |
return "\<c-p>" | |
else | |
return "\<c-n>" | |
endif | |
endfunction | |
inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr> | |
inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => VIM user interface | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Set 7 lines to the cursor - when moving vertically using j/k | |
set so=7 | |
" Turn on the WiLd menu | |
set wildmenu | |
" Ignore compiled files | |
set wildignore=*.o,*~,*.pyc | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
set cmdheight=1 | |
" A buffer becomes hidden when it is abandoned | |
set hid | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" Ignore case when searching | |
set ignorecase | |
" When searching try to be smart about cases | |
set smartcase | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" No annoying sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
syntax enable | |
" Set extra options when running in GUI mode | |
if has("gui_running") | |
set guioptions-=T | |
set guioptions+=e | |
set t_Co=256 | |
set guitablabel=%M\ %t | |
endif | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Files, backups and undo | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Turn backup off, since most stuff is in SVN, git et.c anyway... | |
set nobackup | |
set nowb | |
set noswapfile | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
" 1 tab == 4 spaces | |
set shiftwidth=4 | |
set tabstop=4 | |
set shiftround "Round spaces to nearest shiftwidth multiple | |
set nojoinspaces "Don't convert spaces to tabs | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
set ai "Auto indent | |
set si "Smart indent | |
set wrap "Wrap lines | |
"""""""""""""""""""""""""""""" | |
" => Visual mode related | |
"""""""""""""""""""""""""""""" | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Moving around, tabs, windows and buffers | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Treat long lines as break lines (useful when moving around in them) | |
map j gj | |
map k gk | |
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search) | |
map <space> / | |
map <leader><space> <ESC>:%s/ | |
" Disable highlight when <leader><cr> is pressed | |
map <silent> <leader><cr> :noh<cr> | |
" Smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" Close the current buffer | |
map <leader>bd :Bclose<cr> | |
" Close all the buffers | |
map <leader>ba :1,1000 bd!<cr> | |
" Useful mappings for managing tabs | |
map <leader>tn :tabnew<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tc :tabclose<cr> | |
map <leader>tm :tabmove | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" Return to last edit position when opening files (You want this!) | |
set laststatus=2 | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l | |
map 0 ^ | |
" Delete trailing white space on save, useful for Python and CoffeeScript ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
" Toggle paste mode on and off | |
map <leader>v :setlocal paste!<cr> | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
en | |
return ' ' | |
endfunction | |
noremap <Up> <nop> | |
noremap <Down> <nop> | |
noremap <Left> <nop> | |
noremap <Right> <nop> | |
set relativenumber | |
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left> | |
set list | |
set listchars=tab:▸\ ,eol:¬ | |
set undofile | |
function! SearchForTODO() | |
let current_ft = "*" . expand ("%:e") | |
"echom current_ft | |
execute "silent grep \"TODO\" " . l:current_ft | |
execute "redraw! " | |
cw | |
call feedkeys("\<C-W>L") | |
call feedkeys("20\<C-W><") | |
endfunction | |
command! -nargs=0 TODOS call SearchForTODO() | |
exec 'source '.fnameescape($HOME.'/.vimrc') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment