" Important stuff {{{ let g:loaded_python_provider=1 " Disable python 2 interface let g:python_host_skip_check=1 " Skip python 2 host check let g:python3_host_prog = '/usr/bin/python3' let g:tagbar_ctags_bin = '/usr/bin/ctags' set inccommand=nosplit " Live preview of substitutes and other similar commands " Plug updates itself automatically if empty(glob('~/.config/nvim/autoload/plug.vim')) silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif " }}} " Plugins {{{ call plug#begin('~/.config/nvim/plugged') Plug 'junegunn/vim-plug' Plug 'Shougo/deoplete.nvim', { 'do': [':UpdateRemotePlugins', ':set runtimepath+=~/.config/nvim/plugged/deoplete.nvim/'] } Plug 'jiangmiao/auto-pairs' Plug 'zchee/deoplete-jedi' Plug 'w0rp/ale' Plug 'sbdchd/neoformat' Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeFind', 'NERDTreeToggle'] } Plug 'christoomey/vim-tmux-navigator' Plug 'zefei/vim-wintabs' Plug 'lervag/vimtex', { 'for': 'tex' } "Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } Plug '/usr/bin/fzf' Plug 'junegunn/fzf.vim' call plug#end() let g:plug_window = 'rightbelow topleft new' " }}} " Options {{{ " Search down int subfolders " Provides tab-completion for all file-related tasks " - :b lets you autocomplete any open buffer set path+=** let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 "let $NVIM_TUI_ENABLE_TRUE_COLOR=1 set binary set encoding=utf-8 " The encoding displayed. set fileencoding=utf-8 " The encoding written to file. scriptencoding utf-8 " Set utf-8 as default script encoding let mapleader="\" set shell=/bin/zsh " Setting shell to zsh set number " Line numbers on set showmode " Always show mode set textwidth=120 " Text width is 120 characters set cmdheight=1 " Command line height set cmdwinheight=5 " Command-line lines set pumheight=10 " Completion window max size set helpheight=12 " Minimum help window height set previewheight=12 " Completion preview height set noswapfile " New buffers will be loaded without creating a swapfile set hidden " Enables to switch between unsaved buffers and keep undo history set lazyredraw " Don't redraw while executing macros (better performance) set showmatch " Show matching brackets when text indicator is over them set matchtime=2 " How many tenths of a second to blink when matching brackets set nojoinspaces " No extra space when joining a line which ends with . ? ! set updatetime=1000 " Update time used to create swap file or other things set synmaxcol=220 " Don't try to syntax highlight minified files set splitbelow " Splitting a window will put the new window below the current set splitright " Splitting a window will put the new window right of the current set notimeout " Time out on key codes but not mappings. set ttimeout set ttimeoutlen=10 set ignorecase " Ignore case by default set smartcase " Make search case sensitive only if it contains uppercase letters set wrapscan " Search again from top when reached the bottom set cursorline " Hightlight the screen line of the cursor set numberwidth=5 " Minimal number of columns to use for line numbers set nobackup set nowritebackup set wrap " Wrap lines longer than the width of the window set visualbell " Use visual bell instead of beeping set selectmode=key set keymodel=startsel set foldenable " Fold by default set foldlevelstart=10 set foldnestmax=10 " Deepest fold is 10 levels set foldmethod=marker " Markers are used to specify folds. set completeopt-=preview " Don't show preview scratch buffers set noexpandtab " Do not turn tabs into spaces set tabstop=4 " Number of spaces a equals set softtabstop=4 set shiftwidth=4 " Number of spaces for each (auto)indent step set foldclose=all set nostartofline set nosmartindent set laststatus=1 " Status line on 2 or more files set nosmarttab set modeline set modelines=2 set scrolloff=7 " Keep this many lines padding when scrolling set undofile set undolevels=1000 set undoreload=10000 set undodir=$HOME/.config/nvim/undo set termguicolors set fillchars="fold: " " Characters to fill the statuslines and vertical separators set fillchars+=vert:\│ set nrformats-=octal set pastetoggle= set shortmess=aoOtIWcFs " Shorten messages and don't show intro set omnifunc=syntaxcomplete#Complete set complete+=] set completeopt-=preview set completeopt+=noinsert,longest,noselect,menuone set formatoptions+=n let formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-][\t ]\)\s*' " Display all matching files when we tab complete set wildmenu set wildignorecase set wildoptions=tagfile set wildignore+=.git,.hg,.svn set wildignore+=*.aux,*.out,*.toc set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp set wildignore+=*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg set wildignore+=*.mp3,*.oga,*.ogg,*.wav,*.flac set wildignore+=*.eot,*.otf,*.ttf,*.woff set wildignore+=*.doc,*.pdf,*.cbr,*.cbz set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb set wildignore+=*.swp,.lock,.DS_Store,._* set wildignore+=.stversions,*.pyc,*.spl,*.o,*.out,*~,%* set wildignore+=*vim/backups* set wildignore+=tmp/** set wildignore+=*.gem set wildignore+=log/** set wildignore+=*cache* set wildignore+=*logs* set wildignore+=*node_modules/** set wildignore+=__pycache__,*.egg-info set wildmode=longest:list,full match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' highlight TermCursor ctermfg=green guifg=green colorscheme turtles " }}} " Statusline {{{ function! GitBranch() return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") endfunction function! StatuslineGit() let l:branchname = GitBranch() return strlen(l:branchname) > 0?' '.l:branchname.' ':'' endfunction function! PasteForStatusline() let paste_status = &paste if paste_status == 1 return " [paste] " else return "" endif endfunction function! LinterStatus() abort let l:counts = ale#statusline#Count(bufnr('')) let l:all_errors = l:counts.error + l:counts.style_error let l:all_non_errors = l:counts.total - l:all_errors return l:counts.total == 0 ? 'OK' : printf( \ '%dW %dE', \ all_non_errors, \ all_errors \) endfunction set statusline= set statusline+=%#SpecialKey# set statusline+=\ %{StatuslineGit()} set statusline+=%#CursorLineNr# set statusline+=\ %F set statusline+=\ %y set statusline+=\ %h%m%r%w%q set statusline+=%= set statusline+=%{LinterStatus()} set statusline+=%{PasteForStatusline()} set statusline+=\ %{&fileencoding?&fileencoding:&encoding} set statusline+=\ [%{&fileformat}\] set statusline+=\ %l:%c\ (%p%%) set statusline+=%#Keyword# set statusline+=\ %{winnr()} set statusline+= " }}} " AutoCommands {{{ if !exists("autocommands_loaded") && has("autocmd") let autocommands_loaded = 1 autocmd BufWritePre * :%s/\s\+$//e " Auto remove all trailing whitespace on :w :au FocusLost * :wa " Autosave files when focus is lost " Disables automatic commenting on newline autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Automatic syntax highlighting for files aug set_file_types au BufRead,BufNewFile *.txt set filetype=markdown au BufRead,BufNewFile *.md set filetype=markdown au BufRead,BufNewFile *.conf set filetype=dosini au BufRead,BufNewFile *.bash* set filetype=sh aug END endif "}}} " Read-Only files {{{ if &readonly set laststatus=0 set ruler set cmdheight=1 set nonumber set noshowmode set colorcolumn=0 endif " }}} " Tweaks for browsing {{{ " - :edit a folder to open a file browser " - /v/t to open in an h-split/v-split/tab let g:netrw_banner=0 " disable annoying banner let g:netrw_browse_split=4 " open in prior window let g:netrw_altv=1 " open splits to the right let g:netrw_liststyle=3 " tree view let g:netrw_list_hide=netrw_gitignore#Hide() let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' let g:netrw_winsize=25 " }}} " {{{ Ale let g:ale_echo_msg_error_str = 'E' let g:ale_echo_msg_warning_str = 'W' let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' hi ALEErrorSign ctermfg=red ctermbg=none hi ALEWarningSign ctermfg=yellow ctermbg=none " }}} " Deoplete {{{ let g:deoplete#enable_at_startup = 1 let g:deoplete#sources#jedi#show_docstring = 1 let g:deoplete#enable_ignore_case = 1 let g:deoplete#enable_smart_case = 1 let g:context_filetype#same_filetypes = {} let g:context_filetype#same_filetypes._ = '_' "}}} " FZF {{{ " An action can be a reference to a function that processes selected lines function! s:build_quickfix_list(lines) call setqflist(map(copy(a:lines), '{ "filename": v:val }')) copen cc endfunction let g:fzf_action = { \ 'ctrl-q': function('s:build_quickfix_list'), \ 'ctrl-t': 'tab split', \ 'ctrl-x': 'split', \ 'ctrl-v': 'vsplit' } "let $FZF_DEFAULT_OPTS .= ' --no-height' " Default fzf layout: - down / up / left / right let g:fzf_layout = { 'down': '~40%' } " You can set up fzf window using a Vim command let g:fzf_layout = { 'window': 'enew' } let g:fzf_layout = { 'window': '-tabnew' } "let g:fzf_layout = { 'window': '10split enew' } " Customize fzf colors to match your color scheme let g:fzf_colors = \ { 'fg': ['fg', 'Normal'], \ 'bg': ['bg', 'Normal'], \ 'hl': ['fg', 'Comment'], \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], \ 'hl+': ['fg', 'Statement'], \ 'info': ['fg', 'PreProc'], \ 'border': ['fg', 'Ignore'], \ 'prompt': ['fg', 'Conditional'], \ 'pointer': ['fg', 'Exception'], \ 'marker': ['fg', 'Keyword'], \ 'spinner': ['fg', 'Label'], \ 'header': ['fg', 'Comment'] } " Enable per-command history. " CTRL-N and CTRL-P will be automatically bound to next-history and " previous-history instead of down and up. If you don't like the change, " explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. let g:fzf_history_dir = '~/.local/share/fzf-history' function! s:fzf_statusline() highlight fzf1 ctermfg=161 ctermbg=251 highlight fzf2 ctermfg=23 ctermbg=251 highlight fzf3 ctermfg=237 ctermbg=251 setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f endfunction autocmd! User FzfStatusLine call fzf_statusline() " [Buffers] Jump to the existing window if possible let g:fzf_buffers_jump = 1 " [Commands] --expect expression for directly executing the command let g:fzf_commands_expect = 'alt-enter,ctrl-x' " Override Colors command. You can safely do this in your .vimrc as fzf.vim " will not override existing commands. command! -bang Colors \ call fzf#vim#colors({'left': '15%', 'options': '--reverse --margin 30%,0'}, 0) " :Ag - Start fzf " :Ag! - Start fzf in fullscreen and display the preview window above command! -bang -nargs=* Ag \ call fzf#vim#ag(, \ 0 ? fzf#vim#with_preview('up:60%') \ : fzf#vim#with_preview('right:50%'), \ 0) " Likewise, Files command with preview window command! -bang -nargs=? -complete=dir Files \ call fzf#vim#files(, fzf#vim#with_preview(), 0) " }}} " Wintabs {{{ let g:wintabs_ui_active_higroup = 'TabLineSel' let g:wintabs_switchbuf='useopen,usetab' let intertabSpace= ' ' let activeWinTabChar = '|' let activeVimTabChar = '|' let activeWinTabChar = '▎' let activeVimTabChar = '▍' let g:wintabs_ui_sep_leftmost=intertabSpace let g:wintabs_ui_sep_inbetween=intertabSpace let g:wintabs_ui_active_right=intertabSpace let g:wintabs_ui_active_left=activeVimTabChar let g:wintabs_ui_sep_rightmost=intertabSpace let g:wintabs_ui_modified=' +' let g:wintabs_ignored_filetypes=[] let g:wintabs_ui_active_vimtab_left=activeVimTabChar let g:wintabs_ui_active_vimtab_right=intertabSpace let g:wintabs_ui_arrow_left='«' let g:wintabs_ui_arrow_right='»' " }}} " NerdTree {{{ autocmd StdinReadPre * let s:std_in=1 let NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.pyo$', '\.db$', '\.sqlite$', '.o$', 'bower_components', 'node_modules', '__pycache__'] let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$'] let NERDTreeNaturalSort = 1 let NERDTreeShowHidden=1 let NERDTreeWinPos=1 let NERDTreeRespectWildIgnore = 1 let NERDTreeMinimalUI=1 let NERDTreeDirArrows = 1 let NERDTreeCascadeSingleChildDir=1 let NERDTreeCascadeOpenSingleChildDir=1 let NERDTreeQuitOnOpen = 1 let NERDTreeHijackNetrw = 0 let NERDTreeAutoCenter = 1 " }}} " Tmux navigator {{{ let g:tmux_navigator_no_mappings = 1 let g:tmux_navigator_save_on_switch = 1 nnoremap M-left :TmuxNavigateLeft nnoremap M-Down :TmuxNavigateDown nnoremap M-Up :TmuxNavigateUp nnoremap M-Right :TmuxNavigateRight nnoremap M-Tab :TmuxNavigatePrevious " }}} " Mappings {{{ map :!w:!pdflatex % map :setlocal spell! spelllang=es map :setlocal spell! spelllang=en nmap (ale_previous_wrap) nmap (ale_next_wrap) nnoremap f :Neoformat vnoremap f :Neoformat " FZF really is a lifechanger nnoremap :FZF nnoremap b :Buffers nnoremap h :History: nnoremap t :Files nnoremap gt :GFiles nnoremap l :Lines nnoremap m :Maps nnoremap r :Ag " Mapping selecting mappings nmap (fzf-maps-n) xmap (fzf-maps-x) omap (fzf-maps-o) " Insert mode completion imap (fzf-complete-word) imap (fzf-complete-path) imap (fzf-complete-file-ag) imap (fzf-complete-line) nnoremap :NERDTreeFind nnoremap :NERDTreeToggle nnoremap pi :PlugInstall nnoremap pu :PlugUpdate nnoremap pU :PlugUpgrade nnoremap pc :PlugClean " super quick search and replace nnoremap ' :'{,'}s/\<=expand("")\>/ nnoremap ¿ :%s/\<=expand("")\>/ " Learn vim keys the hard way nnoremap :vertical resize -2 nnoremap :vertical resize +2 nnoremap :resize -2 nnoremap :resize +2 nnoremap :so ~/.config/nvim/init.vim nnoremap T :terminal nnoremap s :split nnoremap v :vsplit nnoremap nv :vnew nnoremap ns :new " ensure that ctrl+u in insert mode can be reversed " http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U inoremap u inoremap u " My vim wants to enter all the time, enter all the time nnoremap i " Fix indentation nnoremap i mzgg=G`z " Unhighlight search terms nnoremap :noh=has('diff')?'diffupdate':'' " What about the Q nnoremap Q map q " Move vertically by visual line nnoremap j gj nnoremap k gk vnoremap j gj vnoremap k gk " Use tab for indenting in visual mode vnoremap >gv| vnoremap g noremap g inoremap g inoremap g noremap Y y$ " Center screen when jumping and moving nnoremap n :norm! nzz nnoremap N :norm! Nzz vnoremap n :norm! nzz vnoremap N :norm! Nzz nnoremap zz nnoremap zz nnoremap zz nnoremap zz vnoremap zz vnoremap zz vnoremap zz vnoremap zz " Tabs nnoremap :tabnew nnoremap (wintabs_close) nnoremap (wintabs_next) nnoremap <(wintabs_previous) " Alt to switch windows nnoremap nnoremap nnoremap nnoremap " Terminal movement tnoremap tnoremap h tnoremap j tnoremap k tnoremap l " Shift butterfinger :command! WQ wq :command! Wq wq :command! Wqa wqa :command! Wa wa :command! WA wa :command! W w :command! Q q :command! Qa qa :command! QA qa " }}} " vim:foldmethod=marker:foldlevel=0