set nocompatible " be iMproved, required filetype off " required "vim needs a more POSIX compatible shell than fish if &shell =~# 'fish$' set shell=bash endif call plug#begin('~/.local/share/nvim/plugged') Plug 'neomake/neomake' Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'airblade/vim-gitgutter' Plug 'bling/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'ntpeters/vim-better-whitespace' Plug 'sbdchd/neoformat' Plug 'dag/vim-fish', { 'for': 'fish' } Plug 'lervag/vimtex', { 'for': 'tex' } Plug 'Konfekt/FastFold' Plug 'ervandew/supertab' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-surround' Plug 'tpope/vim-repeat' Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' Plug 'tomtom/tcomment_vim' Plug 'godlygeek/tabular' Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } "Plug 'junegunn/fzf' " On Archlinux this plugin is installed globally when installing fzf Plug 'junegunn/fzf.vim' Plug 'junegunn/goyo.vim' Plug 'editorconfig/editorconfig-vim' Plug 'machakann/vim-highlightedyank' Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' } Plug 'autozimu/LanguageClient-neovim', { \ 'branch': 'next', \ 'do': './install.sh', \ 'for': ['python', 'haskell'] \ } Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " Colorschemes Plug 'NLKNguyen/papercolor-theme' "Plug 'chriskempson/base16-vim' "Plug 'rakr/vim-one' "Plug 'tomasr/molokai' "Plug 'reedes/vim-colors-pencil' " All of your Plugins must be added before the following line call plug#end() filetype plugin indent on " Enable syntax highlighting syntax on "------------------------------------------------------------ " General settings "------------------------------------------------------------ " Better command-line completion set wildmenu set wildmode=longest:full,full " Show partial commands in the last line of the screen set showcmd " Highlight searches set hlsearch " highlight matching pattern as you type set incsearch " store swap files in a central place set directory=~/.cache/nvim/swapfiles//,/tmp// " Command line history set history=100 " Set Window title set title " open new buffers to the right of the current one when splitting vertically set splitright " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis \ | wincmd p | diffthis endif " Use case insensitive search, except when using capital letters set ignorecase set smartcase " Allow backspacing over autoindent, line breaks and start of insert action set backspace=indent,eol,start " Stop certain movements from always going to the first character of a line. " While this behaviour deviates from that of Vi, it does what most users " coming from other editors would expect. set nostartofline " Display the cursor position on the last line of the screen or in the status " line of a window set ruler " Always display the status line, even if only one window is displayed set laststatus=2 " Instead of failing a command because of unsaved changes, instead raise a " dialogue asking if you wish to save changed files. set confirm " Use visual bell instead of beeping when doing something wrong set visualbell " And reset the terminal code for the visual bell. If visualbell is set, and " this line is also included, vim will neither flash nor beep. If visualbell " is unset, this does nothing. set t_vb= " Disable mouse set mouse= " Display line numbers on the left set number "set relativenumber " Quickly time out on keycodes, but never time out on mappings set notimeout ttimeout ttimeoutlen=100 " Use to toggle between 'paste' and 'nopaste'. This is only useful in " terminal vim "set pastetoggle= " show vertical line after 120 characters set colorcolumn=121 " linewrapping and textwidth set textwidth=120 set formatoptions-=t set wrap set linebreak set breakindent set nojoinspaces " highlight current line. Can cause Vim to respond slowly, especially for " large files or files with long lines. "set cursorline " minimize lag when scrolling large files with cursorline enabled set lazyredraw " always show at least 3 lines above and below cursor when scrolling set scrolloff=3 " show hex code of unprinteable characters set display="uhex" " Syntay highlighting items specify folds set foldmethod=syntax " avoids that too many folds are created set foldnestmax=3 " start with all folds expanded set nofoldenable " allows to hide buffers without saving set hidden " show tab characters set list set listchars=tab:▸\ " updatetime (for gitgutter) set updatetime=250 " enable undodir set undofile set undodir=~/.local/share/nvim/undodir " Enable increasing of alphabetical characters with set nrformats+=alpha " Warn when file changed on disk set autoread autocmd CursorHold * checktime " Indentation options set autoindent set smartindent set expandtab set shiftwidth=4 set softtabstop=4 set smarttab set inccommand=split " Automatically save notes when focus is lost autocmd FocusLost ~/workspace/masterthesis/notes* :wa autocmd FocusLost ~/sync/Notes* :wa autocmd BufRead ~/sync/Notes* :set nospell let g:python3_host_prog = '/usr/bin/python3' " Path to Python3 to ignore virualenvs let g:loaded_python_provider = 0 " Disable Python2 "------------------------------------------------------------ " Mappings "------------------------------------------------------------ let mapleader='ö' let maplocalleader='ö' " Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy, " which is the default nnoremap Y y$ " Force saving files that require root permission cmap w!! w !sudo tee > /dev/null % " the escape key is tooo far away inoremap jj " don't leave visual selection mode after changing indentation vmap > >gv vmap < gk imap gj nmap gk nmap gj vmap gk vmap gj " Move lines up and down using Alt+J and Alt+K (works in all modes) nnoremap :m .+1== nnoremap :m .-2== inoremap :m .+1==gi inoremap :m .-2==gi vnoremap :m '>+1gv=gv vnoremap :m '<-2gv=gv " Set common command misspellings as aliases to make them work nonetheless cnoreabbrev W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W')) cnoreabbrev Q ((getcmdtype() is# ':' && getcmdline() is# 'Q')?('q'):('Q')) cnoreabbrev WQ ((getcmdtype() is# ':' && getcmdline() is# 'WQ')?('wq'):('WQ')) cnoreabbrev Wq ((getcmdtype() is# ':' && getcmdline() is# 'Wq')?('wq'):('Wq')) " Copy to clipboard and stay in visualmode vnoremap "*ygv " Insert new line in normal mode nmap i " Insert space in normal mode "nnoremap i " increment/decrement feature nnoremap - nnoremap + " Toggle NERDTree nnoremap :NERDTreeToggle " Cycle through buffers nnoremap :bnext nnoremap :bprevious " ctags jumping nmap nmap :tnext nmap :tprevious " b and w in insert mode inoremap lwi inoremap bi " toggle spellchecking map :setlocal spell! spelllang=de_de " Esc to disable highlighting of search matches nnoremap :nohlsearch " Copy to X clipboard vmap "*y " Paste from X clipboard vmap d"*p imap "*pa nmap "*p " neovim terminal mappings tnoremap tnoremap tnoremap h tnoremap j tnoremap k tnoremap l " window navigation nnoremap h nnoremap j nnoremap k nnoremap l " Disable showing the help map imap "------------------------------------------------------------ " Theming "------------------------------------------------------------ " Remove annoying GUI elements in gvim set guioptions-=m "remove menu bar set guioptions-=T "remove toolbar set guioptions-=r "remove right-hand scroll bar set guioptions-=L "remove left-hand scroll bar set guioptions-=e "remove ugly tab bar set guifont=Hack\ 9 set termguicolors set background=light colorscheme PaperColor "highlight Cursor guibg=#65ff51 "------------------------------------------------------------ " Plugin Settings "------------------------------------------------------------ " fzf commands and mappings command! Fd call fzf#run(fzf#wrap({'source': 'fd --follow --type f --hidden --exclude .git'})) function! s:rg_to_qf(line) let parts = split(a:line, ':') return {'filename': parts[0], 'lnum': parts[1], 'col': parts[2], \ 'text': join(parts[3:], ':')} endfunction function! s:rg_handler(lines) if len(a:lines) < 2 | return | endif let cmd = get({'ctrl-x': 'split', \ 'ctrl-v': 'vertical split', \ 'ctrl-t': 'tabe'}, a:lines[0], 'e') let list = map(a:lines[1:], 's:rg_to_qf(v:val)') let first = list[0] execute cmd escape(first.filename, ' %#\') execute first.lnum execute 'normal!' first.col.'|zz' if len(list) > 1 call setqflist(list) copen wincmd p endif endfunction command! -nargs=* Rg call fzf#run({ \ 'source': empty() \ ? 'rg --hidden --glob "!.git/" --iglob "!license*" --iglob "!COPYING" --column --no-heading --color always --colors "match:none" "\S"' \ : printf('rg --hidden --glob "!.git/" --iglob "!license*" --iglob "!COPYING" --column --no-heading --color always --colors "match:none" "%s"', \ escape(, '"\')), \ 'sink*': function('rg_handler'), \ 'options': '--ansi --expect=ctrl-t,ctrl-v,ctrl-x --delimiter : --nth 4.. '. \ '--multi --bind=ctrl-a:select-all,ctrl-d:deselect-all ', \ 'down': '50%' \ }) nnoremap :Fd nnoremap :Rg nnoremap :Buffers " Neomake. Run only on write if on battery. function! OnBattery() let l:bat_file = '/sys/class/power_supply/AC/online' return filereadable(bat_file) && readfile(bat_file) == ['0'] endfunction if OnBattery() call neomake#configure#automake('w') else call neomake#configure#automake('nw', 1000) endif hi NeomakeWarningSign guifg=#ff8700 ctermfg=208 hi NeomakeVirtualtextWarning guifg=#ff8700 ctermfg=208 hi NeomakeErrorSign guifg=#d70000 ctermfg=160 hi NeomakeVirtualtextError guifg=#d70000 ctermfg=160 " on nvim the language client already provides warnings let g:neomake_haskell_enabled_makers = [] let g:neomake_python_enabled_makers = [] " Airline settings "let g:airline_theme='tomorrow' if !exists('g:airline_symbols') let g:airline_symbols = {} endif let g:airline_left_sep = '' let g:airline_right_sep = '' let g:airline_symbols.linenr = '¶' let g:airline_symbols.branch = '⎇' let g:airline_symbols.paste = '∥' let g:airline_symbols.whitespace = '␣' let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#disable_refresh=1 " vim-notes settings "let g:notes_directories = ['~/sync/notes'] "let g:notes_suffix = '.txt' " neoformat settings let g:neoformat_haskell_brittany = { \ 'exe': 'brittany', \ 'args': ['--indent 4', '--columns 99', '--import-col 49', '--import-as-col 50'], \ 'stdin': 1, \ } let g:neoformat_enabled_haskell = ['brittany'] let g:SuperTabDefaultCompletionType = '' let g:UltiSnipsExpandTrigger = "" let g:UltiSnipsJumpForwardTrigger = "" let g:UltiSnipsJumpBackwardTrigger = "" let g:UltiSnipsEditSplit = "vertical" " vimlatex settings let g:vimtex_compiler_method = 'latexmk' let g:vimtex_compiler_latexmk = { \ 'continuous' : 1, \ 'build_dir' : 'build', \ } "let g:vimtex_fold_enabled = 1 let g:vimtex_imaps_leader = 'ö' let g:vimtex_complete_close_braces = 1 let g:vimtex_quickfix_open_on_warning = 0 let g:vimtex_quickfix_mode = 2 let g:vimtex_view_method = 'zathura' " TODO "let g:vimtex_compiler_progname = '/usr/bin/nvr' "set filetype=tex on empty tex files. let g:tex_flavor='latex' " fastfold settings let g:tex_fold_enabled=1 let g:vimsyn_folding='af' let g:xml_syntax_folding = 1 let g:php_folding = 1 let g:perl_fold = 1 " EditorConfig settings let g:EditorConfig_exclude_patterns = ['fugitive://.*'] " highlightedyank let g:highlightedyank_highlight_duration = 600 hi HighlightedyankRegion cterm=reverse gui=reverse " vim-better-whitespace settings let g:better_whitespace_filetypes_blacklist=['diff', 'gitcommit', 'unite', 'qf', 'help'] let g:strip_whitelines_at_eof=1 highlight ExtraWhitespace guibg=#E06C75 ctermbg=210 " vim-markdown let g:vim_markdown_math = 1 let g:vim_markdown_new_list_item_indent = 0 let g:vim_markdown_auto_insert_bullets = 0 let g:vim_markdown_toc_autofit = 1 let g:vim_markdown_folding_style_pythonic = 1 let g:vim_markdown_folding_level = 4 " deoplete let g:deoplete#enable_at_startup = 1 " LanguageClient config let g:LanguageClient_serverCommands = { \ 'haskell': ['hie-wrapper'], \ 'python': ['/usr/bin/pyls'], \} let g:LanguageClient_rootMarkers = { \ 'haskell': ['*.cabal', 'stack.yaml'], \ } nnoremap :call LanguageClient_contextMenu() map lk :call LanguageClient#textDocument_hover() map lg :call LanguageClient#textDocument_definition() map lr :call LanguageClient#textDocument_rename() map lf :call LanguageClient#textDocument_formatting() map lb :call LanguageClient#textDocument_references() map la :call LanguageClient#textDocument_codeAction() map ls :call LanguageClient#textDocument_documentSymbol()