Skip to content

Instantly share code, notes, and snippets.

@bbtdev
Created April 3, 2018 16:46
Show Gist options
  • Save bbtdev/5c6dafd72dd986d34be80b506d7fa4b7 to your computer and use it in GitHub Desktop.
Save bbtdev/5c6dafd72dd986d34be80b506d7fa4b7 to your computer and use it in GitHub Desktop.
vim config denisa lubuntu
" tmux
fun! DoesPaneAlreadyExists()
let panes_list = split(system('tmux list-panes -s -F "#{pane_index}"', "\n"))
let panes_count = len(panes_list)
if panes_count > 1
exec ':echo "' . panes_list[1] . '"'
call system('tmux kill-pane -t ' . panes_list[1] )
else
endif
endfun
fun! CreatePaneWithCurrentDirectory()
call DoesPaneAlreadyExists()
call system('tmux split-window -c ' . expand('%:p:h') . '\; resize-pane -x 70 -y 10')
endfun
fun! CreatePaneWithTmuxDefaultDirectory()
call DoesPaneAlreadyExists()
call system('tmux split-window \; resize-pane -x 70 -y 10')
endfun
fun! RunSpecForFileWithDispath()
let file = GetCurrentFile()
if IsCompatibleForSpec(file)
let file = GetSpecForFile(file)
endif
exec ':Dispatch rspec ' . file
endfunction
" KEY MAPPINGS
" leader
let mapleader=" "
" buffer navi
:nnoremap <leader>l :Buffers<CR>
:nnoremap <leader>b :b#<CR>
" windows
" move cursor on split
nnoremap <C-w>v :vsplit<CR><C-w>p
nnoremap <C-w>s :split<CR><C-w>p
" open big below
nnoremap <C-w>S :botright sp<CR>
nnoremap <C-w>V :botright vsplit<CR>
" window navigation
" nnoremap <C-h> <C-w>h
" nnoremap <C-j> <C-w>j
" nnoremap <C-k> <C-w>k
" nnoremap <C-l> <C-w>l
" PLUGINS
" * rails navi
" ruby/rails
:nnoremap <leader>ra :call SwitchToRailsSpecAlternate()<cr>
:nnoremap <leader>rv :call AlternateViewsFolderController()<cr>
" spec
:nnoremap <leader>sf :call RunSpecDispatchForFile()<cr>
:nnoremap <leader>sF :call RunSpecForFile()<cr>
" :nnoremap <leader>rrf :call RunSpecForFile()<cr>
" * fzf
" replace ls with fzf buffers
:cnoreabbrev ls :Buffers
" replace tags with fzf tags
:cnoreabbrev tags :Tags
" :FZF on CTRLP
nnoremap <C-p> :FZF<CR>
" TESTING
:nnoremap <leader>tm :call CreatePaneWithTmuxDefaultDirectory()<cr>
:nnoremap <leader>tf :call CreatePaneWithCurrentDirectory()<cr>
:nnoremap <leader>ts :call RunSpecForFileWithDispath()<cr>
" * mucomplete
" completion sources
" never omni first, slows down
" c-p = :help complete
setglobal complete-=t
let g:mucomplete#chains = {}
let g:mucomplete#chains.default = ['c-n']
let g:mucomplete#chains.vim = ['c-n', 'cmd']
let g:mucomplete#chains.ruby = ['c-n', 'tags', 'omni']
let g:mucomplete#chains.html = ['c-n', 'omni']
set completeopt+=menuone
set completeopt+=noselect
set completeopt+=noinsert
let g:mucomplete#always_use_completeopt = 1
let g:mucomplete#enable_auto_at_startup = 1
let g:mucomplete#smart_enter = 1
imap <Plug>MyCR <Plug>(MUcompleteCR)
imap <cr> <Plug>MyCR
" * dirvish
" sort by file type
autocmd FileType dirvish sort ,^.*[\/],
" :FZF in dirvish
autocmd FileType dirvish nnoremap <buffer><silent> <c-p> :FZF<cr>
" * FZF
" NVIM exit type mode, FZF fix (affected fzf ESC)
tnoremap <expr> <esc> &filetype == 'fzf' ? "\<esc>" : "\<c-\>\<c-n>"
" * airline
" buffer numbers
let g:airline#extensions#tabline#buffer_nr_show = 1
" enable
let g:airline#extensions#tabline#enabled = 1
" * endwise
" ctr+j
" imap <C-J> <CR>
" * syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_html_checkers = ['w3']
" let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_checkers = [] " to deactivate
"" emmet ""
let g:user_emmet_leader_key='<C-E>'
let g:user_emmet_settings={'javascript.jsx': {'extends':'jsx'}}
"" vim-tips ""
autocmd VimEnter * call Tip()
" PLUGINS
call plug#begin('~/.vim/plugged')
" EXPLORERS
Plug '~/.fzf'
Plug 'junegunn/fzf.vim' " FZF - file explorer
Plug 'justinmk/vim-dirvish' " Dirvish - split explorer
" AUTOCOMPLETE
Plug 'lifepillar/vim-mucomplete'
" TAGS
Plug 'majutsushi/tagbar' " Tagbar - show all tags in file
" PRACTICAL
Plug 'tpope/vim-repeat' " Vim-repeat - repeats actions from supported plugings
Plug 'troydm/zoomwintab.vim' " ZoomWinTab - C-o undo
Plug 'tpope/vim-surround'
Plug 'Raimondi/delimitMate' " delimitMate - closes delimiter
Plug 'tpope/vim-endwise' " adds end automatically
" LINTS
" Plug 'w0rp/ale'
Plug 'vim-syntastic/syntastic' " ale conflict
" GIT
Plug 'tpope/vim-fugitive'
" RUBY/RAILS
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-bundler' " Vim-bundler - support for bundle, but also integrates gem tags
Plug 'ngmy/vim-rubocop'
" HTML
"Plug 'tpope/vim-ragtag'
" THEMES
Plug 'rafi/awesome-vim-colorschemes'
" STATUS/TAB LINES
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" MINE
Plug 'bbtdev/railsnavi.vim'
" TERMINAL
Plug 'tpope/vim-dispatch'
Plug 'christoomey/vim-tmux-navigator'
" TESTING
Plug 'chrisbra/Colorizer'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'othree/html5.vim'
Plug 'tpope/vim-ragtag'
Plug 'mattn/emmet-vim'
Plug 'jonatasbaldin/vim-tips'
"" TROUBLE SHOOT ""
"" syntastic jsx ""
" Plug 'jaxbot/syntastic-react'
" Plug 'pmsorhaindo/syntastic-local-eslint.vim'
call plug#end()
" GENERAL
set nocompatible " We're running Vim, not Vi!
syntax on " Enable syntax highlighting
filetype on " Enable filetype detection
filetype plugin on " Enable filetype-specific plugins
set number " sets numbering
set hidden " hide buffer errors
set tabstop=2 shiftwidth=2 expandtab " tab and spaces
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " no comment on new lines
set wrap " wrap lines visually
set wildmenu " pressing tab in command
" THEMES
colorscheme solarized8_flat
set background=light
" out
" filetype indent on " Enable filetype-specific indenting, vim-plug does this auto
" autocompletion
" setlocal omnifunc=syntaxcomplete#Complete
" autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
" autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
" EXTERNAL
source ~/.config/vim/configs/plugins.vim
source ~/.config/vim/configs/keys.vim
source ~/.config/vim/configs/functions.vim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment