Skip to content

Instantly share code, notes, and snippets.

@mer0mingian
Last active November 25, 2019 20:27
Show Gist options
  • Save mer0mingian/26f13f5b1644eb2e54b84876ae4f6ef3 to your computer and use it in GitHub Desktop.
Save mer0mingian/26f13f5b1644eb2e54b84876ae4f6ef3 to your computer and use it in GitHub Desktop.
My vim8 configuration
set nocompatible " required
filetype off " required
" README. First install Vundle.
" Then install the following dependencies:
" fzf - fzf.vim, vim-clap
" reggrep - OPTIONAL?
" ctags - Vista
" python3 -m pip install pynvim - vim-clap
" echo set t_Co=256 - lightline
" python3 -m pip install yapf - yapf autoformatting by google
" download and install anaconda - vim-conda
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'scrooloose/nerdtree' " file explorer sidebar
Plugin 'Xuyuanp/nerdtree-git-plugin' " git status in nerdtree
Plugin 'jistr/vim-nerdtree-tabs' " no longer actively maintained
Plugin 'itchyny/lightline.vim' " lightweight statusbar
Plugin 'Raimondi/delimitMate' " complete + mark delimiters
Plugin 'flazz/vim-colorschemes' " colorschemes
Plugin 'ervandew/supertab' " Tab completion
Plugin 'tmhedberg/SimpylFold' " code folding
Plugin 'vimwiki/vimwiki' " Markdown wiki TODO: needs configuration
Plugin 'godlygeek/tabular' " markdown tables
Plugin 'plasticboy/vim-markdown' " markdown syntax support
Plugin 'terryma/vim-multiple-cursors' " Sublime-likish
Plugin 'airblade/vim-gitgutter' " git flags in editor
Plugin 'tpope/vim-fugitive' " git support, TODO: configure
Plugin 'tpope/vim-surround' " get delimiters from a selection
Plugin 'tpope/vim-eunuch' " UNIX commands in vim
Plugin 'tpope/vim-commentary' " create block commentaries
Plugin 'tpope/vim-obsession' " automated session management
Plugin 'wannesm/rmvim.vim' " asyncrhonous remote editing
" Plugin 'thaerkh/vim-workspace' " Better session management
Plugin 'psliwka/vim-smoothie' " Smooth scrooling
Plugin 'timakro/vim-searchant' " search result highlighting
Plugin 'vim-pandoc/vim-pandoc' " document converter interface
Plugin 'vim-pandoc/vim-pandoc-syntax' " markdown syntax for pandoc
" Plugin 'vim-airline/vim-airline' " replace by lightline
" Plugin 'vim-airline/vim-airline-themes' " replace by lightline
Plugin 'liuchengxu/vista.vim' " Vim-script-based tagbar
" Plugin 'kien/ctrlp.vim' " deprecated - replaced by vim-clap
" Plugin 'sgur/ctrlp-extensions.vim' " deprecated - replaced by vim-clap
" Plugin 'tacahiroy/ctrlp-funky' " deprecated - replaced by vim-clap
Plugin 'junegunn/fzf.vim' " fuzzy search implementation for vim-clap
Plugin 'liuchengxu/vim-clap' " replaces CtrlP, benefits from ripgrp
Plugin 'python-mode/python-mode', {'for':'python', 'branch':'develop'} " TODO: configure
Plugin 'skywind3000/asyncrun.vim' " run Python scripts directly from vim
Plugin 'dense-analysis/ale' " Linting engine. Replaces syntastic. TODO: conf
Plugin 'vim-scripts/indentpython.vim' " automated indentation
Plugin 'jeetsukumaran/vim-pythonsense' " Python object movements
" Plugin 'davidhalter/jedi-vim' " conflicts with python-mode
" Plugin 'neoclide/coc.nvim' " replaced by deoplete.nvim
" Plugin 'Shougo/deoplete.nvim' " automcompletion, replaced by ale
" Plugin 'deoplete-plugins/deoplete-jedi' " Jedi for deoplete, replaced by ale
Plugin 'cjrh/vim-conda' " handling the python path properly TODO: conf
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
syntax on " Syntax highlighting
set rtp+=~/.fzf " fuzzy search - fast, but need system install
" ============================================================================
" Tabs, movement shortcuts
" ============================================================================
"
"split navigations and rules
" nnoremap <C-J> <C-W><C-J>
" nnoremap <C-K> <C-W><C-K>
" nnoremap <C-L> <C-W><C-L>
" nnoremap <C-H> <C-W><C-H>
" Tab navigation like Chrome
noremap <C-t> :tabnew<CR>
inoremap <C-t> <Esc>:tabnew<CR>i
" CTRL-Tab is next tab
noremap <C-Tab> :<C-U>tabnext<CR>
inoremap <C-Tab> <C-\><C-N>:tabnext<CR>
cnoremap <C-Tab> <C-C>:tabnext<CR>
" CTRL-SHIFT-Tab is previous tab
noremap <C-S-Tab> :<C-U>tabprevious<CR>
inoremap <C-S-Tab> <C-\><C-N>:tabprevious<CR>
cnoremap <C-S-Tab> <C-C>:tabprevious<CR>
" Terminal window
aug t_bufnum
au!
au BufEnter,BufLeave * if &buftype ==# 'terminal' | let g:t_bufnum = expand('<abuf>') | endif
aug END
nnoremap <F4> :silent! call term_sendkeys(t_bufnum, "python " . expand("%:p") . "\<lt>CR>")<CR>
nnoremap <F2> :below 15sp|terminal<CR>
nnoremap <F3> :below 15sp|terminal python %<CR>
" ============================================================================
" general editor settings
" ============================================================================
"
set splitbelow
set splitright
set foldmethod=indent
set foldlevel=99
set number
set tabstop=4
set softtabstop=4
set shiftwidth=4
" set clipboard=unnamed
set clipboard=unnamedplus
let g:SimpylFold_docstring_preview=1
" Python formatting
au BufNewFile,BufRead *.py,*.md
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |
\ set showmatch |
\ set cursorline
let python_highlight_all=1
" ============================================================================
" Single line Plugin configurations
" ============================================================================
" Airline has been deprecated with python mode
" let g:airline_theme='wombat'
" let g:airline_molokai_bg='dark'
let g:SuperTabDefaultCompletionType = "<c-n>"
let g:gitgutter_max_signs = 500 " default value
nmap ]c <Plug>GitGutterNextHunk
nmap [c <Plug>GitGutterPrevHunk
nmap <Leader>hs <Plug>GitGutterStageHunk
nmap <Leader>hu <Plug>GitGutterUndoHunk
let g:vimwiki_list = [{'path': '~/Documents/mer0s_wiki/', 'syntax': 'markdown', 'ext': '.md'}]
au FileType vimwiki set syntax=markdown
nnoremap <silent><C-P> :Clap<CR>
nnoremap <silent><C-O> :Clap command<CR>
nnoremap <silent><F6> :NERDTreeTabsToggle<CR>
nnoremap <silent><F7> :Vista!!<CR>
" autocmd FileType python nnoremap <LocalLeader>= :0,$!yapf<CR> " Google yapf
let g:workspace_session_disable_on_args = 1 " calling vim with file will not re-open session
let g:workspace_session_directory = $HOME . '/.vim/sessions/'
nnoremap <leader>s :ToggleWorkspace<CR>
" ============================================================================
" Lightline statusbar
" ============================================================================
set noshowmode
set laststatus=2
if !has('gui_running')
set t_Co=256
endif
let g:lightline = {
\ 'colorscheme': 'one',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
" ============================================================================
" Nerdtree
" ============================================================================
autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "m",
\ "Staged" : "+",
\ "Untracked" : " ",
\ "Renamed" : "r",
\ "Unmerged" : "*",
\ "Deleted" : "-",
\ "Dirty" : "d",
\ "Clean" : "c",
\ 'Ignored' : 'i',
\ "Unknown" : "?"
\ }
" ============================================================================
" Ale - has been deprecated with Python mode
" ============================================================================
let b:ale_linters = ['pyflakes', 'flake8', 'pylint']
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'python3': ['eslint'],
\ }
" let b:ale_fix_on_save = 1
" Enable completion where available.
" This setting must be set before ALE is loaded.
" You should not turn this setting on if you wish to use ALE as a completion
" source for other completion plugins, like Deoplete.
" let g:ale_completion_enabled = 1
set omnifunc=ale#completion#OmniFunc
" Only run linters named in ale_linters settings.
let g:ale_linters_explicit = 1
set omnifunc=ale#completion#OmniFunc
" ============================================================================
" colorscheme:
" ============================================================================
colorscheme molokai
"
" Set a function to toggle my colorscheme with F5
let s:mybg = "dark"
function! ColoToggle()
if (s:mybg ==? "light")
colorscheme molokai
set background=dark
let s:mybg = "dark"
else
colorscheme Atelier_EstuaryLight
set background=light
let s:mybg = "light"
endif
endfunction
nnoremap <silent> <F5> :call ColoToggle()<cr>
" ============================================================================
" Jedi Setting
" ============================================================================
" let g:jedi#popup_on_dot = 0
" let g:jedi#show_call_signatures = "1"
" let g:jedi#goto_command = "<leader>d"
" let g:jedi#goto_assignments_command = "<leader>g"
" let g:jedi#goto_definitions_command = ""
" let g:jedi#documentation_command = "K"
" let g:jedi#usages_command = "<leader>n"
" let g:jedi#completions_command = "<C-Space>"
" let g:jedi#rename_command = "<leader>r"
" ============================================================================
" FZF
" ============================================================================
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" In Neovim, 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': '10new' }
" 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'
" 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)
" Advanced customization using autoload functions
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
" Replace the default dictionary completion with fzf-based fuzzy completion
inoremap <expr> <c-x><c-k> fzf#vim#complete('cat /usr/share/dict/words')
function! s:fzf_statusline()
" Override statusline as you like
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()
" ============================================================================
" Vista
" ============================================================================
" Command Description
" Vista Open vista window for viewing tags or LSP symbols
" Vista! Close vista view window if already opened
" Vista!! Toggle vista view window
" ":Vista [EXECUTIVE]: open vista window powered by EXECUTIVE.
" ":Vista finder [EXECUTIVE]: search tags/symbols generated from EXECUTIVE.
" See :help vista-commands for more information.
" How each level is indented and what to prepend.
" This could make the display more compact or more spacious.
" e.g., more compact: ["▸ ", ""]
" Note: this option only works the LSP executives, doesn't work for `:Vista ctags`.
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]
" Executive used when opening vista sidebar without specifying it.
" See all the avaliable executives via `:echo g:vista#executives`.
let g:vista_default_executive = 'ctags' " default 'ctags'
" Set the executive for some filetypes explicitly. Use the explicit executive
" instead of the default one for these filetypes when using `:Vista` without
" specifying the executive.
" let g:vista_executive_for = {
" \ 'cpp': 'vim_lsp',
" \ 'php': 'vim_lsp',
" \ }
" Declare the command including the executable and options used to generate ctags output
" for some certain filetypes.The file path will be appened to your custom command.
" For example:
" let g:vista_ctags_cmd = {
" " \ 'haskell': 'hasktags -x -o - -c',
" " \ }
" To enable fzf's preview window set g:vista_fzf_preview.
" The elements of g:vista_fzf_preview will be passed as arguments to fzf#vim#with_preview()
" For example:
let g:vista_fzf_preview = ['right:50%']
" Ensure you have installed some decent font to show these pretty symbols, then you can enable icon for the kind.
let g:vista#renderer#enable_icon = 1
" The default icons can't be suitable for all the filetypes, you can extend it as you wish.
let g:vista#renderer#icons = {
\ "function": "\uf794",
\ "variable": "\uf71b",
\ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment