From 357c0aab134398115adde68fc34b3b1dd9ff3f07 Mon Sep 17 00:00:00 2001 From: Zykino Date: Mon, 27 May 2019 20:24:23 +0200 Subject: [PATCH] add neovim configuration --- init.vim | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 init.vim diff --git a/init.vim b/init.vim new file mode 100644 index 0000000..3196c8f --- /dev/null +++ b/init.vim @@ -0,0 +1,137 @@ +"" Based on ensimag vim config file version 1.0.2 +"" this file is intended for vim 8. +"" before using it on your machine however you will need to: +"" - install plug with : +"" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +"" (see https://github.com/junegunn/vim-plug) +"" - install the languageserver server for each language you indend to use : +"" * pyls for python (see https://github.com/palantir/python-language-server) +"" * rls for rust (see https://github.com/rust-lang-nursery/rls) +"" * clangd for c +"" - you need to install jedi for python auto-completion +"" - install some font with powerline symbols for eye candy and icons +"" (see https://github.com/powerline/fonts) +"" - change plugin directory to ~/.local/share/nvim/plugged + +"" after that copy this file as your ~/.vimrc and execute :PlugInstall + +set nocompatible +filetype off + +call plug#begin('~/.local/share/nvim/plugged') " on your own machine + +" not needed as neovim alreay has (better ?) sane defaults +"Plug 'tpope/vim-sensible' " sane defaults + +" eye candy +Plug 'vim-airline/vim-airline' " status bar (needs special fonts) +Plug 'vim-airline/vim-airline-themes' +Plug 'morhetz/gruvbox' " very nice and soft color theme +Plug 'ryanoasis/vim-devicons' " various symbols (linux, rust, python, ...) + +" essential plugins +" see for example https://github.com/autozimu/LanguageClient-neovim/issues/35#issuecomment-288731665 +"Plug 'maralla/completor.vim' " auto-complete +Plug 'autozimu/LanguageClient-neovim', { + \ 'branch': 'next', + \ 'do': 'bash install.sh', + \ } " as of july 2018 this branch is needed for vim8 +Plug 'tbodt/deoplete-tabnine', { + \ 'do': './install.sh', + \ } " auto-complete contextually + +" rust +Plug 'rust-lang/rust.vim' " syntax highlighting +Plug 'mattn/webapi-vim' " used for rust playpen + + +" not essential +Plug 'tpope/vim-fugitive' " git +Plug 'scrooloose/nerdtree' " browse files tree +" Plug 'junegunn/fzf' " fuzzy files finding + +" snippets allow to easily 'fill' common patterns +Plug 'SirVer/ultisnips' +Plug 'honza/vim-snippets' + +call plug#end() + +filetype plugin indent on + +" configure maralla/completor to use tab +" other configurations are possible (see website) +"inoremap pumvisible() ? "\" : "\" +"inoremap pumvisible() ? "\" : "\" +"inoremap pumvisible() ? "\\" : "\" + +" ultisnips default bindings compete with completor's tab +" so we need to remap them +let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="" + +" airline : +" for terminology you will need either to export TERM='xterm-256color' +" or run it with '-2' option +let g:airline_powerline_fonts = 1 +set laststatus=2 +au VimEnter * exec 'AirlineTheme hybrid' + +set encoding=utf-8 + +syntax on + +colorscheme gruvbox +set background=dark +set number relativenumber + +" see https://jeffkreeftmeijer.com/vim-number/ +:augroup numbertoggle +: autocmd! +: autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif +: autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif +:augroup END + + +let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree + +" tabs +set tabstop=4 +set shiftwidth=4 +set smartindent + +" highlight trailing whitespace +highlight ExtraWhitespace ctermbg=red guibg=red +match ExtraWhitespace /\s\+\%#\@]" conceal cchar=≟ " Char "question equal to" from unicode: [c-v]U225F +"au BufEnter,BufNewFile,BufRead *.rs syntax match rustInequality "!=\ze[^>]" conceal cchar=≠ " Char "not equal to" from unicode: [c-v]U2260 + +" let's autoindent c files +au BufWrite *.c call LanguageClient#textDocument_formatting() + +" run language server for python, rust and c +let g:LanguageClient_autoStart = 1 +let g:LanguageClient_serverCommands = { + \ 'python': ['pyls'], + \ 'rust': ['rustup', 'run', 'stable', 'rls'], + \ 'javascript': ['javascript-typescript-stdio'], + \ 'go': ['go-langserver'], + \ 'c' : ['clangd'] + \ } + +" keep the cursor "centered" vertically +set scrolloff=5 + +" use rg instead of grep. Comment this if you ripgrep is not installed. +set grepprg=rg\ --vimgrep +set grepformat=%f:%l:%c:%m +