Skip to content

Instantly share code, notes, and snippets.

@mattroseman
Last active January 8, 2021 23:20
Show Gist options
  • Save mattroseman/6b20626b91a834d991f813e0aec33fe9 to your computer and use it in GitHub Desktop.
Save mattroseman/6b20626b91a834d991f813e0aec33fe9 to your computer and use it in GitHub Desktop.
vim configuration
" General
syntax on
let mapleader = '-'
let python_highlight_all=1
set nocompatible
filetype off
set backspace=indent,eol,start
set encoding=utf-8
set nu
set fileformat=unix
set formatoptions-=cro
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
set ignorecase
set smartcase
set foldmethod=syntax
autocmd FileType html,xhtml,htmldjango setlocal foldmethod=manual
set foldlevel=99
" Keyboard Shortcuts
nmap <C-n> :cnext<CR>
nmap <C-m> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
nnoremap <space> za
nnoremap <space> zf
" ALE shortcuts
nnoremap <C-]> :ALEGoToDefinition<CR>
cnoreabbrev gotodef ALEGoToDefinitionInSplit
cnoreabbrev gotodefv ALEGoToDefinitionInVSplit
nnoremap <C-p> <C-o>
" go shortcuts
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>t <Plug>(go-test)
" Tab Spacing
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
au BufNewFile,BufRead *.js,*.ts,*.jsx,*.html,*.css,*.scss,*sass,*.yml,*.xml,*.md,*.markdown,*.mdx
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2
" Pathogen
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'vim-scripts/indentpython.vim'
" Plugin 'vim-syntastic/syntastic'
Plugin 'dense-analysis/ale'
Plugin 'nvie/vim-flake8'
Plugin 'scrooloose/nerdtree'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" Plugin 'morhetz/gruvbox'
Plugin 'sonph/onehalf', {'rtp': 'vim/'}
Plugin 'wakatime/vim-wakatime'
Plugin 'fatih/vim-go'
Plugin 'tpope/vim-fugitive'
Plugin 'python-mode/python-mode'
Plugin 'pangloss/vim-javascript'
Plugin 'yuezk/vim-js'
Plugin 'maxmellon/vim-jsx-pretty'
" Plugin 'ycm-core/YouCompleteMe'
Plugin 'tmhedberg/SimpylFold'
Plugin 'konfekt/fastfold'
Plugin 'vim-ruby/vim-ruby'
call vundle#end()
filetype plugin indent on
" Split Buffer
set splitbelow
set splitright
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" YouCompleteMe
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_auto_trigger = 0
nmap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
" Python Mode
let g:pymode_python = 'python3'
let g:pymode_warnings = 1
let g:pymode_paths = ['/usr/local/bin/python3']
let g:pymode_trim_whitespaces = 0
let g:pymode_options_colorcolumn = 0
let g:pymode_motion = 1
let g:pymode_doc = 1
let g:pymode_doc_bind = 'K'
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
let g:pymode_lint = 0
let g:pymode_rope = 0
let g:pymode_rope_completion = 0
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
" Colorscheme
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set t_Co=256
set background=dark
" let g:grubox_termcolors = 256
" let g:gruvbox_contrast_dark = 'hard'
" let g:airline_theme='gruvbox'
" colorscheme gruvbox
" let g:onehalf_termcolors = 256
let g:airline_theme='onehalfdark'
let g:airline_powerline_fonts=1
colorscheme onehalfdark
" Go-Vim
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_fmt_autosave = 0
" Search for any .vimsettings files in the path to the file.
" Source them if you find them.
function! ApplyLocalSettings(dirname)
" Don't try to walk a remote directory tree -- takes too long, too many
" what if's
let l:netrwProtocol = strpart(a:dirname, 0, stridx(a:dirname, "://"))
if l:netrwProtocol != ""
return
endif
" Convert windows paths to unix style (they still work)
let l:curDir = substitute(a:dirname, "\\", "/", "g")
let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, "/"))
if isdirectory(l:parentDir)
" Recursively walk to the top of the path
call ApplyLocalSettings(l:parentDir)
endif
" Now walk back down the path and source .vimsettings as you find them. This
" way child directories can 'inherit' from their parents
let l:settingsFile = a:dirname . "/.vimsettings"
if filereadable(l:settingsFile)
exec ":source " . l:settingsFile
endif
endfunction
autocmd! BufEnter * call ApplyLocalSettings(expand("<afile>:p:h"))
" " Syntastic
" set statusline+=%#warningmsg#
" " set statusline+=%{SyntasticStatusLineFlag()}
" set statusline+=%*
"
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" let g:syntastic_error_symbol = "✗"
"
" let g:syntastic_python_checkers = ['flake8', 'python3']
" let g:syntastic_python_flake8_args = '--ignore=E501,W605'
"
" let g:syntastic_javascript_checkers = ['eslint']
" ALE
let g:ale_linters = {
\ 'python': ['pyls', 'flake8'],
\ 'javascript': ['eslint', 'prettier'],
\ 'typescript': ['tslint'],
\ 'yaml': ['yamllint'],
\ 'go': ['gopls'],
\ 'ruby': ['rubocop']
\}
" let g:ale_python_flake8_options = '--ignore=E501,W605'
let g:ale_python_pyls_config = {
\ 'pyls': {
\ 'plugins': {
\ 'pycodestyle': {
\ 'enabled': v:false
\ },
\ 'pydocstyle': {
\ 'enabled': v:false
\ },
\ 'pylint': {
\ 'enabled': v:false
\ },
\ 'flake8': {
\ 'enabled': v:false
\ }
\ }
\ }
\}
nnoremap ]r :ALENextWrap<CR>
nnoremap [r :ALEPreviousWrap<CR>
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_echo_msg_format = '%linter%%(code)%: %s'
let g:airline#extensions#ale#enabled = 1
" Load all plugins now.
" Plugins need to be added to runtimepath before helptags can be generated.
packloadall
" Load all of the helptags now, after plugins have been loaded.
" All messages and errors will be ignored.
silent! helptags ALL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment