dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.config/nvim/init.vim

482 lines
16 KiB
VimL
Raw Normal View History

2017-12-28 13:49:45 +00:00
" Important stuff {{{
2018-02-14 22:03:56 +00:00
let g:loaded_python_provider=1 " Disable python 2 interface
let g:python_host_skip_check=1 " Skip python 2 host check
2017-12-28 13:49:45 +00:00
let g:python3_host_prog = '/usr/bin/python3'
let g:tagbar_ctags_bin = '/usr/bin/ctags'
2018-02-14 22:03:56 +00:00
set inccommand=nosplit " Live preview of substitutes and other similar commands
2017-12-28 13:49:45 +00:00
" Plug updates itself automatically
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
2017-12-28 13:49:45 +00:00
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" }}}
" Plugins {{{
2017-12-28 13:49:45 +00:00
call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/vim-plug'
Plug 'junegunn/goyo.vim', { 'for': 'mail'}
2018-02-14 22:03:56 +00:00
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeFind', 'NERDTreeToggle'] }
2017-12-28 13:49:45 +00:00
Plug 'christoomey/vim-tmux-navigator'
2018-02-04 16:14:51 +00:00
Plug 'zefei/vim-wintabs'
2017-12-28 13:49:45 +00:00
Plug 'Shougo/vinarise.vim'
Plug 'lervag/vimtex', { 'for': 'tex' }
2018-02-14 22:03:56 +00:00
"Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
Plug '/usr/bin/fzf'
2018-02-14 22:03:56 +00:00
Plug 'junegunn/fzf.vim'
2017-12-28 13:49:45 +00:00
call plug#end()
let g:plug_window = 'rightbelow topleft new'
" }}}
" Options {{{
2018-02-14 22:03:56 +00:00
" Search down int subfolders
2017-12-28 13:49:45 +00:00
" 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
2018-02-14 22:03:56 +00:00
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="\<SPACE>"
2018-02-14 22:03:56 +00:00
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 pumheight=10 " Completion window max size
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
2018-02-14 22:03:56 +00:00
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
2018-02-14 22:03:56 +00:00
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
2018-02-14 22:03:56 +00:00
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 <Tab> equals
set softtabstop=4
2018-02-14 22:03:56 +00:00
set shiftwidth=4 " Number of spaces for each (auto)indent step
set foldclose=all
set nostartofline
2018-02-14 22:03:56 +00:00
set nosmartindent
set laststatus=1 " Status line on 2 or more files
set nosmarttab
set modeline
2018-02-14 22:03:56 +00:00
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
2018-02-14 22:03:56 +00:00
set termguicolors
set fillchars="fold: " " Characters to fill the statuslines and vertical separators
set fillchars+=vert:\│ " Make vertical split separator full line
" Display all matching files when we tab complete
set wildmenu
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,._*
2018-02-14 22:03:56 +00:00
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=tmp/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=*cache*
set wildignore+=*logs*
set wildignore+=*node_modules/**
set wildmode=longest:list,full
colorscheme turtles
2018-02-14 22:03:56 +00:00
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
highlight TermCursor ctermfg=green guifg=green
" }}}
" Status line without any plugins {{{
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
set statusline=
set statusline+=%#SpecialKey#
set statusline+=\ %{StatuslineGit()}
set statusline+=%#CursorLineNr#
set statusline+=\ %F
set statusline+=\ %y
2018-02-14 22:03:56 +00:00
set statusline+=\ %h%m%r%w%q
set statusline+=%=
set statusline+=%{PasteForStatusline()}
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\ [%{&fileformat}\]
set statusline+=\ %l:%c\ (%p%%)
set statusline+=%#Keyword#
set statusline+=\ %{winnr()}
2018-02-04 16:14:51 +00:00
set statusline+=
" }}}
2018-02-04 16:14:51 +00:00
" 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
2018-02-09 20:05:20 +00:00
" Disables automatic commenting on newline
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
2018-02-04 16:14:51 +00:00
" 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
aug mutt_settings
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=90
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo
autocmd BufEnter /tmp/neomutt* :exe "normal! 9j\<cr>I"
autocmd BufEnter /tmp/neomutt* set spelllang=es
aug END
endif
"}}}
" Read-Only files {{{
if &readonly
set laststatus=0
set ruler
set cmdheight=1
set nonumber
set noshowmode
set colorcolumn=0
endif
2017-12-28 13:49:45 +00:00
" }}}
" Tweaks for browsing {{{
" - :edit a folder to open a file browser
" - <CR>/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
" }}}
2018-01-25 23:37:48 +00:00
" 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' }
" Default fzf layout: - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
2018-02-14 22:03:56 +00:00
" 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 <SID>fzf_statusline()
" [Buffers] Jump to the existing window if possible
2018-02-14 22:03:56 +00:00
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'}, <bang>0)
" :Ag - Start fzf with hidden preview window that can be enabled with "?" key
" :Ag! - Start fzf in fullscreen and display the preview window above
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" Likewise, Files command with preview window
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
" }}}
2018-02-04 16:14:51 +00:00
" Wintabs {{{
2018-02-09 20:05:20 +00:00
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='»'
2018-02-04 16:14:51 +00:00
" }}}
" Goyo {{{
let g:goyo_height = "90%"
function! s:goyo_enter()
set showmode
let b:quitting = 0
let b:quitting_bang = 0
autocmd QuitPre <buffer> let b:quitting = 1
cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction
function! s:goyo_leave()
set noshowmode
" Quit Vim if this is the only remaining buffer
if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
if b:quitting_bang
qa!
else
qa
endif
endif
endfunction
autocmd! User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave call <SID>goyo_leave()
"}}}
2017-12-28 13:49:45 +00:00
" NerdTree {{{
autocmd StdinReadPre * let s:std_in=1
2018-02-14 22:03:56 +00:00
let NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '.o$', 'bower_components', 'node_modules', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
2017-12-28 13:49:45 +00:00
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 <silent> M-left :TmuxNavigateLeft<cr>
nnoremap <silent> M-Down :TmuxNavigateDown<cr>
nnoremap <silent> M-Up :TmuxNavigateUp<cr>
nnoremap <silent> M-Right :TmuxNavigateRight<cr>
nnoremap <silent> M-Tab :TmuxNavigatePrevious<cr>
" }}}
2018-01-25 23:37:48 +00:00
" LaTeX {{{
let g:tex_flavor = "latex"
2017-12-28 13:49:45 +00:00
" }}}
" Mappings {{{
map <M-p> :!w<Enter>:!pdflatex <C-r>%<Enter>
map <M-a> :setlocal spell! spelllang=es<CR>
map <M-u> :setlocal spell! spelllang=en<CR>
map <M-g> :Goyo<CR>
inoremap <M-g> <esc>:Goyo<CR>a
2017-12-28 13:49:45 +00:00
2018-02-14 22:03:56 +00:00
" FZF really is a lifechanger
nnoremap <C-p> :FZF<CR>
nnoremap <leader>xb :Buffers<cr>
nnoremap <leader>xc :History:<cr>
nnoremap <leader>xf :Files<cr>
nnoremap <leader>xg :GFiles<cr>
nnoremap <leader>xh :History<cr>
nnoremap <leader>xl :Lines<cr>
nnoremap <leader>xm :Maps<cr>
nnoremap <leader>xr :Ag<cr>
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>pU :PlugUpgrade<CR>
nnoremap <leader>pc :PlugClean<CR>
" Learn vim keys the hard way
2018-02-17 19:16:52 +00:00
nnoremap <silent> <Left> :vertical resize -2<CR>
nnoremap <silent> <Right> :vertical resize +2<CR>
nnoremap <silent> <Up> :resize -2<CR>
nnoremap <silent> <Down> :resize +2<CR>
nnoremap <silent> <F5> :so ~/.config/nvim/init.vim<CR>
2018-02-14 22:03:56 +00:00
nnoremap <leader>T :terminal<CR>
nnoremap <leader>ws :split<CR>
nnoremap <leader>wv :vsplit<CR>
2018-02-17 19:16:52 +00:00
nnoremap <leader>wnv :vnew<CR>
nnoremap <leader>wns :new<CR>
2018-02-14 22:03:56 +00:00
" Fix indentation
nnoremap <leader>i mzgg=G`z<CR>
" Unhighlight search terms
nnoremap <silent> <leader><space> :noh<CR>
" What about the Q
nnoremap Q <nop>
2017-12-28 13:49:45 +00:00
map q <nop>
2018-02-14 22:03:56 +00:00
" Move vertically by visual line
nnoremap j gj
2017-12-28 13:49:45 +00:00
nnoremap k gk
2018-02-14 22:03:56 +00:00
vnoremap j gj
vnoremap k gk
" Center screen when jumping and moving
nnoremap <silent> n :norm! nzz<CR>
nnoremap <silent> N :norm! Nzz<CR>
vnoremap <silent> n :norm! nzz<CR>
vnoremap <silent> N :norm! Nzz<CR>
nnoremap <C-u> <C-u>zz
nnoremap <C-d> <C-d>zz
nnoremap <C-f> <C-f>zz
nnoremap <C-b> <C-b>zz
vnoremap <C-u> <C-u>zz
vnoremap <C-d> <C-d>zz
vnoremap <C-f> <C-f>zz
vnoremap <C-b> <C-b>zz
" Tabs
nnoremap <C-n> :tabnew<CR>
nnoremap <leader>bx :bd!<CR>
nnoremap <Tab> :bnext!<CR>
nnoremap <S-Tab> :bprev!<CR>
" Alt to switch windows
nnoremap <M-j> <C-W><C-J>
2017-12-28 13:49:45 +00:00
nnoremap <M-k> <C-W><C-K>
nnoremap <M-l> <C-W><C-L>
nnoremap <M-h> <C-W><C-H>
2018-02-14 22:03:56 +00:00
" Terminal movement
tnoremap <Esc> <C-\><C-n>
tnoremap <M-h> <C-\><C-n><C-w>h
2017-12-28 13:49:45 +00:00
tnoremap <M-j> <C-\><C-n><C-w>j
tnoremap <M-k> <C-\><C-n><C-w>k
tnoremap <M-l> <C-\><C-n><C-w>l
2018-02-14 22:03:56 +00:00
" Shift butterfinger
:command! WQ wq
:command! Wq wq
:command! Wqa wqa
2018-02-14 22:03:56 +00:00
:command! Wa wa
:command! WA wa
:command! W w
:command! Q q
2018-02-14 22:03:56 +00:00
:command! Qa qa
:command! QA qa
" }}}
2018-01-25 23:37:48 +00:00
" vim:foldmethod=marker:foldlevel=0