Skip to content

Instantly share code, notes, and snippets.

@Charl13
Last active June 21, 2021 14:53
Show Gist options
  • Save Charl13/b1c00e81dc286b2a8bd1c4ead0864c07 to your computer and use it in GitHub Desktop.
Save Charl13/b1c00e81dc286b2a8bd1c4ead0864c07 to your computer and use it in GitHub Desktop.
" ============================================================================ "
" === PLUGINS === "
" ============================================================================ "
"
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')
" Text manipulation
Plug 'tpope/vim-surround' " Surroundings
Plug 'junegunn/vim-peekaboo' " Clipboard (Vim register) preview
Plug 'swekaj/php-foldexpr.vim' " Support for PHP syntax folding
Plug 'FooSoft/vim-argwrap' " (Un)wrapping bracket contents
" Search an replace variants of word(s)
Plug 'tpope/vim-abolish'
" Git support in Vim
Plug 'tpope/vim-fugitive' " Main support
Plug 'sodapopcan/vim-twiggy' " Branch management
Plug 'junegunn/gv.vim' " Log
Plug 'mhinz/vim-signify' " Status in sign column
Plug 'shumphrey/fugitive-gitlab.vim' " Open Gitlab URLs using :Gbrowse
" Fuzzy finding files
Plug 'Shougo/denite.nvim'
" Language server protcol, diagnostics and refactoring
Plug 'neoclide/coc.nvim', {'branch': 'release'} " IntelliSense enigne
Plug 'phpactor/phpactor', {'for': 'php', 'branch': 'master', 'do': 'composer install --no-dev -o'} " PHP refactoring
Plug 'elythyr/phpactor-mappings' " Key mapping for PHP actor (not using?)
" Snippets
Plug 'SirVer/ultisnips' " Autocomplete engine
Plug 'honza/vim-snippets' " Common snippets
Plug 'sniphpets/sniphpets' " Helper functions for creating php snippets
Plug 'sniphpets/sniphpets-symfony' " Symfony snippets (Ultisnips)
Plug 'sniphpets/sniphpets-doctrine' " Doctrine snippets (Ultisnips)
" Plug 'onecentlin/laravel5-snippets-vscode' " Laravel snippets (VSCode)
" Plug 'onecentlin/laravel-blade-snippets-vscode' " Laravel blade snippets (VSCode) (doesnt work?)
" Plug 'nalabdou/Symfony-code-snippets', {'do': 'yarn install --frozen-lockfile'} " Symfony snippets (VSCode) (doesnt work?)
" Syntax and color scheme
Plug 'zeis/vim-kolor' " Color scheme
Plug 'jwalton512/vim-blade' " Blade syntax highlighting
Plug 'lumiliet/vim-twig' " Twig syntax highlighting
Plug 'dominikduda/vim_current_word' " Highlight words matching word under cursor
Plug 'jackguo380/vim-lsp-cxx-highlight' " C(++) syntax highlighting
" Navigation
Plug 'tpope/vim-unimpaired'
" Initialize plugin system
call plug#end()
let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-html', 'coc-snippets', 'coc-explorer', 'coc-diagnostic', 'coc-vetur', 'coc-tsserver', 'coc-phpls', 'coc-css']
" ============================================================================ "
" === Ultisnips configuration === "
" ============================================================================ "
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
" ============================================================================ "
" === Denite configuration === "
" ============================================================================ "
" Use ripgrep for searching current directory for files
" By default, ripgrep will respect rules in .gitignore
" --files: Print each file that would be searched (but don't search)
" --glob: Include or exclues files for searching that match the given glob
" (aka ignore .git files)
call denite#custom#var('file/rec', 'command', ['ag', '--skip-vcs-ignores', '--ignore', 'node_modules', '--hidden', '--follow', '--nogroup', '-g', ''])
call denite#custom#var('grep', 'command', ['ag'])
call denite#custom#var('grep', 'default_opts', ['-i', '--vimgrep', '--skip-vcs-ignores'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', [])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
call denite#custom#var('buffer', 'date_format', '') " Remove date from buffer list
let s:denite_options = {
\ 'split': 'floating',
\ 'winwidth': &columns / 4 * 3,
\ 'winheight': 15,
\ 'wincol': &columns / 8,
\ 'winrow': (&lines / 3 * 2) - 5,
\ 'preview_height': '80',
\ 'start_filter': 1,
\ 'auto_resize': 1,
\ 'source_names': 'short',
\ 'prompt': '>:',
\ 'statusline': 0,
\ 'highlight_matched_char': 'WildMenu',
\ 'highlight_matched_range': 'Visual',
\ 'highlight_window_background': 'Visual',
\ 'highlight_filter_background': 'StatusLine',
\ 'highlight_prompt': 'StatusLine'
\ }
" Custom options for Denite
call denite#custom#option('default', s:denite_options)
" Update result when typing in large projects
call denite#custom#option('_', 'max_dynamic_update_candidates', 100000)
" ============================================================================ "
" === GIT configuration === "
" ============================================================================ "
" function! ToggleGStatus()
" if buflisted(bufname('.git/index'))
" bd .git/index
" else
" Gstatus
" endif
" endfunction
"
" command ToggleGStatus :call ToggleGStatus()
" ============================================================================ "
" === Key bindings === "
" ============================================================================ "
let g:mapleader=',' " Remap leader key
" === Denite === "
" ; - Browser currently open buffers
" <leader>t - Browse list of files in current directory
" <leader>g - Search current directory for occurences of given term and close window if no results
" <leader>j - Search current directory for occurences of word under cursor
nmap ; :Denite buffer<CR>
nmap <leader>t :DeniteProjectDir file/rec<CR>
nnoremap <leader>g :<C-u>Denite grep:. -no-empty<CR>
nnoremap <leader>j :<C-u>DeniteCursorWord grep:.<CR>
" === Denite window in filter mode === "
autocmd FileType denite-filter call s:denite_filter_my_settings()
function! s:denite_filter_my_settings() abort
inoremap <silent><buffer><expr> <c-t> denite#do_map('do_action', 'tabopen')
inoremap <silent><buffer><expr> <c-v> denite#do_map('do_action', 'vsplit')
inoremap <silent><buffer><expr> <c-h> denite#do_map('do_action', 'split')
inoremap <silent><buffer><expr> <Esc> denite#do_map('quit')
nnoremap <silent><buffer><expr> <Esc> denite#do_map('quit')
imap <silent><buffer> <C-o> <Plug>(denite_filter_quit)
endfunction
" === Denite window shortcuts === "
autocmd FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
nnoremap <silent><buffer> <c-r>
\ :<c-u>call <SID>denite_quickfix()<CR>
nnoremap <silent><buffer><expr> <CR> denite#do_map('do_action')
nnoremap <silent><buffer><expr> d denite#do_map('do_action', 'delete')
nnoremap <silent><buffer><expr> p denite#do_map('do_action', 'preview')
nnoremap <silent><buffer><expr> T denite#do_map('do_action', 'tabopen')
nnoremap <silent><buffer><expr> v denite#do_map('do_action', 'vsplit')
nnoremap <silent><buffer><expr> h denite#do_map('do_action', 'split')
nnoremap <silent><buffer><expr> <ESC> denite#do_map('quit')
nnoremap <silent><buffer><expr> <Space> denite#do_map('toggle_select').'j'
nnoremap <silent><buffer><expr> i denite#do_map('open_filter_buffer')
endfunction
function! s:denite_quickfix()
call denite#call_map('toggle_select_all')
call denite#call_map('do_action', 'quickfix')
endfunction
" === GIT == "
" <leader>b - Show GIT branches
" <leader>s - Show GIT status
" map <leader>b :Twiggy<CR>
" map <leader>s :Gstatus<CR>
" nmap <leader>s :ToggleGStatus<CR>
" === CoC === "
" <leader>dd - Search definitions of word under the cursor
" <leader>dr - Search search references of word under the cursor
" <leader>di - Search implementations of word under the cursor
" <leader>n - Browse list of files in current directory
nmap <silent> <leader>dd <Plug>(coc-definition)
nmap <silent> <leader>dr <Plug>(coc-references)
nmap <silent> <leader>di <Plug>(coc-implementation)
map <leader>n :CocCommand explorer
\ --toggle
\ --width 55
\ --sources=buffer+,file+<CR>
" === VIM === "
" <leader>r - Search and replace word under cursor
" <leader>a - Wrap or Unwrap arguments on line
nnoremap J gJ
nmap <leader>r :%s/\<<c-r><c-w>\>//g<left><left>
vmap <leader>r :s/\<<c-r><c-w>\>//g<left><left>
" === ArgWrap === "
nnoremap <silent> <leader>a :ArgWrap<CR>
" === PHPActor === "
nmap <Leader>am :call phpactor#ContextMenu()<CR>
nmap <Leader>at :call phpactor#Transform()<CR>
vmap <silent><Leader>ae :<C-U>call phpactor#ExtractMethod()<CR>
" === GIT == "
" <leader>b - Show branches
" <leader>s - Show status (fuzzy search)
" <leader>c - Show commits of current file (fuzzy search)
nnoremap <leader>s :CocList --auto-preview gstatus<CR>
nnoremap <leader>c :CocList --normal --auto-preview bcommits<CR>
nnoremap <leader>b :CocList branches<CR>
" navigate chunks of current buffer
nmap [g <Plug>(coc-git-prevchunk)
nmap ]g <Plug>(coc-git-nextchunk)
" navigate conflicts of current buffer
nmap [c <Plug>(coc-git-prevconflict)
nmap ]c <Plug>(coc-git-nextconflict)
" show chunk diff at current cursor position
nmap gs <Plug>(coc-git-chunkinfo)
nmap ga <Plug>(coc-git-chunkstage)
nmap gu <Plug>(coc-git-chunkundo)
" ============================================================================ "
" === Colors === "
" ============================================================================ "
" === GIT sign column colors === "
" highlight SignifySignAdd ctermfg=NONE guifg=#00ff00 cterm=NONE gui=NONE ctermbg=NONE
" highlight SignifySignDelete ctermfg=NONE guifg=#ff0000 cterm=NONE gui=NONE ctermbg=NONE
" highlight SignifySignChange ctermfg=NONE guifg=#ffff00 cterm=NONE gui=NONE ctermbg=NONE
highlight CurrentWordTwins guifg=#ff8787 ctermfg=210
highlight CurrentWord guifg=#ff5f87 gui=bold ctermfg=204 cterm=bold
highlight SignColumn ctermbg=NONE cterm=NONE guibg=NONE gui=NONE
let g:signify_sign_add = '✚'
let g:signify_sign_delete = '✂'
let g:signify_sign_delete_first_line = '✂'
let g:signify_sign_change = '✏'
set cursorline " Highlight line of cursor
" === Additional C(++) colors === "
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
" ============================================================================ "
" === Folding === "
" ============================================================================ "
autocmd BufEnter *.php let b:phpfold_text_right_lines = 1
autocmd BufEnter *.php let b:phpfold_docblocks = 1
autocmd BufEnter *.php let b:phpfold_doc_with_funcs = 1
autocmd BufEnter *.php let b:phpfold_text = 0
autocmd BufEnter *.php let b:phpfold_group_args = 0
set foldlevel=8
colorscheme kolor
" ============================================================================ "
" === Misc === "
" ============================================================================ "
set nolazyredraw " Attempt to fix redrawing issue
set number " Show current line number
set relativenumber " Show relative line numbers
set noswapfile " Disable .swp files
let g:fugitive_gitlab_domains = ['https://gitlab.pxlwidgets.com']
function s:coc_list_current_dir(args)
let node_info = CocAction('runCommand', 'explorer.getNodeInfo', 0)
if node_info isnot v:null && node_info['expandable']
execute 'cd ' . node_info['fullpath']
execute 'CocList ' . a:args
else
execute 'cd ' . fnamemodify(node_info['fullpath'], ':h')
execute 'CocList ' . a:args
endif
endfunction
function SearchWithDenite()
let node_info = CocAction('runCommand', 'explorer.getNodeInfo', 0)
execute 'Denite grep:' . node_info['fullpath'] . ' -no-empty -no-start-filter'
endfunction
nnoremap <leader>f :call SearchWithDenite()<CR>
packadd termdebug
let g:termdebug_wide=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment