Skip to content

Instantly share code, notes, and snippets.

@GiuseppeMP
Created January 23, 2022 01:11
Show Gist options
  • Save GiuseppeMP/2a516ae130fe79888815a427c37f4656 to your computer and use it in GitHub Desktop.
Save GiuseppeMP/2a516ae130fe79888815a427c37f4656 to your computer and use it in GitHub Desktop.
vim-stuffs
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.dotfiles/.vim/plugged')
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Think of sensible.vim as one step above 'nocompatible' mode: a universal set of defaults that (hopefully) everyone can agree on.
Plug 'tpope/vim-sensible'
" Themes collections
Plug 'rafi/awesome-vim-colorschemes'
" Git fugitive
Plug 'tpope/vim-fugitive'
" conquer of completion, support language server protocol.
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" surround, to make easy deal with surrounds
Plug 'tpope/vim-surround'
" easy Motion
Plug 'easymotion/vim-easymotion'
" Comment lines easy
"Comment stuff out. Use gcc to comment out a line (takes a count), gc to comment out the target of a motion (for example, gcap to comment out a paragraph), gc in visual mode to comment out the selection, and gc in operator pending mode to target a comment. You can also use it as a command, either with a range like :7,17Commentary, or as part of a :global invocation like with :g/TODO/Commentary. That's it."
Plug 'tpope/vim-commentary'
" JS syntax
Plug 'jelera/vim-javascript-syntax'
" CSS/SCSS
Plug 'cakebaker/scss-syntax.vim'
" Golang full support
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" async linter, support eslint, pep8, prettier, etc
Plug 'dense-analysis/ale'
" python identation
Plug 'vim-scripts/indentpython.vim'
" Nerdtree
Plug 'preservim/nerdtree'
" Repeat for plugins using dot command
Plug 'tpope/vim-repeat'
" Execute tests in coding like jest/mvn/rspec/mocha etc
Plug 'vim-test/vim-test'
" Plug para transformar funcoes em text objects (Java, c, vim scrips)
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-function'
" Enhancement de sintaxe para text objects functions
Plug 'haya14busa/vim-textobj-function-syntax'
" Suporte text object para funcoes python
Plug 'bps/vim-textobj-python'
" Initialize plugin system
call plug#end()
" remove anything on spacebar
nnoremap <SPACE> <Nop>
" let mapleader=" "
" map <space> <leader>
let g:mapleader=" "
let mapleader=" "
" CURSOR SETUP
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=5\x7"
let &t_EI = "\<Esc>]50;CursorShape=6\x7"
" VIM-GO CONFIGS
" 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
" Enable auto formatting on saving
let g:go_fmt_autosave = 1
" Run `goimports` on your current file on every save
let g:go_fmt_command = "goimports"
" Status line types/signatures
let g:go_auto_type_info = 1
" Go Add Tags
let g:go_addtags_transform = 'camelcase'
noremap gat :GoAddTags<cr>
" Delegate gd and ginfo to lspgo
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" Map keys for most used commands.
" Ex: `\b` for building, `\r` for running and `\b` for running test.
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR>
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>t <Plug>(go-test)
" nerdtree configuration
map <C-z> :NERDTreeToggle<CR> " Toggle side window with `CTRL+z`.
let g:NERDTreeDirArrowExpandable = '‚ñ∏'
let g:NERDTreeDirArrowCollapsible = '‚ñæ'
let NERDTreeShowHidden=1 " Show hidden files
" The configuration options should be placed before `colorscheme sonokai`.
" sonokai styles: atlantis, andromeda, shusia, maia, espresso
colorscheme sonokai
let g:sonokai_style = 'maia'
let g:sonokai_enable_italic = 1
let g:sonokai_disable_italic_comment = 1
" colorscheme slate
" ale autofix configs
let g:ale_fix_on_save = 1
set ttyfast
set showmode
set showcmd
set title
set number
set hidden
" This is what files look like
set ffs=unix,dos,mac
" Update find path to search subdirectories
set path=$PWD/**
" No backups
set nobackup
set nowritebackup
set nowb
set noswapfile
" Keep lots of history/undo
set undolevels=1000
" Files to ignore
" Python
set wildignore+=*.pyc,*.pyo,*/__pycache__/*
" Erlang
set wildignore+=*.beam
" Temp files
set wildignore+=*.swp,~*
" Archives
set wildignore+=*.zip,*.tar
" Tab spaces/whitespaces etc
" " Tab sanity
set expandtab
set tabstop=4
set shiftwidth=4
" " Show hidden characters, tabs, trailing whitespace
set list
set listchars=tab:→\ ,trail:·,nbsp:·
" Different tab/space stops"
autocmd Filetype yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype css setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype scss setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype json setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd FileType make setlocal noexpandtab
" Remap escape
inoremap jk <Esc>
inoremap jj <Esc>
" Coc defaults
" if hidden is not set, TextEdit might fail.
set hidden
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" scrolloff using z-enter(commands)
set scrolloff=6
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
set guifont=CascadiaCodePL-Regular:h18
set clipboard=unnamed
set mouse+=a
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment