Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ducklin5
Last active September 7, 2020 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducklin5/98dbd76972f40fdfd047a2f5039df0dc to your computer and use it in GitHub Desktop.
Save ducklin5/98dbd76972f40fdfd047a2f5039df0dc to your computer and use it in GitHub Desktop.
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Plugins ---------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
Plug 'mhinz/vim-startify'
Plug 'flazz/vim-colorschemes'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'joshdick/onedark.vim'
Plug 'qualiabyte/vim-colorstepper'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'edkolev/tmuxline.vim'
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'kshenoy/vim-signature'
Plug 'airblade/vim-gitgutter'
Plug 'majutsushi/tagbar'
"Plug 'ludovicchabant/vim-gutentags'
Plug 'Raimondi/delimitMate'
Plug 'Chiel92/vim-autoformat'
Plug 'Shougo/echodoc.vim'
Plug 'Valloric/MatchTagAlways'
"Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'neoclide/jsonc.vim'
Plug 'sheerun/vim-polyglot'
Plug 'calviken/vim-gdscript3'
Plug 'lepture/vim-jinja'
Plug 'lumiliet/vim-twig'
Plug 'klen/python-mode'
Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'}
call plug#end()
" Normal vim settings ---------------------------------------------------------
syntax on
set title
set laststatus=2
set cmdheight=2
set t_Co=256
set cursorline
set cursorcolumn
"set colorcolumn=79
set number
set splitbelow
set mouse=a
set term=xterm-256color
set backspace=indent,eol,start
set smartindent
set shiftwidth=4 tabstop=4
set softtabstop=0 noexpandtab
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
set list
set listchars=tab:»\ ,eol:↪,extends:❯,precedes:❮,trail:·
" keep the list chars 'tranlucent' while editing a line
au VimEnter * call matchadd('SpecialKey', '^\s\+', -1) " tab
au VimEnter * call matchadd('SpecialKey', '\s\+$', -1) " whitespace
au VimEnter * call matchadd('SpecialKey', '\n', -1) " eol
if has('clipboard')
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif
" {{{ --- BackupOnSave---
"Turn on backup option
set backup
set backupdir=~/.vim/backup/
set backupdir=.backup/,~/.vim/backup/,/tmp//
set directory=.swp/,~/.vim/swap/,/tmp//
set undodir=.undo/,~/.vim/undo/,/tmp//
"Make backup before overwriting the current buffer
set writebackup
"Overwrite the original backup file
set backupcopy=yes
"Meaningful backup name, ex: filename@2015-04-05.14:59
au BufWritePre * let &bex = '@' . strftime("%F.%H")
" }}}
"" file detect
filetype plugin indent on
autocmd BufRead,BufNewFile *.gd set filetype=gdscript3
autocmd BufRead,BufNewFile *.twig set filetype=jinja.html.twig
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
autocmd FileType yaml setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType json syntax match Comment +\/\/.\+$+
augroup python_files
autocmd!
autocmd FileType python setlocal expandtab
autocmd FileType python set tabstop=4
autocmd FileType python set shiftwidth=4
augroup END
" Plugin Options --------------------------------------------------------------
" UltiSnips
let g:UltiSnipsExpandTrigger="<c-k>"
let g:UltiSnipsJumpForwardTrigger="<c-k>"
let g:UltiSnipsJumpBackwardTrigger="<c-l>"
let g:UltiSnipsEditSplit="vertical"
"" Colorscheme
color PaperColor
"hi Normal ctermbg=none guibg=none
"" Pymode
let g:pymode_indent = 0
let g:pymode_rope_completion = 1
"" Airline
let g:airline_powerline_fonts = 2
let g:airline_theme='tomorrow'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#coc#enabled = 1
"" Tmuxline
let g:tmuxline_preset = {
\'a' : '#S',
\'c' : ['#(whoami)', '#(uptime | cut -d " " -f 1,2,3)'],
\'win' : ['#I', '#W'],
\'cwin' : ['#I', '#W', '#F'],
\'y' : ['%R', '%a', '%Y'],
\'z' : '#H'}
"" nerdTree
let NERDTreeShowHidden=1
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
autocmd BufWinEnter * silent NERDTreeMirror
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ "Modified" : "✹",
\ "Staged" : "✚",
\ "Untracked" : "✭",
\ "Renamed" : "➜",
\ "Unmerged" : "═",
\ "Deleted" : "✖",
\ "Dirty" : "✗",
\ "Clean" : "✔︎",
\ 'Ignored' : '☒',
\ "Unknown" : "?"
\ }
"" Tagbar
autocmd FileType cpp,c,js,java,gdscript3 call tagbar#autoopen(0)
let g:tagbar_type_css = {
\ 'ctagstype' : 'Css',
\ 'kinds' : [
\ 'c:classes',
\ 's:selectors',
\ 'i:identities'
\ ]
\ }
"" autoformat
let g:formatdef_ClangFormatGoogle = '"clang-format -style=Google"'
let g:formatters_cpp = ['ClangFormatGoogle']
"" MatchTagAlways
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\ 'jinja.html.twig': 1
\}
" Shortcut --------------------------------------------
"" Terminal sends Nul(C-@) instead of Ctrl-Space to vim
imap <C-@> <C-Space>
" Buffer
nnoremap gb :ls<CR>:b<Space>
nnoremap <C-x> :bd<CR>
" Tab navigation like Firefox.
noremap <C-t> :tabnew<CR>
noremap <C-u> :tabnext<CR>
noremap <C-y> :tabprevious<CR>
" {{{ Move windows between tabs
function MoveToPrevTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() != 1
close!
if l:tab_nr == tabpagenr('$')
tabprev
endif
sp
else
close!
exe "0tabnew"
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
function MoveToNextTab()
"there is only one window
if tabpagenr('$') == 1 && winnr('$') == 1
return
endif
"preparing new window
let l:tab_nr = tabpagenr('$')
let l:cur_buf = bufnr('%')
if tabpagenr() < tab_nr
close!
if l:tab_nr == tabpagenr('$')
tabnext
endif
sp
else
close!
tabnew
endif
"opening current buffer in new window
exe "b".l:cur_buf
endfunc
" }}}
noremap <C-i> :call MoveToNextTab()<CR><C-w>H
noremap <C-o> :call MoveToPrevTab()<CR><C-w>H
" Windows
map <C-Up> <C-W>+
map <C-Down> <C-W>-
map <C-Right> <c-w>>
map <C-Left> <c-w><
" Misc.
nnoremap <CR> <esc>i
nnoremap <silent> <Esc><Esc> :noh<CR>
map <C-f> :NERDTreeToggle<CR>
" Use <c-space> to trigger completion.
imap <silent><expr> <c-space> coc#refresh()
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment