Last active
April 27, 2022 09:34
-
-
Save 0x0efe/5ee98254a0eefdc54aff3d0b9143740c to your computer and use it in GitHub Desktop.
Vim configuration with Scala Metals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Personal settings | |
syntax on | |
set number | |
set relativenumber | |
set ruler | |
set cursorline | |
set modeline | |
set vb | |
set incsearch | |
set hlsearch | |
set sw=2 | |
set expandtab | |
set smarttab | |
set encoding=utf-8 | |
set termencoding=utf-8 | |
set textwidth=0 | |
set wrapmargin=0 | |
set nowrap | |
set nolist " Unset by default | |
set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:» | |
" Plugins... | |
" ----------------------------------------------------------------------------- | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
autocmd VimEnter * PlugInstall | source $MYVIMRC | |
endif | |
call plug#begin('~/.vim/plugged') | |
" Common | |
Plug 'tpope/vim-sensible' | |
" Scala | |
Plug 'neoclide/coc.nvim', {'tag': '*', 'do': './install.sh'} | |
Plug 'derekwyatt/vim-scala' | |
Plug 'derekwyatt/vim-sbt' | |
Plug 'ktvoelker/sbt-vim' | |
" Haskell | |
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} | |
Plug 'neovimhaskell/haskell-vim' | |
Plug 'alx741/vim-hindent' | |
" Git | |
Plug 'tpope/vim-fugitive' | |
" Status line | |
let g:airline_powerline_fonts = 1 | |
let g:airline_theme='tomorrow' | |
let g:airline#extensions#wordcount#enabled = 0 " Fix for column selection | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline_left_sep='' | |
let g:airline_right_sep='' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
" Tree | |
Plug 'scrooloose/nerdtree' | |
Plug 'xuyuanp/nerdtree-git-plugin' | |
" Theme | |
Plug 'flazz/vim-colorschemes' | |
" Snippets | |
Plug 'MarcWeber/vim-addon-mw-utils' | |
Plug 'tomtom/tlib_vim' | |
Plug 'garbas/vim-snipmate' | |
" Tools | |
Plug 'vim-scripts/AnsiEsc.vim' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'jremmen/vim-ripgrep' | |
call plug#end() | |
" ----------------------------------------------------------------------------- | |
" Color settings | |
set term=xterm-256color | |
set t_Co=256 | |
set t_ut= | |
let g:solarized_termcolors = 256 | |
colorscheme xoria256 | |
" Shortcuts | |
nnoremap <F1> <C-W>w | |
nmap <F2> :NERDTreeToggle<CR> | |
nmap <F3> :NERDTreeFocus<CR> | |
map <F12> :bn<CR> | |
map <F11> :bp<CR> | |
function ToggleWhitespace() | |
if &list == '0' | |
echom "Showing invisible characters" | |
execute 'set list' | |
else | |
echom "Hiding invisible characters" | |
execute 'set nolist' | |
endif | |
endfunction | |
nmap <F6> :call ToggleWhitespace()<CR> | |
" ctrlp Settings | |
let g:ctrlp_working_path_mode='ra' | |
let g:ctrlp_use_caching=0 | |
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files'] | |
let g:ctrlp_custom_ignore = { | |
\ 'dir': '\v[\/]\.(git)$', | |
\ 'file': '\v\.(class)$' | |
\ } | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip | |
" Markdown Setup | |
autocmd BufRead,BufNewFile *.md setlocal tw=78 | |
" Scala Setup | |
let g:scala_sort_across_groups=1 | |
autocmd BufRead,BufNewFile *.sbt set filetype=scala | |
autocmd FileType json syntax match Comment +\/\/.\+$+ | |
" CoC Setup | |
set updatetime=300 | |
set shortmess+=c | |
set signcolumn=yes | |
set nobackup | |
set nowritebackup | |
set cmdheight=2 | |
inoremap <silent><expr> <c-space> coc#refresh() | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
nmap <silent> [c <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]c <Plug>(coc-diagnostic-next) | |
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) | |
nmap <leader>ac <Plug>(coc-codeaction) | |
nnoremap <silent> F :call CocAction('format')<CR> | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if &filetype == 'vim' | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
nmap <leader>rn <Plug>(coc-rename) | |
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr> | |
nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
nnoremap <silent> <space>g :<C-u>CocList -I grep<cr> | |
nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
nnoremap <silent> <space>p :<C-u>CocListResume<CR> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vim version 8.1
More info about Scala Metals setup: https://scalameta.org/metals/docs/editors/vim.html