Skip to content

Instantly share code, notes, and snippets.

@omgitsads
Created September 3, 2019 07:28
Show Gist options
  • Save omgitsads/c064125012362bf104264626e1d89a28 to your computer and use it in GitHub Desktop.
Save omgitsads/c064125012362bf104264626e1d89a28 to your computer and use it in GitHub Desktop.
set nocompatible " be iMproved, required
filetype off " required
set backspace=indent,eol,start
call plug#begin('~/.vim/plugged')
Plug 'airblade/vim-gitgutter'
Plug 'editorconfig/editorconfig-vim'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'mattn/emmet-vim'
Plug 'scrooloose/nerdtree'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-surround'
Plug 'w0rp/ale'
Plug 'arcticicestudio/nord-vim'
Plug 'tmux-plugins/vim-tmux'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'mileszs/ack.vim'
Plug 'elixir-editors/vim-elixir'
Plug 'jparise/vim-graphql'
Plug 'majutsushi/tagbar'
Plug 'ryanoasis/vim-devicons'
call plug#end()
map <C-n> :NERDTreeToggle<CR>
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'nord',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head',
\ 'filetype': 'MyFiletype',
\ 'fileformat': 'MyFileformat',
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '', 'right': '' }
\ }
function! LightlineFugitive() abort
if &filetype ==# 'help'
return ''
endif
if has_key(b:, 'lightline_fugitive') && reltimestr(reltime(b:lightline_fugitive_)) =~# '^\s*0\.[0-5]'
return b:lightline_fugitive
endif
try
if exists('*fugitive#head')
let head = fugitive#head()
else
return ''
endif
let b:lightline_fugitive = head
let b:lightline_fugitive_ = reltime()
return b:lightline_fugitive
catch
endtry
return ''
endfunction
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : ''
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : ''
endfunction
function! CurrentFileTypeSymbol()
return (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() : 'no ft')
endfunction
filetype on
syntax on
colorscheme nord
set guifont=SauceCodePro\ Nerd\ Font:h12
set guioptions=
set hidden
set history=100
filetype indent on
set nowrap
set tabstop=2
set shiftwidth=2
set expandtab
set smartindent
set autoindent
set nu
set undodir=~/.vim/.undo/
set backupdir=~/.vim/.backup
set directory=~/.vim/.swp
autocmd BufWritePre * :%s/\s\+$//e
set hlsearch
if !has('gui_running')
set t_Co=256
endif
" Hybrid line numbers
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
let g:fzf_action = {
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit'
\ }
nnoremap <C-p> :Files<cr>
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
nmap <F8> :TagbarToggle<CR>
autocmd BufEnter,BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window \"vim - " . CurrentFileTypeSymbol() . " - " . expand("%:t") . "\"")
autocmd VimLeave * call system("tmux rename-window bash")
" ripgrep
if executable('rg')
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
set grepprg=rg\ --vimgrep
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
" 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%'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment