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

592 lines
19 KiB
VimL
Raw Normal View History

2017-12-28 13:49:45 +00:00
" Important stuff {{{
scriptencoding utf-8 " Set utf-8 as default script encoding
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
let python_highlight_all=1
" 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
if executable('rg')
set grepprg=rg\ --vimgrep\ --hidden\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
2017-12-28 13:49:45 +00:00
" }}}
" Plugins {{{
call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/vim-plug'
" UI
Plug 'zefei/vim-wintabs'
Plug 'zefei/vim-wintabs-powerline'
" Languages
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
" Formatting
Plug 'tmsvg/pear-tree'
Plug 'w0rp/ale'
Plug 'sbdchd/neoformat', {'on': 'Neoformat'}
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/neco-syntax'
Plug 'Shougo/neco-vim'
" Navigation
Plug 'christoomey/vim-tmux-navigator'
Plug '/usr/bin/fzf'
Plug 'junegunn/fzf.vim'
" Modes
Plug 'junegunn/goyo.vim'
" Python
Plug 'numirias/semshi', {'do': ':UpdateRemotePlugins'}
Plug 'jpalardy/vim-slime'
Plug 'zchee/deoplete-jedi'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
call plug#end()
2017-12-28 13:49:45 +00:00
" }}}
" Options {{{
" Search down into subfolders
" Provides tab-completion for all file-related tasks
" - :b lets you autocomplete any open buffer
set path+=**
set binary
2018-07-21 04:46:57 +00:00
set clipboard^=unnamedplus " system clipboard (requires +clipboard)
set encoding=utf-8 " The encoding displayed.
set fileencoding=utf-8 " The encoding written to file.
set shell=/bin/zsh " Setting shell to zsh
set number " Line numbers on
set showmode " Always show mode
set mousemodel=popup
set breakindent
set cmdheight=1 " Command line height
set cmdwinheight=5 " Command-line lines
set pumheight=12 " 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 redrawtime=500
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=200 " 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
set completefunc=LanguageClient#complete
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
set noexpandtab " Do not turn tabs into spaces
set tabstop=4 " Number of spaces a <Tab> equals
set softtabstop=4
set shiftwidth=4 " Number of spaces for each (auto)indent step
set foldclose=all
set nostartofline
set nosmartindent
set nosmarttab
set modeline
set modelines=2
set scrolloff=3 " Keep this many lines padding when scrolling
2018-07-21 04:46:57 +00:00
set title
set undofile
set undolevels=1000
set undoreload=10000
set undodir=$HOME/.config/nvim/undo
set nrformats-=octal
set pastetoggle=<F12>
set shortmess=aoOtIWcFs " Shorten messages and don't show intro
set omnifunc=syntaxcomplete#Complete
set complete+=]
set formatoptions+=n
" 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
if &diff
set textwidth=80
endif
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
let mapleader="\<SPACE>"
let maplocalleader=","
let formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-][\t ]\)\s*'
" }}}
" Read-Only files {{{
if &readonly
set laststatus=0
set ruler
set cmdheight=1
set nonumber
set noshowmode
set colorcolumn=0
let g:ale_disabled
endif
2017-12-28 13:49:45 +00:00
" }}}
" {{{ Ale
let g:ale_linters_explicit = 1
let g:ale_change_sign_column_color = 1
let g:ale_echo_msg_format = '[%linter%] %s% (code)% [%severity%]'
let g:ale_loclist_msg_format = '[%linter%] %s% (code)% [%severity%]'
let g:ale_open_list = 'on_save'
let g:ale_sign_error = '✖'
let g:ale_sign_warning = '⚠'
let g:ale_lint_delay = 500 " relint max once per [amount] milliseconds
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_set_highlights = 1
let g:ale_pattern_options = {
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
\}
nmap <silent> <F10> <Plug>(ale_previous_wrap)
nmap <silent> <F11> <Plug>(ale_next_wrap)
" }}}
" Deoplete {{{
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option('max_list', 100000)
call deoplete#custom#option('min_pattern_length', 2)
call deoplete#custom#source('LanguageClient',
\ 'min_pattern_length',
\ 2)
if !exists('g:deoplete#omni#input_patterns')
let g:deoplete#omni#input_patterns = {}
endif
let g:deoplete#sources#jedi#server_timeout = 120
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._ = '_'
"}}}
2017-12-28 13:49:45 +00:00
" 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>
2017-12-28 13:49:45 +00:00
" }}}
" FZF {{{
" use bottom positioned 30% height bottom split
let g:fzf_layout = { 'down': '~35%' }
let g:fzf_action = {
\ 'ctrl-t': 'enew',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Clear'],
\ 'hl': ['fg', 'String'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
let g:fzf_buffers_jump = 1
let g:fzf_tags_command = 'ctags -R'
let g:fzf_history_dir = '~/.local/share/fzf-history'
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --hidden --ignore-case --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\ : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ <bang>0)
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
" only use FZF shortcuts in non diff-mode
if !&diff
nnoremap <F1> :Helptags<CR>
nnoremap <F2> :Files<CR>
nnoremap <F3> :History<CR>
nnoremap <F4> :Buffers<CR>
nnoremap <C-g> :Rg<CR>
endif
" }}}
" Semshi {{{
let g:semshi#mark_selected_nodes = 2
let g:semshi#error_sign = v:false
" }}}
" Slime {{{
let g:slime_target = 'tmux'
let g:slime_python_ipython = 1
let g:slime_paste_file = '~/Documents/Algorave/.slime_paste'
let g:slime_default_config = {"socket_name": "default", "target_pane": ":.2"}
let g:slime_dont_ask_default = 1
nnoremap <c-c>l :SlimeSendCurrentLine<CR>
" }}}
" LSP {{{
let g:LanguageClient_serverCommands = {
\ 'python': ['/usr/bin/pyls'],
\ 'cpp': ['clangd'],
\ 'bash': ['/usr/bin/shellcheck'],
\ }
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
" }}}
" Colors {{{
2019-04-14 15:53:12 +00:00
let g:seoul256_srgb = 1
let g:seoul256_background = 233
colo seoul256
" }}}
" Wintabs {{{
let g:wintabs_switchbuf='useopen,usetab'
nnoremap <silent> <C-w> :WintabsClose<CR>
nnoremap <silent> <C-l> :WintabsNext<CR>
nnoremap <silent> <C-h> :WintabsPrevious<CR>
" }}}
" AutoCommands {{{
if !exists("autocommands_loaded") && has("autocmd")
let autocommands_loaded = 1
" Auto remove all trailing whitespace on :w
autocmd BufWritePre * :%s/\s\+$//e
" Disables automatic commenting on newline
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Runs a script that cleans out tex build files whenever I close out of a .tex file.
autocmd VimLeave *.tex !texclear %
2019-01-08 13:01:43 +00:00
autocmd BufWritePost ~/.Xresources,~/.Xdefaults !xrdb %
aug aug_cursor_line
au!
au InsertEnter * setlocal nocursorline
au InsertLeave * setlocal cursorline
aug END
aug skeletons
autocmd BufNewFile *.py 0r ~/.config/nvim/templates/py.skeleton
autocmd BufRead,BufNewFile *.foxdot 0r ~/.config/nvim/templates/foxdot.skeleton
autocmd BufNewFile *.sh 0r ~/.config/nvim/templates/sh.skeleton
aug END
aug terminal_stuff
au TermOpen * setlocal nonumber norelativenumber
aug END
augroup CloseLoclistWindowGroup
autocmd!
autocmd QuitPre * if empty(&buftype) | lclose | endif
augroup END
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set showmode ruler
aug fzf_setup
au!
au TermOpen term://*FZF tnoremap <silent> <buffer> <esc> <c-c>
aug END
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo
" Automatic syntax highlighting for files
aug set_file_types
au BufRead,BufNewFile *.md set filetype=markdown
au BufRead,BufNewFile *.conf set filetype=dosini
au BufRead,BufNewFile *.bash* set filetype=sh
au BufRead,BufNewFile man set textwidth=80
aug END
endif
" }}}
"Mappings {{{
" Spell checking
nnoremap <F6> :setlocal spell! spelllang=es<CR>
nnoremap <F7> :setlocal spell! spelllang=en<CR>
nnoremap <F8> :set nospell<CR>
2019-04-14 15:53:12 +00:00
" LaTeX
nnoremap <F9> :w! \| !compiler <c-r>%<CR>
" Plug
nnoremap <leader>pi :PlugInstall<CR>
nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>pU :PlugUpgrade<CR>
nnoremap <leader>pc :PlugClean<CR>
" Neoformat
nnoremap <leader>f :Neoformat<CR>
vnoremap <leader>f :Neoformat<CR>
" Use urlview to choose and open a url:
noremap <leader>u :w<Home>silent <End> !urlscan<CR>
noremap ,, :w<Home>silent <End> !urlscan<CR>
" Visual mode pressing * or # searches for the current selection
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
" Super quick search and replace
2018-10-18 19:25:56 +00:00
nnoremap <Space>+ :'{,'}s/\<<C-r>=expand("<cword>")<CR>\>/
nnoremap <Space>¿ :%s/\<<C-r>=expand("<cword>")<CR>\>/
" Learn vim keys the hard way
nnoremap <silent> <Left> :vertical resize -2<CR>
nnoremap <silent> <Right> :vertical resize +2<CR>
2018-07-21 04:46:57 +00:00
nnoremap <silent> <Up> :resize -1<CR>
nnoremap <silent> <Down> :resize +1<CR>
inoremap jk <esc>
cnoremap jk <C-c>
2018-07-21 04:46:57 +00:00
" Edit and source config file
2018-07-21 04:46:57 +00:00
nnoremap <silent> <leader>ev :vsplit $MYVIMRC<CR>
nnoremap <silent> <leader>sv :source $MYVIMRC<CR>
" Fast saves
nnoremap <leader>w :w!<CR>
" Fast exits
nnoremap <leader>q :q!<CR>
" Splits
nnoremap <leader>T :terminal<CR>
nnoremap <leader>s :split<CR>
nnoremap <leader>v :vsplit<CR>
nnoremap <leader>nv :vnew<CR>
nnoremap <leader>ns :new<CR>
" Ensure that ctrl+u in insert mode can be reversed
" http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U
inoremap <c-u> <c-g>u<c-u>
inoremap <c-w> <c-g>u<c-w>
" My vim wants to enter all the time, enter all the time
nnoremap <silent> <CR> i<CR><ESC>
" Fix indentation
nnoremap <leader>i mzgg=G`z<CR>
" Deedee
2018-07-21 04:46:57 +00:00
nnoremap - dd<CR>p
inoremap <c-d> <esc>ddi
" Quote words under cursor
nnoremap <leader>" viW<esc>a"<esc>gvo<esc>i"<esc>gvo<esc>3l
nnoremap <leader>' viW<esc>a'<esc>gvo<esc>i'<esc>gvo<esc>3l
" Move a line of text using Shift+[jk]
nnoremap <S-j> mz:m+<cr>`z
nnoremap <S-k> mz:m-2<cr>`z
vnoremap <S-j> :m'>+<cr>`<my`>mzgv`yo`z
vnoremap <S-k> :m'<-2<cr>`>my`<mzgv`yo`z
2018-07-21 04:46:57 +00:00
" Unhighlight search terms
2018-07-04 19:27:13 +00:00
nnoremap <silent> <leader><space> :noh<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" What about the Q
nnoremap Q <nop>
map q <nop>
2018-07-21 04:46:57 +00:00
" j = gj :: k = gk while preserving numbered jumps ie. 12j or 30k
nnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
nnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
vnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
vnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
" Line movements
noremap <silent> <Home> g<Home>
noremap <silent> <End> g<End>
inoremap <silent> <Home> <C-o>g<Home>
inoremap <silent> <End> <C-o>g<End>
2018-07-21 04:46:57 +00:00
nnoremap H 0
nnoremap L $
vnoremap H 0
vnoremap L $
2018-07-21 04:46:57 +00:00
noremap Y 0y$
noremap <leader>y y$
" 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>
" Alt to switch windows
nnoremap <M-j> <C-W><C-J>
nnoremap <M-k> <C-W><C-K>
nnoremap <M-l> <C-W><C-L>
nnoremap <M-h> <C-W><C-H>
inoremap <A-h> <Esc><C-w>h
inoremap <A-j> <Esc><C-w>j
inoremap <A-k> <Esc><C-w>k
inoremap <A-l> <Esc><C-w>l
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Terminal movement
tnoremap <Esc> <C-\><C-n>
tnoremap <M-h> <C-\><C-n><C-w>h
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
" 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
" }}}
2018-07-21 04:46:57 +00:00
" Stuff i'll probably use if i remember to {{{
" Don't close window when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
2018-07-21 04:46:57 +00:00
" global replace
vnoremap <Leader>sw "hy
\ :let b:sub = input('global replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ let b:rep = substitute(getreg('h'), '/', '\\/', 'g') <Bar>
2018-07-21 04:46:57 +00:00
\ execute '%s/'.b:rep."/".b:sub.'/g' <Bar>
\ unlet b:sub b:rep <Bar>
\ endif <CR>
nnoremap <Leader>sw
\ :let b:sub = input('global replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ execute "%s/<C-r><C-w>/".b:sub.'/g' <Bar>
\ unlet b:sub <Bar>
\ endif <CR>
" prompt before each replace
vnoremap <Leader>cw "hy
\ :let b:sub = input('interactive replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ let b:rep = substitute(getreg('h'), '/', '\\/', 'g') <Bar>
\ execute '%s/'.b:rep.'/'.b:sub.'/gc' <Bar>
\ unlet b:sub b:rep <Bar>
\ endif <CR>
nnoremap <Leader>cw
\ :let b:sub = input('interactive replacement: ') <Bar>
\ if b:sub !=? '' <Bar>
\ execute "%s/<C-r><C-w>/".b:sub.'/gc' <Bar>
\ unlet b:sub <Bar>
\ endif <CR>
" highlight long lines
let w:longlines = matchadd('ColorColumn', '\%'.&tw.'v', &tw)
nnoremap <silent> <Leader>ll
\ :if exists('w:longlines') <Bar>
\ silent! call matchdelete(w:longlines) <Bar>
\ unlet w:longlines <Bar>
\ elseif &textwidth > 0 <Bar>
\ let w:longlines = matchadd('ColorColumn', '\%'.&textwidth.'v', &textwidth) <Bar>
\ else <Bar>
\ let w:longlines = matchadd('ColorColumn', '\%80v', 80) <Bar>
\ endif <CR>
" local keyword jump
nnoremap <Leader>fw
\ [I:let b:jump = input('Go To: ') <Bar>
\ if b:jump !=? '' <Bar>
\ execute "normal! ".b:jump."[\t" <Bar>
\ unlet b:jump <Bar>
\ endif <CR><Paste>
" }}}
" vim:foldmethod=marker:foldlevel=0