Skip to content

Instantly share code, notes, and snippets.

@dracorp
Created November 15, 2023 14:12
Show Gist options
  • Save dracorp/14d14e52da6da6747f5be5a9833379a5 to your computer and use it in GitHub Desktop.
Save dracorp/14d14e52da6da6747f5be5a9833379a5 to your computer and use it in GitHub Desktop.
let g:PYTHON3 = has('python3')
let g:PYTHON = has('python') || has('python3')
let g:UNIX = has('unix') || has('macunix') || has('win32unix')
if has('multi_byte')
let g:UNICODE = 0
if &termencoding == ''
let &termencoding = &encoding
endif
if $LC_ALL =~? '\vutf-?8' || $LANG =~? '\vutf-?8'
let g:UNICODE = 1
scriptencoding utf-8
set fileencoding=utf-8
set encoding=utf-8
endif
endif
if !has("compatible")
let vim_plug_path=expand('~/.vim/autoload/plug.vim')
if !filereadable(vim_plug_path)
if !executable("curl")
echoerr "You have to install curl or first install vim-plug yourself!"
execute "q!"
endif
echo "Installing Vim-Plug..."
echo ""
silent exec "!\curl -fLo " . vim_plug_path . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
let vim_plug_just_installed = 1
autocmd VimEnter * PlugInstall
endif
call plug#begin()
Plug 'https://github.com/junegunn/vim-plug'
Plug 'https://github.com/tpope/vim-sensible'
Plug 'https://github.com/preservim/nerdtree.git'
Plug 'https://github.com/ConradIrwin/vim-bracketed-paste'
Plug 'https://github.com/scrooloose/nerdcommenter'
Plug 'https://github.com/godlygeek/tabular'
Plug 'https://github.com/pbrisbin/vim-restore-cursor'
Plug 'https://github.com/vim-scripts/better-whitespace'
Plug 'https://github.com/morhetz/gruvbox'
Plug 'https://github.com/andymass/vim-matchup'
Plug 'https://github.com/tpope/vim-speeddating'
Plug 'https://github.com/ervandew/supertab'
Plug 'https://github.com/editorconfig/editorconfig-vim'
Plug 'https://github.com/AndrewRadev/splitjoin.vim'
Plug 'https://github.com/wgwoods/vim-scripts'
Plug 'https://github.com/mbbill/undotree'
Plug 'https://github.com/itchyny/lightline.vim'
Plug 'https://github.com/mhinz/vim-startify'
call plug#end()
delc PlugUpgrade
" Plugins configuration
silent! colorscheme gruvbox
set background=dark
if has("persistent_undo")
let target_path = expand('~/.vim/undo')
" create the directory and any parent directories
" if the location does not exist.
if !isdirectory(target_path)
call mkdir(target_path, "p", 0700)
endif
let &undodir=target_path
set undofile
nnoremap <F5> :UndotreeToggle<CR>
endif
if !exists("g:lightline")
let g:lightline = {}
endif
let g:lightline.colorscheme = 'gruvbox'
let g:lightline.component_function = {
\ 'filename': 'LightlineFilename',
\ }
let g:lightline.active = {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ }
function! LightlineFilename()
let filename = &filetype ==# 'vimfiler' ? vimfiler#get_status_string() :
\ &filetype ==# 'unite' ? unite#get_status_string() :
\ &filetype ==# 'vimshell' ? vimshell#get_status_string() :
\ expand('%:p') !=# '' ? expand('%:p') : '[No Name]'
let modified = &modified ? ' +' : ''
return filename . modified
endfunction
if has('signs') && version >= 800
set signcolumn=auto " show signcolumns
endif
endif
" Enable 256 color terminal
set t_Co=256
" more colors
if &term =~ "xterm"
if has("terminfo")
set t_Sf="\<Esc>[3%p1%dm"
set t_Sb="\<Esc>[4%p1%dm"
else
set t_Sf="\<Esc>[3%dm"
set t_Sb="\<Esc>[4%dm"
endif
endif
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" indention & tabs
set autoindent " always set autoindenting on
set smartindent " smart autoindenting when starting a new line
set copyindent " copy the previous indentation on autoindenting
" 1 tab == 4 spaces
set tabstop=4 " a tab is four spaces
set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
set shiftwidth=4 " number of spaces to use for autoindenting
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
set expandtab " expand tabs by default (overloadable per file type later)
set shiftround " use multiple of shiftwidth when indenting with '<' and '>
set isfname-== " open file under cursor for entry: VARIABLE=path
set isfname+={,} " open file under cursor with env variable
set iskeyword-=$
set undolevels=1000 " use many muchos levels of undo
set cursorline
set listchars=tab:>-,eol:$,trail:-,nbsp:%
set showmode " always show what mode we're currently editing in
set showmatch " jump to matching parenthesis/bracket
set matchpairs+=<:> " Add HTML brackets to pair matching
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set nojoinspaces " do not insert 2 spaces after .?! when join lines <J>
set splitbelow " command :sp put a new window below the active
set splitright " command :vs put a new windows on right side of active
set tildeop " Tylde(~) behaves like operator
set cmdheight=2 " use a status bar that is 2 rows high
set wildmenu " make tab completion for files/buffers act like bash
set wildmode=list:longest,list:full " show a list when pressing tab and complete
set diffopt+=iwhite " ignore white spaces
set diffopt+=context:3 " context for diff
if has("patch-8.1.0360")
set diffopt+=indent-heuristic
set diffopt+=algorithm:patience
endif
if has('folding')
set foldmethod=marker
" Mappings to easily toggle fold levels
nnoremap z0 :set foldlevel=0<cr>
nnoremap z1 :set foldlevel=1<cr>
nnoremap z2 :set foldlevel=2<cr>
nnoremap z3 :set foldlevel=3<cr>
nnoremap z4 :set foldlevel=4<cr>
nnoremap z5 :set foldlevel=5<cr>
endif
" highlight line under cursor, horizontal cursor
nnoremap <Leader>l :setlocal cursorline!<CR>
nnoremap <Leader>L :setlocal cursorcolumn!<CR>
" change search mapping and don't jump
nnoremap * g*``
nnoremap # g#``
nnoremap g* *``
nnoremap g# #``
" Moving cursor to other windows:
" shift down : change window focus to lower one (cyclic)
" shift up : change window focus to upper one (cyclic)
" shift left : change window focus to one on left
" shift right : change window focus to one on right
nnoremap <s-down> <c-w>w
nnoremap <s-up> <c-w>W
nnoremap <s-left> <c-w>h
nnoremap <s-right> <c-w>l
" Navigate on a wrapped line as the normal
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Up> <C-o>gk
inoremap <Up> <C-o>gk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment