" General Settings filetype plugin on " Enable default plugins set nocompatible " Disable vi-compatible set wildmenu " Enable autocomple menu set incsearch " Show search results as typing string set hlsearch " Highlight matches to previos search string set expandtab " In Insert mode: Use the appropriate number of spaces to insert . set tabstop=4 "Number of spaces that a counts for set shiftwidth=0 " Make shiftwidth value the same as tabstop set relativenumber " Use relative numbers in the side bar set nowrap " Turn off text wrapping long lines set history=1000 " Set number of ':' commands set wildmode=list:full " wildmenu show list complete to first result set splitright " New windows split to the right of current one set splitbelow " New windows split below the current one set completeopt-=preview " Hide the preview/scratch window set path=** " Allow commands like 'gf' to find files set wildignore=*/app/cache,*/vendor,*/env,*.pyc,*/venv,*/__pycache__,*/venv " Ignore folders set sessionoptions+=globals " Append global variables to the default session options (Window Names) set backspace=2 " Make backspace work like most other programs " Custom status line set statusline= set statusline+=%1*\ %02c\ " Color set statusline+=%2*\ » " RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK set statusline+=%3*\ %<%F\ " File+path set statusline+=%2*\« " LEFT-POINTING DOUBLE ANGLE QUOTATION MARK set statusline+=%2*\ %=\ %l/%L\ (%02p%%)\ " Rownumber/total (%) " Set spacing of filetypes au FileType vim,ledger,yaml,html,htmldjango setlocal tabstop=2 au FileType sh,python setlocal tabstop=4 au FileType make setlocal tabstop=4 noexpandtab " Setup colorscheme syntax enable colorscheme gruvbox " Set the colorscheme set background=dark " Use dark colorscheme " Set vimdiff colors, make it easier to read highlight DiffAdd cterm=BOLD ctermfg=NONE ctermbg=22 highlight DiffDelete cterm=BOLD ctermfg=NONE ctermbg=52 highlight DiffChange cterm=BOLD ctermfg=NONE ctermbg=23 highlight DiffText cterm=BOLD ctermfg=NONE ctermbg=23 " Disable Background Color for transparency hi Normal guibg=NONE ctermbg=NONE hi Search ctermbg=None ctermfg=166 " Highlight lines at 80 mark/120 mark highlight ColorColumn ctermbg=cyan au BufEnter *.py let w:m1=matchadd('ColorColumn', '\%81v', 100) au BufEnter *.py let w:m2=matchadd('Error', '\%121v', 100) au BufLeave *.py call clearmatches() " Neovim (Docker) vs Vim if has('nvim') let $EditorDir=$HOME.'/.config/nvim/' let $SessionDir='.vimcache' silent! execute '!mkdir -p .vimcache/backup' else let $EditorDir=$HOME.'/.vim/' let $SessionDir='.' endif " My Shorcuts let mapleader="\" " type jj to get out of insert mode inoremap jj " Ctags for python project command! MakeTagsPython !ctags --languages=python --python-kinds=-i -R . " Command for figuring out highlight group map hi :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#") " Turn off syntax highlighting nnoremap :noh " New tab nnoremap t :tabnew " Visually select pasted text nnoremap gp `[v`] " Vimdiff commands nnoremap du :diffupdate nnoremap dd :diffget nnoremap df :diffput nnoremap _ [c nnoremap = ]c " Visually select line without ending nnoremap v ^v$h " Some very useful shortcuts for editing Ledger entries " Copy the last entry nnoremap ll G{jV}y}p10l " Copy the current entry to the bottom, copy date from last entry nnoremap lb {jV}yGp10l{{jvEy}jvEpl " Copy the current entry to the next position nnoremap ln {jV}y}p10l " Jump down from line to replace dollar ammount nnoremap ld j^f$lC " After searching pull entry to current position nnoremap ly vapyp{{jvEy}jvEpl " Accept current autocomplete suggestion inoremap pumvisible() ? "\" : "\" " Faster jumping for linting errors nnoremap [q :lprev nnoremap ]q :lnext nnoremap [w :cprev nnoremap ]w :cnext " Set breakpoint in python noremap ep ofrom pudb import set_trace; set_trace() " Vertical split instead of horiztonal noremap f fL " ] uses path not tags file? noremap ] vL " Run isort on file noremap ei :!isort % " Run black on file noremap eb :!black % " Session saving function! SaveSession() :mksession! $SessionDir/session.vim :echo 'Session Saved!' endfunction nnoremap ess :call SaveSession() nnoremap esr :source $SessionDir/session.vim " Jump to first/last line in a paragraph nnoremap k{w nnoremap j}k^ vnoremap k{w vnoremap j}k^ nnoremap y :call system('nc -w 1 172.17.0.1 41401', @0) "----------------------------------------------------------------------------------------------------------------------- " Ack Searching "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/ack.vim/plugin/ack.vim')) nnoremap / :call AckSearch() noremap ea :Ack function! AckSearch() call inputsave() let term = input('Search: ') call inputrestore() if !empty(term) execute "Ack! " . term endif endfunction " Setting better default settings let g:ackprg = \ "ack -s -H --nocolor --nogroup --column --ignore-dir=.venv/ --ignore-dir=.vimcache/ --ignore-dir=migrations/ --ignore-dir=.mypy_cache/ --ignore-file=is:tags --nojs --nocss --nosass" endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Argwrap "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/vim-argwrap/plugin/argwrap.vim')) nnoremap ew :ArgWrap endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Fugitive "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/vim-fugitive/plugin/fugitive.vim')) " Command for toggling git status function! ToggleGStatus() if buflisted(bufname('.git/index')) bd .git/index else Gstatus endif endfunction command ToggleGStatus :call ToggleGStatus() nnoremap gs :ToggleGStatus nnoremap gc :Gcommit --verbose nnoremap gd :Gdiff endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " fzf.vim "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/fzf.vim/plugin/fzf.vim')) nnoremap ff :Files nnoremap fb :Buffers nnoremap ft :Tags nnoremap fm :Marks nnoremap fc :Commits nnoremap fg :GFiles? " Find Directories nnoremap fd :call fzf#run(fzf#wrap({'source': 'find * -type d'})) " Enable C-N and C-P to go backwards in history let g:fzf_history_dir = '~/.local/share/fzf-history' " [Buffers] Jump to the existing window if possible let g:fzf_buffers_jump = 1 " Show hidden directories let $FZF_DEFAULT_COMMAND = 'find . -type f -not -path "*/\.git/*" -not -path "*/\.mypy_cache/*"' endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Indent Guides "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/vim-indent-guides/plugin/indent_guides.vim')) let g:indent_guides_enable_on_vim_startup = 1 let g:indent_guides_auto_colors = 0 let g:indent_guides_exclude_filetypes =['help', 'nerdtree'] let g:indent_guides_start_level = 2 let g:indent_guides_guide_size = 1 au VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=235 au VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=237 au BufEnter *.py,*.html :IndentGuidesEnable au BufLeave *.py,*.html :IndentGuidesDisable endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Taboo "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/taboo.vim/plugin/taboo.vim')) function! RenameTab() call inputsave() let term = input('Tabname: ') call inputrestore() if !empty(term) execute ":TabooRename " . term endif endfunction nnoremap er :call RenameTab() endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Ale "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/ale/autoload/ale.vim')) let g:ale_lint_on_enter = 0 let g:ale_sign_column_always = 1 let g:ale_lint_on_text_changed = 'never' let g:ale_python_mypy_options='--ignore-missing-imports --disallow-untyped-defs' let g:ale_history_enabled = 0 highlight clear ALEErrorSign highlight clear ALEWarningSign " Change gutter color highlight SignColumn cterm=NONE ctermfg=0 ctermbg=None endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " RainbowParentheses "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/rainbow_parentheses.vim/plugin/rainbow_parentheses.vim')) au VimEnter * RainbowParenthesesToggle au Syntax * RainbowParenthesesLoadRound au Syntax * RainbowParenthesesLoadSquare au Syntax * RainbowParenthesesLoadBraces let g:rbpt_colorpairs = [ \ ['brown', 'RoyalBlue3'], \ ['darkblue', 'DarkOrchid3'], \ ['red', 'firebrick3'], \ ['magenta', 'SeaGreen3'], \ ['yellow', 'SeaGreen3'], \ ['blue', 'DarkOrchid3'], \ ['gray', 'firebrick3'], \ ['cyan', 'DarkOrchid3'], \ ['darkred', 'firebrick3'], \ ['brown', 'RoyalBlue3'], \ ['gray', 'firebrick3'], \ ['darkgreen', 'RoyalBlue3'], \ ['red', 'SeaGreen3'], \ ['darkcyan', 'DarkOrchid3'], \ ['green', 'RoyalBlue3'], \ ] endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Pymode "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/python-mode/plugin/pymode.vim')) let g:pymode_python = 'python3' let g:pymode_run = 1 let g:pymode_indent = 1 let g:pymode_motion = 1 let g:pymode_options_colorcolumn = 0 let g:pymode_lint = 0 let g:pymode_rope = 0 let g:pymode_doc = 0 let g:pymode_breakpoint = 0 let g:pymode_lint = 0 let g:pymode_folding = 0 let g:pymode_motion = 0 " Disable error when using fzf to switch files endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Ranger Intergration "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/ranger.vim/plugin/ranger.vim')) let g:ranger_map_keys = 0 nnoremap m :Ranger nnoremap n :RangerWorkingDirectory let g:ranger_replace_netrw = 1 " open ranger when vim open a directory endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Jinja Highlighting "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/vim-jinja2-syntax/indent/jinja.vim')) au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm set ft=jinja endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Markdown "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/vim-markdown/indent/markdown.vim')) let g:vim_markdown_folding_disabled=1 endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " Terraform "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/vim-terraform/ftplugin/terraform.vim')) let g:terraform_align=1 let g:terraform_commentstring='//%s' endif "----------------------------------------------------------------------------------------------------------------------- "----------------------------------------------------------------------------------------------------------------------- " CamelCaseMotion "----------------------------------------------------------------------------------------------------------------------- if !empty(glob($EditorDir.'plugged/CamelCaseMotion/plugin/camelcasemotion.vim')) " Remap normal ',' to ',,' so we don't lose it nnoremap ,, , xnoremap ,, , onoremap ,, , endif