source ~/.vim/common.vim
set shell=/bin/zsh
set hidden


"  ____  _             
" |  _ \| |_   _  __ _ 
" | |_) | | | | |/ _` |
" |  __/| | |_| | (_| |
" |_|   |_|\__,_|\__, |
"                |___/ 
" ########################################################################
"

call plug#begin('~/.vim/plugged')

" Powerline vim
" @site: https://github.com/powerline/powerline
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'powerline/powerline'             " Powerline VIM
Plug 'vim-airline/vim-airline'         " AirLine (tabs,etc..)
Plug 'vim-airline/vim-airline-themes'  " AirLine Themes (for sexy working)

Plug 'echuraev/translate-shell.vim', { 'do': 'wget -O ~/.vim/trans git.io/trans && chmod +x ~/.vim/trans' }

" Vim addons (nice & sexy) 
Plug 'mhinz/vim-startify'
Plug 'terryma/vim-expand-region'
Plug 'terryma/vim-multiple-cursors'
Plug 'editorconfig/editorconfig-vim'

Plug 'dylanaraps/wal'

Plug 'kristijanhusak/vim-carbon-now-sh'

"Plug 'yggdroot/indentline'

Plug 'sbdchd/neoformat'
Plug 'neomake/neomake'
Plug 'ludovicchabant/vim-gutentags'
Plug 'junegunn/fzf'
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'KabbAmine/zeavim.vim'
Plug 'tpope/vim-commentary'
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'wincent/ferret'
Plug 'moll/vim-bbye'

Plug 'shime/vim-livedown'
Plug 'kjwon15/vim-transparent'

Plug 'mzlogin/vim-markdown-toc'

Plug 'tpope/vim-unimpaired'

" NOTE: you need to install completion sources to get completions. Check
" our wiki page for a list of sources: https://github.com/ncm2/ncm2/wiki
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-tmux'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-vim-lsp'

Plug 'vim-vdebug/vdebug'

" NERDTree
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'scrooloose/nerdtree'
Plug 'zefei/vim-wintabs'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'ryanoasis/vim-devicons'
Plug 'jistr/vim-nerdtree-tabs'

" Vim colorscheme plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'fcpg/vim-complimentary'
Plug 'fcpg/vim-farout'
Plug 'fcpg/vim-orbital'
Plug 'fcpg/vim-fahrenheit'

" Vim Git
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'junegunn/gv.vim'


" Vim Snippets
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'ssh://gogs@git.cynarski.pl:65522/myEnv/my-snips.git'

" PHP
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'StanAngeloff/php.vim'
Plug 'arnaud-lb/vim-php-namespace'
Plug 'lumiliet/vim-twig'

Plug 'phpactor/phpactor' ,  {'do': 'composer install'}
Plug 'phpactor/ncm2-phpactor'

Plug 'tobyS/vmustache'
Plug 'tobyS/pdv'
Plug 'StanAngeloff/php.vim', {'for': 'php'}
Plug 'adoy/vim-php-refactoring-toolbox'

Plug 'stephpy/vim-php-cs-fixer'

" TypeScript
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'leafgarland/typescript-vim'
" Plug 'mhartington/nvim-typescript'
Plug 'Quramy/tsuquyomi'


" HasiCorp
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'fatih/vim-hclfmt'
Plug 'hashivim/vim-terraform'
Plug 'hashivim/vim-consul'
Plug 'b4b4r07/vim-hcl'

" Salt-Stack (.:REACTIVATE:.)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'saltstack/salt-vim'

" GoLang
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Plug 'fatih/vim-go'

" DevOps Syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plug 'chr4/nginx.vim'

Plug 'ekalinin/Dockerfile.vim'

call plug#end()
"
" ########################################################################
"
source ~/.vim/powerline.vim

let g:trans_bin = "~/.vim"

set laststatus=2
nnoremap <silent> <leader>n :NERDTreeToggle<CR>
nnoremap <leader>v :vsplit<CR>
nnoremap <leader>s :split<CR>

map d<cr> <cr>:NERDTreeClose<cr>


set number relativenumber

augroup numbertoggle
  autocmd!
  autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
  autocmd BufLeave,FocusLost,InsertEnter   * set norelativenumber
augroup END


set statusline+=%#warningmsg#
set statusline+=%*

"
"
"
"
"
"""""""""""""""""""""""""""""""

if filereadable(".bookmarks")
    let g:NERDTreeBookmarksFile = ".bookmarks"
endif

nmap <leader>p :FZF<cr>
syntax enable
filetype plugin indent on

"autocmd VimEnter * colorscheme farout
autocmd VimEnter * colorscheme fahrenheit
set bg=light
hi Normal guibg=NONE ctermbg=NONE
"autocmd VimEnter * 


map <C-n> <Plug>(wintabs_previous)
map <C-m> <Plug>(wintabs_next)

set mouse=a
let g:vrc_connect_timeout = 10
let g:vrc_cookie_jar = '/tmp'
let g:vrc_follow_redirects = 1
let g:vrc_include_response_header = 1
let g:vrc_max_time = 60
let g:vrc_resolve_to_ipv4 = 1
let g:vrc_ssl_secure = 1

set foldmethod=syntax   
set foldnestmax=10
set foldenable
set foldlevel=4

set foldnestmax=10
"set nofoldenable
"set foldlevel=1
"let g:tex_fold_enabled=1
"let g:vimsyn_folding='af'
"let g:xml_syntax_folding = 1
"let g:php_folding = 1
"let g:perl_fold = 1

let g:SimpylFold_docstring_preview = 1

let g:startify_custom_header = []

function! s:list_commits()
    let git = 'git -C ./'
    let commits = systemlist(git .' log --oneline | head -n10')
    let git = 'G'. git[1:]
    return map(commits, '{"line": matchstr(v:val, "\\s\\zs.*"), "cmd": "'. git .' show ". matchstr(v:val, "^\\x\\+") }')
endfunction

let g:startify_session_dir = $HOME .  '/.vim/sessions/'

let g:startify_lists = [
    \ { 'header': ['   Ostatnio edytowane'], 'type': 'dir' },
    \ { 'header': ['   Zapisane sesje'],       'type': 'sessions' },
    \ { 'header': ['   Ostatnie zmiany'],        'type': function('s:list_commits') },
    \ { 'header': ['   Zakładki'],       'type': 'bookmarks' },
\ ]

let g:startify_files_number = 6

let g:startify_bookmarks = [ 
    \ {'c': '~/.vimrc'}, 
    \ {'z': '~/.zshrc'},
    \ {'v': '~/.vim/common.vim'},
    \ {'b': '~/.vim/binds.vim'},
    \ {'p': '~/.vim/powerline.vim'},
\ ]

let g:startify_update_oldfiles = 1
let g:startify_disable_at_vimenter = 0
let g:startify_session_autoload = 1
let g:startify_session_persistence = 1
"let g:startify_session_delete_buffers = 0
let g:startify_change_to_dir = 0
"let g:startify_change_to_vcs_root = 0  " vim-rooter has same feature
let g:startify_skiplist = [
      \ 'COMMIT_EDITMSG',
      \ escape(fnamemodify(resolve($VIMRUNTIME), ':p'), '\') .'doc',
      \ 'bundle/.*/doc',
      \ ]

augroup startify_map
  au!
  autocmd FileType startify nnoremap <buffer> <F2> <Nop>
  if !exists('g:startify_custom_header')
    autocmd FileType startify call <SID>update_logo()
  endif
  autocmd FileType startify setl nowrap
augroup END


" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()

" IMPORTANTE: :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect

set hidden

"  _____                 ____            _       _
" |_   _|   _ _ __   ___/ ___|  ___ _ __(_)_ __ | |_
"   | || | | | '_ \ / _ \___ \ / __| '__| | '_ \| __|
"  _| || |_| | |_) |  __/___) | (__| |  | | |_) | |_
" (_)_| \__, | .__/ \___|____/ \___|_|  |_| .__/ \__|
"       |___/|_|                          |_|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""




"          _
"    _ __ | |__  _ __
"   | '_ \| '_ \| '_ \
"  _| |_) | | | | |_) |
" (_) .__/|_| |_| .__/
"   |_|         |_|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <silent><leader>pcf :call PhpCsFixerFixFile()<CR>

