This repository has been archived on 2023-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
nvim-config/init.vim

254 lines
6.8 KiB
VimL
Raw Normal View History

" vim: set et sw=2 ts=2 tw=80 :
set rtp+='$HOME/.local/share/nvim/site'
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
source ~/.config/nvim/plugins.vim
" Use "," as leader
let mapleader = ","
let maplocalleader = " "
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
" LanguageClient-neoviM
let g:LanguageClient_serverCommands = {
\ 'scala': ['metals-vim'],
\ 'sbt': ['metals-vim'],
\ 'python': ['pyls'],
\ 'c': ['ccls'],
\ 'go': ['go-langserver'],
\ 'bash': ['bash-language-server']
\ }
let g:LanguageClient_useVirtualText = 0
function! LC_maps()
if has_key(g:LanguageClient_serverCommands, &filetype)
nnoremap <buffer> <silent> <localleader>d
\ :call LanguageClient#textDocument_definition()<CR>
nnoremap <buffer> <silent> <localleader>t
\ :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <buffer> <silent> <localleader>s
\ :call LanguageClient#textDocument_documentSymbol()<CR>
nnoremap <buffer> <silent> <localleader>u
\ :call LanguageClient#textDocument_references()<CR>
nnoremap <buffer> <silent> <localleader>r
\ :call LanguageClient#textDocument_rename()<CR>
nnoremap <buffer> <silent> <localleader>i
\ :call LanguageClient#textDocument_implementation()<CR>
nnoremap <buffer> <silent> <localleader>f
\ :call LanguageClient#textDocument_formatting()<CR>
nnoremap <buffer> <silent> <localleader>h
\ :call LanguageClient#textDocument_documentHighlight()<CR>
nnoremap <buffer> <silent> <localleader>H
\ :call LanguageClient#textDocument_clearDocumentHighlight()<CR>
endif
endfunction
autocmd FileType * call LC_maps()
" NCM2
" enable ncm2 for all buffers
autocmd BufEnter * call ncm2#enable_for_buffer()
" IMPORTANT: :help Ncm2PopupOpen for more information
set completeopt=noinsert,menuone,noselect
" suppress the annoying 'match x of y', 'The only match' and 'Pattern not
" found' messages
set shortmess+=c
" CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead.
inoremap <c-c> <ESC>
" Use <TAB> to select the popup menu:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" wrap existing omnifunc
" Note that omnifunc does not run in background and may probably block the
" editor. If you don't want to be blocked by omnifunc too often, you could
" add 180ms delay before the omni wrapper:
" 'on_complete': ['ncm2#on_complete#delay', 180,
" \ 'ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
au User Ncm2Plugin call ncm2#register_source({
\ 'name' : 'css',
\ 'priority': 9,
\ 'subscope_enable': 1,
\ 'scope': ['css','scss'],
\ 'mark': 'css',
\ 'word_pattern': '[\w\-]+',
\ 'complete_pattern': ':\s*',
\ 'on_complete': ['ncm2#on_complete#omni', 'csscomplete#CompleteCSS'],
\ })
" FILE MANAGER
" Override netrw commands with Dirvish
let g:loaded_netrwPlugin = 1
command! -nargs=? -complete=dir Explore Dirvish <args>
command! -nargs=? -complete=dir Sexplore belowright split | silent Dirvish <args>
command! -nargs=? -complete=dir Vexplore leftabove vsplit | silent Dirvish <args>
let g:dirvish_mode = ':sort ,^.*[\/],'
" SETTINGS
if !has('nvim')
setlocal cm=blowfish2
end
" activate mouse support
set mouse=a
" allow unsaved hidden buffers
set hidden
2019-02-15 21:02:17 +00:00
" set column padding when scrolling from top or bottom
set scrolloff=5
2018-12-10 19:36:10 +00:00
" set relative line numbers
set number relativenumber
" set highlighting and continous search
2018-12-10 19:36:10 +00:00
set hlsearch incsearch
" show n-column limiter when textwidth is set
2018-12-10 19:36:10 +00:00
set colorcolumn=+1
if has('nvim')
" prevent terminal buffers to be closed when changing buffer
autocmd TermOpen * set bufhidden=hide
" restore line numbers for all buffers (revert changes of cmd below)
autocmd BufCreate * set rnu nu
" remove line numbers to terminal
autocmd TermOpen * set nornu nonu
end
" set autoindent on`
set autoindent
" Make :find work on all files in :pwd
set path+=**
set wildignore+=**/node_modules/**,*~
" ADDITIONAL COMMANDS
2019-01-20 12:28:38 +00:00
command! Q quit
command! W write
command! WQ wq
2019-01-20 12:28:38 +00:00
command! WW write suda://%
2019-02-05 13:54:59 +00:00
command! D call CreateDir()
function! CreateDir()
!mkdir -p '%:p:h'
endfunction
2019-02-02 22:25:50 +00:00
" emulate system clipboard
inoremap <C-v> <ESC>"+pa
vnoremap <C-c> "+y
inoremap <S-tab> <C-d>
2018-12-18 09:15:06 +00:00
" make escape work in terminal and send ESC to terminal with C-Esc
tnoremap <Esc> <C-\><C-n>
tnoremap <C-Esc> <Esc>
" Automatically save folds for each file
augroup AutoSaveFolds
autocmd!
autocmd BufWinLeave * silent! mkview
autocmd BufWinEnter * silent! loadview | doautocmd BufRead
augroup END
" clear search pattern with F2
noremap <F2> :let @/ = ""<CR>
2018-12-27 12:20:34 +00:00
" Switch between Windows with: Leader w
nnoremap <Leader>w <C-w><C-w>
" Re-read buffer and load modelines with: Leader m
nnoremap <Leader>m :doautocmd BufRead<CR>
" Open fzf with all files in git with: Leader f
nnoremap <Leader>f :GFiles<CR>
" Fix indentation with: Leader i
nnoremap <Leader>i mzgg=G`z
2018-12-27 12:20:34 +00:00
" Delete buffer with: Leader d
2019-01-03 21:58:42 +00:00
nnoremap <Leader>d :bp\|bd #<CR>
" move to next tab with: Leader t
tnoremap <C-e> <C-\><C-n>:tabnext<CR>
" clear trailing spaces in file
function! g:ClearTrailingSpaces()
silent! %s/\s\s*$//g
let @/ = "" " clear last search
endfunction
2018-12-27 12:20:34 +00:00
" remove trailing spaces with: Leader t s
nnoremap <silent> <Leader>s :call ClearTrailingSpaces()<CR>
" automatically remove trailing spaces when saving a file
autocmd BufWrite * call ClearTrailingSpaces()
2018-12-27 12:20:34 +00:00
" Reload config with: Leader R
nnoremap <Leader>R :source ~/.config/nvim/init.vim<CR>
2018-12-27 12:20:34 +00:00
" show Vim's true competitor with: Leader r c m
nnoremap <Leader>rcm :!open https://youtu.be/jn40Ugz0vuk<CR><CR>
2019-01-20 12:28:38 +00:00
" open netrw in directory of current file
nnoremap <Leader>e :Ex<CR>
" Toggle Location and Quickfix windows with these mappings
let g:lt_location_list_toggle_map = '<leader>l'
let g:lt_quickfix_list_toggle_map = '<leader>q'
" Insert in the end of file with Leader c
nnoremap <Leader>c GA
" COLORSCHEME
2018-12-27 12:20:34 +00:00
" set colorscheme to onedark.im for nvim and airline
colorscheme onedark
let g:airline_theme='onedark'
" PACKAGES
" vim-fish setup
2018-12-18 09:15:06 +00:00
syntax enable
filetype plugin indent on
" Set up :make to use fish for syntax checking.
autocmd FileType fish compiler fish
2018-12-10 19:36:10 +00:00
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file (restore to previous version)
if has('persistent_undo')
set undofile " keep an undo file (undo changes after closing)
endif
endif