dotfiles/vim/vimrc
2020-05-07 19:44:35 +02:00

434 lines
10 KiB
VimL

" File : vimrc
" Author : Jeff LANCE <email@jefflance.me>
" Date : 15.04.2015
" Last Modified Date: 28.04.2020
" Last Modified By : Jeff LANCE <email@jefflance.me>
""""""""""""""""""""""""""""""""""""""""""""""
"
" ____ _____ _ _ _____ ____ _ _
" / ___| ____| \ | | ____| _ \ / \ | |
"| | _| _| | \| | _| | |_) | / _ \ | |
"| |_| | |___| |\ | |___| _ < / ___ \| |___
" \____|_____|_| \_|_____|_| \_\/_/ \_\_____|
"
"
""""""""""""""""""""""""""""""""""""""""""""""""
" some useful vars
let using_neovim = has('nvim')
let using_vim = !using_neovim
set nocompatible " be iMproved, required
filetype plugin indent on
" viminfo configuration
if using_vim
set viminfo='100,n$HOME/.vim/files/info/viminfo
endif
set backupdir=$HOME/.vim/backup
set directory=$HOME/.vim/tmp
set noswapfile
" UTF-8
set encoding=utf8
" Syntax highlighting
syntax on
set synmaxcol=512
" 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 = ";"
" Fast saving
nmap <leader>w :w!<cr>
" Allow saving of files as sudo when I forgot to start vim using sudo.
" ca w!! w !sudo tee "%"
" A buffer becomes hidden when it is abandoned
set hidden
" Use system clipboard
set clipboard=unnamedplus
" Mouse
set mouse=a
" Auto change dir to current buffer dir
autocmd BufEnter * silent! lcd %:p:h
" Delete extra blank line at the end of file
" autocmd BufWritePre *.py normal m`:%s/\s\+$//e``
""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ___ _ _ _____ _____ ____ _____ _ ____ _____
" |_ _| \ | |_ _| ____| _ \| ___/ \ / ___| ____|
" | || \| | | | | _| | |_) | |_ / _ \| | | _|
" | || |\ | | | | |___| _ <| _/ ___ \ |___| |___
" |___|_| \_| |_| |_____|_| \_\_|/_/ \_\____|_____|
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To use fancy symbols wherever possible,
let fancy_symbols_enabled = 1
" Font config
set guifont=Inconsolata\ Nerd\ Font\ Mono\ 11
" Remove ugly vertical lines on window division
set fillchars+=vert:\
"
set linespace=5
" vim tab title
let &titlestring = @%
set title
" Show line numbers
set number
" Line wrapping
set wrap
" Tab control
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set textwidth=80
set autoindent
set smartindent
" python
au BufNewFile,BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix
" js, html, css
au BufNewFile,BufRead *.js, *.html, *.css
\ set noexpandtab
\ set tabstop=2
\ set softtabstop=2
\ set shiftwidth=2
" Let the cursor traverse to the previous or following line when at the or the
" end of a line
set whichwrap=b,s,<,>,[,]
" Search
set ignorecase " Ignore case when searching
" 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
" Disable scrollbars (real hackers don't use scrollbars for navigation!)
set guioptions-=r
set guioptions-=R
set guioptions-=l
set guioptions-=L
" Spell checking
set spell
set spelllang=fr,en
"""""""""""""""""""""""""""""""""""""""""""
" ____ _ _ _ ____ ___ _ _ ____
" | _ \| | | | | |/ ___|_ _| \ | / ___|
" | |_) | | | | | | | _ | || \| \___ \
" | __/| |__| |_| | |_| || || |\ |___) |
" |_| |_____\___/ \____|___|_| \_|____/
"
"""""""""""""""""""""""""""""""""""""""""""
" Installing the Plug plugin manager
source $HOME/.vim/plug.vim
" Start startify if no arg
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter *
\ if argc() == 0
\ && !exists("s:std_in")
\ | Startify
\ | endif
" needed so deoplete can auto select the first suggestion
set completeopt+=noinsert
" comment this line to enable autocompletion preview window
" (displays documentation related to the selected completion option)
" disabled by default because preview makes the window flicker
" set completeopt-=preview
" autocompletion of files and commands behaves like shell
" (complete only the common part, list the options that match)
set wildmode=list:longest
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ____ _____ _ _____ _ _ ____ _ ___ _ _ _____
" / ___|_ _|/ \|_ _| | | / ___|| | |_ _| \ | | ____|
" \___ \ | | / _ \ | | | | | \___ \| | | || \| | _|
" ___) || |/ ___ \| | | |_| |___) | |___ | || |\ | |___
" |____/ |_/_/ \_\_| \___/|____/|_____|___|_| \_|_____|
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set noshowmode
set laststatus=2
if !has('gui_running')
set t_Co=256
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ____ ___ _ ___ ____ ____ ____ _ _ _____ __ __ _____
" / ___/ _ \| | / _ \| _ \/ ___| / ___| | | | ____| \/ | ____|
" | | | | | | | | | | | |_) \___ \| | | |_| | _| | |\/| | _|
" | |__| |_| | |__| |_| | _ < ___) | |___| _ | |___| | | | |___
" \____\___/|_____\___/|_| \_\____/ \____|_| |_|_____|_| |_|_____|
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let base16colorspace=256 " Access colors present in 256 colorspace"
set background=dark
" colorscheme abstract
colorscheme sourcerer
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" _ _ _ _ _
" _ __ | |_ _ __ _(_)_ __ ___ ___ ___| |_| |_(_)_ __ __ _ ___
" | '_ \| | | | |/ _` | | '_ \/ __| / __|/ _ \ __| __| | '_ \ / _` / __|
" | |_) | | |_| | (_| | | | | \__ \ \__ \ __/ |_| |_| | | | | (_| \__ \
" | .__/|_|\__,_|\__, |_|_| |_|___/ |___/\___|\__|\__|_|_| |_|\__, |___/
" |_| |___/ |___/
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" BufTabLine
"
hi TabLineSel ctermbg=green ctermfg=black guibg=green guifg=black
hi PmenuSel ctermbg=white ctermfg=white guibg=white guifg=white
"
" Defx
"
" Set appearance
call defx#custom#option(
\ '_', {
\ 'winwidth': 40,
\ 'split': 'vertical',
\ 'direction': 'botright',
\ 'show_ignored_files': 0,
\ 'buffer_name': 'defxplorer',
\ 'toggle': 1,
\ 'columns': 'icon:indent:icons:filename',
\ 'resume': 1,
\ }
\ )
call defx#custom#column(
\ 'icon', {
\ 'directory_icon': '▸',
\ 'opened_icon': '▾',
\ }
\ )
call defx#custom#column(
\ 'mark', {
\ 'readonly_icon': '✗',
\ 'selected_icon': '✓',
\ }
\ )
"
" Deoplete
"
if using_neovim
let g:deoplete#enable_at_startup = 1
endif
"
" FZF
"
" This is the default extra key bindings
let g:fzf_action = {
\ 'enter': 'e',
\ 'ctrl-h': 'split',
\ 'ctrl-v': 'vsplit'
\ }
" Preview window
let g:fzf_preview_window = 'right:60%'
if has('nvim') && !exists('g:fzf_layout')
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
endif
"
" Header
"
let g:header_field_author = 'Jeff LANCE'
let g:header_field_author_email = 'email@jefflance.me'
let g:header_auto_add_header = 0
"
" Lightline
"
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype', 'kitestatus' ] ],
\ },
\ 'component': {
\ 'readonly': '%{&readonly?"|":""}',
\ 'kitestatus': '%{kite#statusline()}',
\ },
\ 'component_function': {
\ 'gitbranch': 'FugitiveHead'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
"
" Markdown review
"
let vim_markdown_preview_toggle=1
let vim_markdown_preview_browser='x-www-browser'
"
" REPL
"
let g:repl_program = {
\ 'python': ['ipython'],
\ 'default': ['zsh'],
\ 'r': ['R'],
\ 'lua': ['lua'],
\ 'vim': ['vim -e']
\ }
let g:repl_predefine_python = {
\ 'numpy': 'import numpy as np',
\ 'matplotlib': 'from matplotlib import pyplot as plt'
\ }
let g:repl_cursor_down = 1
let g:repl_python_automerge = 1
let g:repl_ipython_version = '7'
let g:repl_position = 3
"
" Startify
"
let g:startify_custom_header = 'startify#center(startify#fortune#cowsay())'
let g:startify_session_dir = '~/.vim/session'
let g:startify_lists = [
\ { 'type': 'files', 'header': ['MRU' . getcwd()] },
\ { 'type': 'sessions', 'header': ['SESSIONS'] },
\ { 'type': 'bookmarks', 'header': ['BOOKMARKS'] },
\ ]
let g:startify_enable_special = 0
let g:startify_files_number = 10
let g:startify_bookmarks = [
\ '~/.config/',
\ '~/.vimrc',
\ '~/.vim/keybindings.vim',
\ '~/.vim/plug.vim',
\ '~/.vim/functions.vim',
\ '~/Projets/latex/latex-homework'
\ ]
"
" Tmuxline
"
let g:tmuxline_preset = {
\'a' : '#S',
\'win' : ['#I', '#W'],
\'cwin' : ['#I', '#W', '#F'],
\'y' : ['%a', '%d', '%b', '%R'],
\'z' : '#H'
\ }
let g:tmuxline_separators = {
\ 'left' : '',
\ 'left_alt': '>',
\ 'right' : '',
\ 'right_alt' : '',
\ 'space' : ' '
\ }
let g:tmuxline_theme = 'sourcerer'
"
" TMux navigator
"
let g:tmux_navigator_no_mappings = 1
let g:tmux_navigator_save_on_switch = 2
"
" Vimroom
"
let g:goyo_width=200
let g:goyo_margin_top = 2
let g:goyo_margin_bottom = 2
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" _____ _ _ _ _ ____ _____ ___ ___ _ _ ____
" | ___| | | | \ | |/ ___|_ _|_ _/ _ \| \ | / ___|
" | |_ | | | | \| | | | | | | | | | \| \___ \
" | _| | |_| | |\ | |___ | | | | |_| | |\ |___) |
" |_| \___/|_| \_|\____| |_| |___\___/|_| \_|____/
"
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Load fucntions from file
source $HOME/.vim/functions.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" _ _________ ______ ___ _ _ ____ ___ _ _ ____ ____
" | |/ / ____\ \ / / __ )_ _| \ | | _ \_ _| \ | |/ ___/ ___|
" | ' /| _| \ V /| _ \| || \| | | | | || \| | | _\___ \
" | . \| |___ | | | |_) | || |\ | |_| | || |\ | |_| |___) |
" |_|\_\_____| |_| |____/___|_| \_|____/___|_| \_|\____|____/
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Load keybindings from file
source $HOME/.vim/keybindings.vim