let g:pdv_template_dir = $HOME ."/.vim/plugged/pdv/templates_snip"

autocmd BufWritePost *.php silent! call PhpCsFixerFixFile()
autocmd FileType php setlocal omnifunc=phpactor#Complete

" Include use statement
nmap <Leader>u :call phpactor#UseAdd()<CR>
" Invoke the context menu
nmap <Leader>mm :call phpactor#ContextMenu()<CR>
" Invoke the navigation menu
nmap <Leader>nn :call phpactor#Navigate()<CR>
" Goto definition of class or class member under the cursor
" Include use statement
nmap <Leader>u :call phpactor#UseAdd()<CR>
" Invoke the context menu
nmap <Leader>mm :call phpactor#ContextMenu()<CR>
" Invoke the navigation menu
nmap <Leader>nn :call phpactor#Navigate()<CR>
" Goto definition of class or class member under the cursor
nmap <Leader>o :call phpactor#GotoDefinition()<CR>
" Transform the classes in the current file
nmap <Leader>tt :call phpactor#Transform()<CR>
" Generate a new class (replacing the current file)
nmap <Leader>cc :call phpactor#ClassNew()<CR>
" Extract expression (normal mode)
nmap <silent><Leader>ee :call phpactor#ExtractExpression(v:false)<CR>
" Extract expression from selection
vmap <silent><Leader>ee :<C-U>call phpactor#ExtractExpression(v:true)<CR>
" Extract method from selection
vmap <silent><Leader>em :<C-U>call phpactor#ExtractMethod()<CR>
nmap <Leader>o :call phpactor#GotoDefinition()<CR>
" Transform the classes in the current file
nmap <Leader>tt :call phpactor#Transform()<CR>
" Generate a new class (replacing the current file)
nmap <Leader>cc :call phpactor#ClassNew()<CR>

let g:vim_php_refactoring_use_default_mapping = 0

" nnoremap <unique> <Leader>rlvar :call PhpRenameLocalVariable()<CR>
"nnoremap <unique> <Leader>rcvar :call PhpRenameClassVariable()<CR>
"nnoremap <unique> <Leader>rm :call PhpRenameMethod()<CR>
"nnoremap <unique> <Leader>eu :call PhpExtractUse()<CR>
vnoremap <unique> <Leader>ec :call PhpExtractConst()<CR>
"nnoremap <unique> <Leader>ep :call PhpExtractClassProperty()<CR>
" vnoremap <unique> <Leader>emm :call PhpExtractMethod()<CR>
"nnoremap <unique> <Leader>np :call PhpCreateProperty()<CR>
nnoremap <unique> <Leader>du :call PhpDetectUnusedUseStatements()<CR>
vnoremap <unique> <Leader>aa :call PhpAlignAssigns()<CR>
nnoremap <unique> <Leader>sg :call PhpCreateSettersAndGetters()<CR>
"nnoremap <unique> <Leader>cog :call PhpCreateGetters()<CR>
"nnoremap <unique> <Leader>da :call PhpDocAll()<CR>
nnoremap <unique> <Leader>da :call pdv#DocumentWithSnip()<CR><Paste>

let g:vdebug_options = {
    \    'port' : 9009,
    \    'timeout' : 20,
    \    'server' : '',
    \    'on_close' : 'stop',
    \    'break_on_open' : 1,
    \    'ide_key' : '',
    \    'debug_window_level' : 0,
    \    'debug_file_level' : 0,
    \    'debug_file' : '',
    \    'path_maps' : {},
    \    'watch_window_style' : 'expanded',
    \    'marker_default' : '⬦',
    \    'marker_closed_tree' : '▸',
    \    'marker_open_tree' : '▾',
    \    'sign_breakpoint' : '▷',
    \    'sign_current' : '▶',
    \    'continuous_mode'  : 1
    \}
<

" Extract expression (normal mode)

" let $NVIM_PYTHON_LOG_FILE="/tmp/nvim_log"
" let $NVIM_PYTHON_LOG_LEVEL="DEBUG"
