Skip to content

Instantly share code, notes, and snippets.

@ourway
Created March 29, 2023 00:41
Show Gist options
  • Save ourway/b6d553f3c409fa5f10346637a9b15be4 to your computer and use it in GitHub Desktop.
Save ourway/b6d553f3c409fa5f10346637a9b15be4 to your computer and use it in GitHub Desktop.
" Helps force plugins to load correctly when it is turned back on below
filetype off
" Install vim plug if not installed
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Plugs
call plug#begin('~/.vim/plugged')
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
"let g:deoplete#enable_at_startup = 1
Plug 'elixir-editors/vim-elixir'
Plug 'mhinz/vim-mix-format'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'tpope/vim-sensible'
Plug 'maralla/completor.vim'
Plug 'davidhalter/jedi-vim'
Plug 'notpratheek/vim-luna'
Plug 'SirVer/ultisnips'
Plug 'rust-lang/rust.vim'
Plug 'sonph/onehalf', { 'rtp': 'vim' }
Plug 'bfrg/vim-cpp-modern'
Plug 'vim-syntastic/syntastic'
Plug 'honza/vim-snippets'
Plug 'beautify-web/js-beautify'
Plug 'mattn/webapi-vim'
Plug 'towolf/vim-helm'
Plug 'stephpy/vim-yaml'
Plug 'morhetz/gruvbox'
Plug 'cormacrelf/vim-colors-github'
Plug 'evanleck/vim-svelte'
Plug 'xavierd/clang_complete'
Plug 'preservim/nerdtree'
Plug 'mxw/vim-jsx'
Plug 'pangloss/vim-javascript'
Plug 'vim-erlang/vim-erlang-compiler'
Plug 'vim-erlang/vim-erlang-omnicomplete'
Plug 'vim-erlang/vim-erlang-runtime'
Plug 'vim-erlang/vim-erlang-skeletons'
Plug 'tomasr/molokai'
Plug 'vim-erlang/vim-erlang-tags'
"Plug 'camspiers/animate.vim'
"Plug 'camspiers/lens.vim'
Plug 'vim-erlang/erlang-motions.vim'
"Plug 'ycm-core/YouCompleteMe'
Plug 'fatih/vim-go'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'pappasam/coc-jedi', { 'do': 'yarn install --frozen-lockfile && yarn build', 'branch': 'main' }
"Plug 'ervandew/supertab'
"Plug 'skywind3000/asyncrun.vim'
"Plug 'nvie/vim-flake8'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
"Plug 'pangloss/vim-javascript'
"Plug 'leafgarland/typescript-vim'
"Plug 'MaxMEllon/vim-jsx-pretty'
"Plug 'chriskempson/base16-vim'
Plug 'deoplete-plugins/deoplete-jedi'
Plug 'vim-python/python-syntax'
Plug 'psf/black', { 'tag': '23.1.0' }
Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
Plug 'mileszs/ack.vim'
Plug 'github/copilot.vim'
Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
call plug#end()
" sets
set shell=/bin/zsh
set tabstop=4
set softtabstop=4
set noet
set shiftwidth=4
set textwidth=120
filetype indent on
set modeline
set foldmethod=syntax
set foldlevelstart=64
set nocompatible
set hidden
set ttyfast
"set lazyredraw " don't redraw everytime
set synmaxcol=128 " avoid slow rendering for long lines
set report =0 " Always report changed lines.
set wrapscan
set ruler
set splitbelow " Open new windows below the current window.
set splitright " Open new windows right of the current window.
set relativenumber
"set number
set noswapfile
set exrc
set secure
set noerrorbells
"set clipboard+=unnamedplus
set wildmode=longest:full,full
set timeout
set ttimeout
set timeoutlen=500
set ttimeoutlen=50
set autoindent
set fileformat=unix
set listchars=eol:¬,tab:▷\ ,
set indentkeys=o,O
set mouse=a
set shiftround
set showbreak=
set backupcopy=yes
set breakindent
set autoread
"set display=lastline
set backspace=indent,eol,start
set laststatus =2 " Always show statusline.
set virtualedit=onemore
"set fillchars=vert:\ ,fold:-,diff:· " Spaces are enough for vertical split separators.
"set diffopt=filler,foldcolumn:0,vertical " Show lines where missing, no need for a foldcolumn during diff, split vertically by default
set updatetime=1000
autocmd CursorHoldI * call feedkeys("\<C-G>u", "nt")
nnoremap j gj
nnoremap k gk
if has('persistent_undo') "check if your vim version supports
set undodir=$HOME/.vim/undo "directory where the undo files will be stored
set undofile "turn on the feature
endif
" Searching
"nnoremap / /\v
"vnoremap / /\v
set hlsearch
set incsearch
set showmode
set showcmd
set ignorecase
set smartcase
set smarttab
set showmatch
map <leader><space> :let @/=''<cr> " clear search
" Return to last edit position when opening files (You want this!)
"
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
" config
let g:mix_format_on_save = 1
let g:jsx_ext_required = 0
let mapleader = ","
noremap ,e :Files <CR>
if exists(':terminal')
let g:terminal_color = 'xterm'
" allow terminal buffer size to be very large
let g:terminal_scrollback_buffer_size = 100000
endif
nnoremap <silent> ,n :call ToggleRelativeNumber()<CR>
function! ToggleRelativeNumber()
if(&relativenumber == 1) && (&number == 1)
set nonumber
set norelativenumber
elseif(&number == 1)
set number
set relativenumber
else
set norelativenumber
set number
endif
endfunc
nnoremap <C-N> :bnext<CR>
"nnoremap <TAB> :bnext<CR>
nnoremap <C-P> :bprev<CR>
" Triger `autoread` when files changes on disk
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
" Notification after file change
" https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
augroup black_on_save
autocmd!
autocmd BufWritePre *.py Black
augroup end
let g:black_linelength = 120
nnoremap ,f :Black<CR>
let g:jedi#completions_enabled = 1
let g:jedi#show_call_signatures = 0
"let g:jedi#use_splits_not_buffers = "left"
"let g:jedi#environment_path = "venv"
autocmd FileType python setlocal completeopt-=preview
autocmd FileType *.go execute ':!go fmt %'
let g:python3_host_prog = 'python3'
"let g:pipenv_project_root = expand("~/Develop/scrapers")
let g:pipenv_use_virtualenv = 1
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
"set guicursor=i:blinkwait700-blinkon400-blinkoff250
tnoremap <expr> <Esc> (&filetype == "fzf") ? "<Esc>" : "<c-\><c-n>"
nnoremap <silent> <Tab> :tabnext<CR>
nnoremap <silent> <S-Tab> :tabprevious<CR>
nnoremap <leader>t <Esc>:tabnew<CR>
let g:rg_command = 'rg --vimgrep -S'
let g:python_highlight_all = 1
let g:rustfmt_autosave = 1
let g:rust_clip_command = 'pbcopy'
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
"nnoremap <leader>n :NERDTreeFocus<CR>
"nnoremap <C-t> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
autocmd BufEnter *.{js,jsx,ts,tsx} :syntax sync fromstart
autocmd BufLeave *.{js,jsx,ts,tsx} :syntax sync clear
autocmd Filetype python set et smarttab ts=4 sw=4 list lcs=tab:>-,trail:.,nbsp:_
" Put all temporary files under the same directory.
" https://github.com/mhinz/vim-galore#temporary-files
set backup
set backupdir =$HOME/.vim/files/backup/
set backupext =-vimbackup
set backupskip =
set directory =$HOME/.vim/files/swap/
set updatecount =100
set undofile
set undodir =$HOME/.vim/files/undo/
set viminfo ='100,n$HOME/.vim/files/info/viminfo
autocmd! GUIEnter * set vb t_vb=
autocmd FileType c,cpp setlocal equalprg=clang-format
" path to directory where library can be found
let g:clang_library_path='/opt/homebrew/opt/llvm/lib'
let skip_defaults_vim=1
set viminfo=""
let g:erlang_tags_auto_update_current=0
let g:erlang_tags_otp=1
set foldcolumn=1
fu! SaveSess()
execute 'mksession! ' . getcwd() . '/.Session.vim'
endfunction
fu! RestoreSess()
if filereadable(getcwd() . '/.Session.vim')
execute 'so ' . getcwd() . '/.Session.vim'
if bufexists(1)
for l in range(1, bufnr('$'))
if bufwinnr(l) == -1
exec 'sbuffer ' . l
endif
endfor
endif
endif
endfunction
"autocmd VimLeave * call SaveSess()
"autocmd VimEnter * nested call RestoreSess()
"
augroup vimrc_autocmds
au!
autocmd BufRead * highlight OverLength ctermbg=darkred ctermfg=white guibg=#592929
autocmd BufRead * match OverLength /\%120v.*/
augroup END
let g:prettier#exec_cmd_path = "/opt/homebrew/bin/prettier"
let g:prettier#autoformat = 1
set rtp+=~/.vim/plugins
"source ~/.vim/plugins/important.vim
let g:clang_library_path="/Library/Developer/CommandLineTools/usr/lib/libclang.dylib"
if executable('ag')
let g:ackprg = 'ag --vimgrep --nocolor --column'
endif
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
set background=dark
colorscheme molokai
let g:syntastic_python_checkers = ['pylint']
"https://stackoverflow.com/questions/16595268/vim-split-window-focus-new-window
set splitbelow
set splitright
autocmd BufRead,BufNewFile Jenkinsfile set filetype=groovy
augroup restore_pos | au!
au BufWinEnter *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe 'normal! g`"zz'
\ | endif
augroup end
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") && &filetype != "gitcommit" |
\ execute("normal `\"") |
\ endif
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment