Skip to content

Instantly share code, notes, and snippets.

@femmerling
Last active January 17, 2024 19:21
Show Gist options
  • Save femmerling/410f6e0302cbb6dc391fb2700cd56cfa to your computer and use it in GitHub Desktop.
Save femmerling/410f6e0302cbb6dc391fb2700cd56cfa to your computer and use it in GitHub Desktop.
vim dotfile
set encoding=utf-8
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" plugin section
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'ervandew/supertab'
Plugin 'vim-scripts/darkspectrum'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-easytags'
Plugin 'Valloric/YouCompleteMe'
Plugin 'psf/black'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'fatih/vim-go'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" Enable clipboard
set clipboard=unnamed
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>
"" Themes and size
set guifont=Monaco:h12
set nu
set background=dark
colorscheme darkspectrum
"" Nerdtree settings
map <Leader>n :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$', '\~$', '\.swp$', '^__pycache__'] "ignore files in NERDTree
let NERDTreeShowHidden=1
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif"let python_highlight_all=1
"" Keybinding for openning terminal on a new split
map <Leader>t :term<CR>
"" Keybinding for black formatting
map <Leader>b :Black<CR>
let g:black_fast = 1
let g:black_linelength = 120
let g:black_skip_string_normalization = 1
let g:black_skip_magic_trailing_comma = 1
syntax on
"" Default tab settings
set tabstop=2
set shiftwidth=2
set expandtab
"" Set size
if has("gui_running")
set lines=999 columns=999
else
if exists("+lines")
set lines=50
endif
if exists("+columns")
set columns=100
endif
endif
"" Easytags
set tags=./tags;
let g:easytags_opts = ['--fields=+l']
let g:easytags_python_enabled = 1
let g:easytags_async=1
let g:easytags_auto_highlight=0
" Enable folding
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
" NERDCommenter Settings
filetype plugin on
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:NERDTrimTrailingWhitespace = 1
" PEP8 stuffs
au BufNewFile,BufRead *.py
\ setf tabstop=4
\ setf softtabstop=4
\ setf shiftwidth=4
\ setf textwidth=79
\ setf expandtab
\ setf autoindent
\ setf fileformat=unix
:highlight BadWhitespace ctermfg=16 ctermbg=253 guifg=#000000 guibg=#F8F8F0
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
"" Autocompleter settings
let g:ycm_autoclose_preview_window_after_completion=1
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
"" FZF settings for eazy search
set rtp+=/opt/homebrew/opt/fzf
set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --follow
let g:rg_derive_root='true'
silent! nmap <C-P> :Files<CR>
silent! nmap <C-G> :GFiles<CR>
silent! nmap <C-f> :Rg!
silent! nmap <C-h> :Rg!<C-R>0<CR>
silent! nmap <leader>u :Rg!<C-R><C-W><CR>
"" Systastic settings
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_loc_list_height=4
let g:syntastic_python_python_exec = 'python3'
let g:syntastic_python_checkers = ['flake8']
let g:syntastic_python_flake8_args='--ignore=E501'
let g:syntastic_go_checkers = ['govet', 'errcheck', 'go']
"" Vim-Go settings
filetype plugin indent on
set autowrite
let g:go_list_type = "quickfix"
"" Gopls setup
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
"" Go syntax highlighting
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1
"" Auto formatting and importing
let g:go_fmt_autosave = 1
let g:go_fmt_command = "goimports"
" Status line types/signatures
let g:go_auto_type_info = 1
" Run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
""Map keys for most used commands.
"" `\gb` for building, `\gr` for running and `\gt` for running test.
autocmd FileType go nmap <leader>gb :<C-u>call <SID>build_go_files()<CR>
autocmd FileType go nmap <leader>gr <Plug>(go-run)
autocmd FileType go nmap <leader>gt <Plug>(go-test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment