Last active
August 18, 2021 20:12
-
-
Save lamdor/7b4520ac3b1c104dba8418b60a4d95eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Turn on syntax highlighting | |
syntax on | |
" For plugins to load correctly | |
filetype plugin indent on | |
let mapleader = " " | |
" Security: do not trust modelines set in files | |
set modelines=0 | |
" Show line numbers | |
set number | |
" Show file stats | |
set ruler | |
" Blink cursor on error instead of beeping (grr) | |
set visualbell | |
" Encoding | |
set encoding=utf-8 | |
" Whitespace | |
set wrap | |
set textwidth=0 | |
set formatoptions=tcqrn1 | |
set tabstop=4 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
set noshiftround | |
" Copy paste from clipboard shortcuts | |
nnoremap <leader>y "+y | |
nnoremap <leader>p "+p | |
nnoremap <leader>P "+P | |
vnoremap <leader>y "+y | |
vnoremap <leader>p "+p | |
" Cursor motion | |
set scrolloff=3 | |
set backspace=indent,eol,start | |
set matchpairs+=<:> " use % to jump between pairs | |
runtime! macros/matchit.vim | |
" Move up/down editor lines | |
nnoremap j gj | |
nnoremap k gk | |
" Allow hidden buffers without complaining | |
set hidden | |
" Rendering | |
set ttyfast | |
" Ex command history | |
set history=200 | |
" allow %% to expand to directory of current file in command line mode | |
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' | |
" use leader ew to open relative file, and with splits | |
" this must use map as we want the %% above to expand | |
map <leader>ew :e %% | |
map <leader>es :sp %% | |
map <leader>ev :vsp %% | |
" use leader bd to delete buffer (insetad of :bd) | |
nnoremap <leader>bd :bd<CR> | |
" Always show the status line for all windows. | |
set laststatus=2 | |
" Last line | |
set showmode | |
set showcmd | |
" Wrap lines | |
set wrap | |
set linebreak | |
" Undo | |
set undofile | |
set undodir=$HOME/.vim_undo | |
" Automatically read a file from disk if changed. In tmux, relies on focus | |
" events below | |
set autoread | |
autocmd FocusGained,BufEnter * :checktime | |
" Searching | |
nnoremap / /\v | |
vnoremap / /\v | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
set showmatch | |
nnoremap <leader><leader> :let @/=''<cr> " clear search | |
if has('nvim') | |
set inccommand=nosplit | |
endif | |
" use ripgrep for grep | |
set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case | |
" set grepformat=$f:$l:%c:%m | |
" Color scheme (terminal) | |
set t_Co=256 | |
set background=dark | |
" do not autowrap text when inserting text | |
set formatoptions-=t | |
" do not show preview of completion in window | |
set completeopt-=preview | |
" commands to cd quickly to common dirs | |
command! Envs cd ~/code/b/environments | |
command! Banno cd ~/code/b | |
" maybe change to use https://stackoverflow.com/questions/59111740/fzf-vim-changing-working-directory-on-the-fly | |
nnoremap <Leader>B :Banno<CR>:cd | |
" a nice way to cd to the git root | |
function Cg() | |
execute 'cd'.system('git rev-parse --show-toplevel') | |
endfunction | |
command! Cg call Cg() | |
nnoremap <Leader>cg :Cg<CR> | |
" get to the gh command line tool faster | |
" and it has to run in a terminal because | |
" many of the commands are interactive | |
map <leader>gh :terminal gh | |
" custom filetypes for extensions | |
autocmd BufRead,BufNewFile *.thor set filetype=ruby | |
autocmd BufRead,BufNewFile *.sh.tpl set filetype=sh | |
autocmd BufRead,BufNewFile Jenkinsfile* set filetype=groovy | |
autocmd BufRead,BufNewFile PULLREQ_EDITMSG set filetype=markdown | |
" nvim | |
if has('nvim') | |
" terminal mode to normal mode | |
tnoremap <Esc> <C-\><C-n> | |
tnoremap <C-v><Esc> <Esc> | |
" make the terminal cursor stand out | |
highlight TermCursor ctermfg=red guifg=red | |
if executable('nvr') | |
let $VISUAL="nvr -cc split --remote-wait +'set bufhidden=wipe'" | |
endif | |
endif | |
packadd minpac | |
call minpac#init() | |
call minpac#add('k-takata/minpac', {'type': 'opt'}) | |
command! PackUpdate call minpac#update() | |
command! PackClean call minpac#clean() | |
call minpac#add('tmux-plugins/vim-tmux-focus-events') | |
call minpac#add('roxma/vim-tmux-clipboard') | |
call minpac#add('sgur/vim-editorconfig') | |
call minpac#add('tpope/vim-eunuch') | |
call minpac#add('tpope/vim-unimpaired') | |
call minpac#add('tpope/vim-surround') | |
call minpac#add('tpope/vim-commentary') | |
call minpac#add('junegunn/fzf') | |
call minpac#add('junegunn/fzf.vim') | |
nnoremap <Leader>s :Files<CR> | |
nnoremap <Leader>h :History<CR> | |
nnoremap <Leader>: :History:<CR> | |
" needs to be two to be fast with the <leader>bd for buffer delete | |
nnoremap <Leader>bb :Buffers<CR> | |
nnoremap <Leader>l :BLines<CR> | |
nnoremap <Leader>/ :Rg<CR> | |
command! -bang -nargs=* Rg | |
\ call fzf#vim#grep( | |
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1, | |
\ <bang>0 ? fzf#vim#with_preview('up:60%') | |
\ : fzf#vim#with_preview('right:50%:hidden', '?'), | |
\ <bang>0) | |
call minpac#add('Shougo/deoplete.nvim') | |
call minpac#add('roxma/vim-hug-neovim-rpc') " required by deoplete | |
let g:deoplete#enable_at_startup = 1 | |
call minpac#add('tpope/vim-dispatch') | |
call minpac#add('radenling/vim-dispatch-neovim') | |
call minpac#add('tpope/vim-fugitive') | |
nnoremap <Leader>g :G | |
nnoremap <Leader>gs :Git<CR> | |
call minpac#add('airblade/vim-gitgutter') | |
call minpac#add('w0rp/ale') | |
" Always run enabled fixers on save | |
let g:ale_fix_on_save = 1 | |
" always keep the sign gutter open | |
let g:ale_sign_column_always = 1 | |
" Mappings in the style of unimpaired-next | |
nmap <silent> [W <Plug>(ale_first) | |
nmap <silent> [w <Plug>(ale_previous) | |
nmap <silent> ]w <Plug>(ale_next) | |
nmap <silent> ]W <Plug>(ale_last) | |
nnoremap gd :ALEGoToDefinition<CR> | |
set omnifunc=ale#completion#OmniFunc | |
call minpac#add('mhinz/vim-grepper') | |
let g:grepper = {} | |
let g:grepper.tools = ['rg', 'git', 'grep'] | |
" search for the current word | |
nnoremap <Leader>* :Grepper -cword -noprompt<CR> | |
nnoremap <Leader>gg :Grepper -tool rg<CR> | |
nnoremap gs <plug>(GrepperOperator) | |
xnoremap gs <plug>(GrepperOperator) | |
cabbrev grep GrepperRg | |
call minpac#add('stefandtw/quickfix-reflector.vim') | |
call minpac#add('unblevable/quick-scope') | |
call minpac#add('connorholyday/vim-snazzy') | |
let g:SnazzyTransparent = 1 | |
colorscheme snazzy | |
call minpac#add('hashivim/vim-terraform') | |
call minpac#add('JuliaEditorSupport/julia-vim') | |
call minpac#add('itchyny/lightline.vim') | |
let g:lightline = { | |
\ 'colorscheme': 'snazzy', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] | |
\ }, | |
\ 'component_function': { | |
\ 'gitbranch': 'fugitive#head', | |
\ 'filename': 'LightlineFilenameRelative' | |
\ }, | |
\ } | |
function! LightlineFilenameRelative() | |
let filename = expand('%:.') !=# '' ? expand('%:.') : '[No Name]' | |
return filename | |
endfunction | |
call minpac#add('edkolev/tmuxline.vim') | |
let g:tmuxline_powerline_separators = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment