Skip to content

Instantly share code, notes, and snippets.

@bdougie
Last active November 8, 2021 19:00
Show Gist options
  • Select an option

  • Save bdougie/ac44feceeb5ba90e7614567939a606e6 to your computer and use it in GitHub Desktop.

Select an option

Save bdougie/ac44feceeb5ba90e7614567939a606e6 to your computer and use it in GitHub Desktop.
nvim config
set nocompatible " be improved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin() " required
Plugin 'VundleVim/Vundle.vim' " required
" Word wrap
set wrap
set textwidth=80
"omnicomplete
set omnifunc=syntaxcomplete#Complete
" ===================
" my plugins here
" ===================
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
Plugin 'https://github.com/gorodinskiy/vim-coloresque.git'
Plugin 'cakebaker/scss-syntax.vim'
" Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'skalnik/vim-vroom'
" Plugin 'farseer90718/flattr.vim'
Plugin 'lmeijvogel/vim-yaml-helper'
Plugin 'rizzatti/dash.vim'
Plugin 'thoughtbot/vim-rspec'
Plugin 'https://github.com/scrooloose/nerdcommenter'
Plugin 'fatih/vim-go'
Plugin 'rust-lang/rust.vim'
" Plugin 'millermedeiros/vim-esformatter'
Plugin 'lambdatoast/elm.vim'
Plugin 'mxw/vim-jsx'
Plugin 'mileszs/ack.vim'
Plugin 'posva/vim-vue'
Plugin 'digitaltoad/vim-pug'
Plugin 'reasonml/vim-reason-loader'
Plugin 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql'] }
call vundle#end() " required
filetype plugin indent on " required
" .vimrc.after is loaded after the plugins have loaded
" Source the vimrc file after saving it
if has("autocmd")
autocmd bufwritepost .vimrc source $MYVIMRC
endif
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
" bind \ (backward slash) to grep shortcut
nnoremap \ :Ag<SPACE>
" bind K to grep word under cursor
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
""""""""""""""""""""""
"""""" Mappings """"""
""""""""""""""""""""""
" mapleader change to <spacebar>
:let mapleader = " "
" prettier
let g:prettier#config#semi = 'true'
let g:prettier#config#single_quote = 'false'
let g:prettier#config#bracket_spacing = 'false'
let g:prettier#config#tab_width = 2
let g:prettier#config#print_width = 120
" vroom commands
let g:vroom_map_keys = 0
nmap <leader>ttt :VroomRunTestFile<CR>
nmap <leader>rr :VroomRunNearestTest<CR>
nmap <leader>ll :VroomRunLastTest<CR>
" RSpec.vim mappings
map <leader>tt :call RunCurrentSpecFile()<CR>
map <leader>s :call RunNearestSpec()<CR>
map <leader>l :call RunLastSpec()<CR>
map <leader>a :call RunAllSpecs()<CR>
" open vim with <leader>v command
nmap <leader>v :edit $MYVIMRC<CR>
" copies the current path to vim clipboard - path, fullpath, just filename
nmap <leader>ff :let @+=expand("%")<CR>
nmap <leader>F :let @+ = expand("%:p")<CR>
nmap <leader>fl :let @+ = expand("%:t")<CR>
" search :Ack actually is <leader>f in terminal vim
nmap <leader>ck :Ack
nmap <leader>gr :grep -F
" toggle spell
nmap <silent> <leader>sp :set spell!<CR>
nmap <silent> <leader>sz 1z=<CR>
" http://vimcasts.org/episodes/spell-checking/
" comment out like sublime
" nmap <D-/> gcc
" maps buffer searching
nmap <leader>bb :ls<CR>
nmap <leader>bl :b#<CR>
nmap <leader>bc :CtrlPBuffer<CR>
" maps vertical and horizontal switching
nmap <leader>H :windo wincmd K<CR>
nmap <leader>h :windo wincmd H<CR>
" open new and split windows
nmap <leader>ss :Sex<CR>
nmap <leader>vv :Vex<CR>
" maps the quit without changes to <leader>q
nmap <leader>q :q!<CR>
" maps spelling mistakes
nmap <leader>e :e.<CR>
" Syntaxt enabling
nmap <leader>1 :syntax enable<CR>
" remove hilights from matched searches
nmap <leader>2 :noh<CR>
" Format JSON Quickly
nmap <leader>3 :%!python -m json.tool<CR>
" copy Sublime indentation rules
" pairing - no indenting for now
" Vjj> instead
" nmap <D-[> <<
" nmap <D-]> >>
" vmap <D-[> <gv
" vmap <D-]> >gv
" move highlighted text
:vmap <C-Right> xpgvlolo
:vmap <C-left> xhPgvhoho
:vnoremap <Left> h
:vnoremap <Right> l
:vnoremap <Up> k
:vnoremap <Down> j
vmap <C-Down> xjPgvjojo
vmap <C-Up> xkPgvkoko
" YAML nav mappings, mainly for the en.yml
nmap <leader>yp :YamlGetFullPath<CR>
nmap <leader>yk :YamlGoToKey
nmap <leader>ym :YamlGoToParent<CR>
" GO run
nmap <leader>gr <Plug>(go-run)
nmap <leader>gob <Plug>(go-build)
nmap <leader>got <Plug>(go-test)
nmap <leader>goc <Plug>(go-coverage)
" dawwP
" dawelp
" hdeep (works at start of first word)
"xdiwdwep"xp (works with most punctuations too)
" Saving, etc
nnoremap <Leader>w :retab<bar>:w<cr> " changes tabs to spaces and save
nnoremap <Leader>wq :retab<bar>:wq<cr> " changes tabs to spaces, saves, and quits
nnoremap <Leader>q :q<cr>
" crete tabs
" no more creating tabs for now
" nmap <leader>ta :tabedit<CR>
" nvm local shortcut
nmap <leader>nvm :! source ~/.nvm/nvm.sh<CR>
" set indent in normal mode to be "="
set autoindent
set cindent
" color scheme
set background=light
" colorscheme github "light
" colorscheme base16-atelierforest "light
" colorscheme base16-atelierseaside "lightgreen
" colorscheme flattr "dark
"" Christian's MakeScript
function! MakeSpec()
let file_path = substitute(expand("%:r"), '^app/', '', '')
:exec ":Espec ". file_path."!"
endfunction
:command! MakeSpec :call MakeSpec()
" grab entire line to move using CRTL + Shift + Direction
function! s:swap_lines(n1, n2)
let line1 = getline(a:n1)
let line2 = getline(a:n2)
call setline(a:n1, line2)
call setline(a:n2, line1)
endfunction
function! s:swap_up()
let n = line('.')
if n == 1
return
endif
call s:swap_lines(n, n - 1)
exec n - 1
endfunction
function! s:swap_down()
let n = line('.')
if n == line('$')
return
endif
call s:swap_lines(n, n + 1)
exec n + 1
endfunction
noremap <silent> <c-s-up> :call <SID>swap_up()<CR>
noremap <silent> <c-s-down> :call <SID>swap_down()<CR>
" test using spring
" let test#ruby#rspec#executable = "spring rspec"
" commonly misspelled words
iabbrev mispell misspell
" eslint for es6 fmt
" will run esformatter after pressing <leader> followed by the 'e' and 's' keys
nnoremap <silent> <leader>esl :Esformatter<CR>
vnoremap <silent> <leader>esl :EsformatterVisual<CR>
let g:syntastic_javascript_checkers = ['eslint']
" let g:syntastic_css_checkers = ['stylelint']
" golint
" set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
" lint on save
" autocmd BufWritePost,FileWritePost *.go execute 'GoLint' | cwindow
" jsx
let g:jsx_ext_required = 0
" #ocamlmerlin
" let g:opamshare = substitute(system('opam config var share'),'\n$','','''')
" execute "set rtp+=" . g:opamshare . "/merlin/vim"
let g:syntastic_ocaml_checkers = ['merlin']
@bdougie
Copy link
Author

bdougie commented Nov 8, 2021

nvim ~/.config/nvim/init.vim

install vundle

clone copilot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment