Skip to content

Instantly share code, notes, and snippets.

@emilio
Created June 21, 2022 12:24
Show Gist options
  • Save emilio/f81f7da7e21c66fffc1d0d0e0cbdd543 to your computer and use it in GitHub Desktop.
Save emilio/f81f7da7e21c66fffc1d0d0e0cbdd543 to your computer and use it in GitHub Desktop.
VimRC as of 2022-06-21
call plug#begin()
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'udalov/kotlin-vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'preservim/nerdtree'
Plug 'rust-lang/rust.vim'
Plug 'vim-syntastic/syntastic'
Plug 'leafgarland/typescript-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive'
Plug 'petrbroz/vim-glsl'
Plug 'bogado/file-line'
Plug 'tpope/vim-haml'
Plug 'plasticboy/vim-markdown'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'vim-pandoc/vim-pandoc'
Plug 'cespare/vim-toml'
Plug 'altercation/vim-colors-solarized'
" Plug 'ycm-core/YouCompleteMe'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'aldafu/vim-widl'
Plug 'wsdjeg/vim-fetch'
call plug#end()
" set nofoldenable
set nocompatible
set foldmethod=syntax
set foldenable
" set foldlevelstart=1
"
" The following makes toggling folds easy, but actually it's unusable due to
" ncurses limitations (you can bind only one, and for that...)
" nnoremap <space> za
" nnoremap <S-space> zA
syntax on
filetype plugin indent on
syntax enable
set t_Co=256
let html_number_lines = 1
set modeline
set shiftround
" let hour = strftime("%H")
" if hour >= 6 && hour < 18
" set background=light
" else
" endif
set background=dark
colorscheme solarized
" Visual settings
set cursorline " Highlight current line
" set number " Enable line numbers.
set title " Show the filename in the window titlebar.
set noshowmode " Don't show the current mode (airline.vim takes care of us)
set laststatus=2 " Always show status line
set colorcolumn=+1 " Show the line to wrap
let g:gitgutter_signs = 0
set spelllang=en,es,de
set spell
autocmd BufRead,BufNewFile *.jsm set filetype=javascript
autocmd FileType
\ tex,text,pandoc,markdown
\ setlocal tw=80 formatoptions+=t foldcolumn=0
autocmd FileType
\ gitcommit
\ setlocal tw=72 formatoptions+=t foldcolumn=0
autocmd FileType
\ gitcommit,mail
\ setlocal nofoldenable
" autocmd FileType pandoc setlocal tw=80 formatoptions+=t foldcolumn=0
autocmd FileType rust,perl,c,cpp setlocal tw=80
autocmd FileType c,cpp,html,css,javascript setlocal sw=2
" Airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_format = '%s '
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#branch#enabled = 1
"let g:airline#extensions#tabline#fnamecollapse = 0
"let g:airline#extensions#tabline#fnamemod = ':t'
let g:ale_fixers = {
\ 'javascript': ['eslint'],
\}
"YouCompleteMe
"
let g:ycm_filetype_blacklist = {
\ 'tex' : 1,
\ 'tagbar' : 1,
\ 'qf' : 1,
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'unite' : 1,
\ 'text' : 1,
\ 'vimwiki' : 1,
\ 'pandoc' : 1,
\ 'infolog' : 1,
\ 'mail' : 1
\}
"
"Only enable autocompletion in java via eclim
" let g:ycm_filetype_whitelist = { 'java': 1 }
let g:ycm_language_server =
\ [
\ {
\ 'name': 'rust',
\ 'cmdline': ['rust-analyzer'],
\ 'filetypes': ['rust'],
\ 'project_root_files': ['Cargo.toml']
\ }
\ ]
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
" let g:ycm_server_log_level = 'debug'
let g:ycm_confirm_extra_conf = 0
nnoremap <C-]> :YcmCompleter GoToDefinition<CR>
" nnoremap <C-[> :YcmCompleter GoToDeclaration<CR>
" if filereadable("~/.vimrc_platform")
" source "~/.vimrc_platform"
" endif
" set list
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
"Pandoc
let g:pandoc#spell#enabled = 1
" PatchReview
let g:patchreview_disable_syntax = 0
" 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
" Disable Rust linting, slow.
let g:syntastic_rust_checkers = []
" C and C++ linting requires more setup, and is done by the completion plugin
" anyways.
let g:syntastic_c_checkers = []
let g:syntastic_cpp_checkers = []
autocmd FileType javascript,html,xhtml let b:syntastic_checkers = ['javascript/eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
" coc
let g:coc_root_patterns = ['.git', '.hg']
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
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.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight the symbol and its referencs when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <plug>(coc-format-selected)
nmap <leader>f <plug>(coc-format-selected)
augroup mygroup
autocmd!
" setup formatexpr specified filetype(s).
autocmd filetype typescript,json setl formatexpr=CocAction('formatselected')
" update signature help on jump placeholder.
autocmd user cocjumpplaceholder call CocActionAsync('showsignaturehelp')
augroup end
" applying codeaction to the selected region.
" example: `<leader>aap` for current paragraph
xmap <leader>a <plug>(coc-codeaction-selected)
nmap <leader>a <plug>(coc-codeaction-selected)
" remap keys for applying codeaction to the current buffer.
nmap <leader>ac <plug>(coc-codeaction)
" apply autofix to problem on the current line.
nmap <leader>qf <plug>(coc-fix-current)
" map function and class text objects
" note: requires 'textdocument.documentsymbol' support from the language server.
xmap if <plug>(coc-funcobj-i)
omap if <plug>(coc-funcobj-i)
xmap af <plug>(coc-funcobj-a)
omap af <plug>(coc-funcobj-a)
xmap ic <plug>(coc-classobj-i)
omap ic <plug>(coc-classobj-i)
xmap ac <plug>(coc-classobj-a)
omap ac <plug>(coc-classobj-a)
" add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" add (neo)vim's native statusline support.
" note: please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment