Skip to content

Instantly share code, notes, and snippets.

@flukejones
Created January 20, 2019 08:49
Show Gist options
  • Save flukejones/193e38e4dca6c43a82c60b358bf8a409 to your computer and use it in GitHub Desktop.
Save flukejones/193e38e4dca6c43a82c60b358bf8a409 to your computer and use it in GitHub Desktop.
Vim config for Rust with language server plus completion
" Bare minimum for rust code
" I add other plugins for Nerdtree, git gutter, airline etc
all plug#begin('~/.vim/plugged')
" Status stuff
Plug 'Valloric/YouCompleteMe'
" show ctags (works with rust.vim too)
" see https://github.com/majutsushi/tagbar/wiki#rust for settings
Plug 'majutsushi/tagbar'
" for rls (and others)
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" (Optional) Multi-entry selection UI.
Plug 'junegunn/fzf'
Plug 'cespare/vim-toml'
call plug#end()
nmap <C-t> :TagbarToggle<CR>
"YCM
let g:ycm_server_python_interpreter = '/usr/bin/python3'
" using lang server instead
let g:ycm_enable_diagnostic_signs = 0
let g:ycm_enable_diagnostic_highlighting = 0
let g:ycm_always_populate_location_list = 0 "default 0
let g:ycm_open_loclist_on_ycm_diags = 0 "default 1
" let g:ycm_rust_src_path = $RUST_SRC_PATH
" Language Server
let g:LanguageClient_serverCommands = {
\ 'rust': ['rls'],
\ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
\ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
\ 'python': ['/usr/local/bin/pyls'],
\ }
let mapleader = ","
"let g:LanguageClient_diagnosticsSignsMax=0
let g:LanguageClient_diagnosticsEnable=1
let g:LanguageClient_diagnosticsList="Quickfix"
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <leader>ld :call LanguageClient#textDocument_definition()<CR>
nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR>
nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR>
nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR>
nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR>
nnoremap <leader>ls :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <leader>lm :call LanguageClient_contextMenu()<CR>
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
" colours for language server diagnostics
highlight ALEInfo ctermbg=Green
highlight ALEInfoSign ctermbg=Green
highlight ALEWarning ctermbg=DarkMagenta
highlight ALEWarningSign ctermbg=DarkMagenta
highlight ALEError ctermbg=DarkRed
highlight ALEErrorSign ctermbg=DarkRed
" symbol list to compare
" ☣ ☢ ☡ ☠ ☠ ☠ ⓘ ░ ➝ ⇉ ➞ ➜ ➟ ➲ → ⇒ ⇛ ⇏ ↯ ❭ ❯ ❱ ➤ ⁇ ☄ ☇ ☈ ☀ ☉ ★ ☆ ☤ ⚕ ⚠ ⚛ ⚙ ⚗
let g:LanguageClient_diagnosticsDisplay = {
\ 1: {
\"name": "Error",
\"texthl": "ALEError",
\"signText": "☢",
\"signTexthl": "ALEErrorSign",
\},
\2: {
\"name": "Warning",
\"texthl": "ALEWarning",
\"signText": "⚠",
\"signTexthl": "ALEWarningSign",
\},
\3: {
\"name": "Info",
\"texthl": "ALEInfo",
\"signText": "⚙",
\"signTexthl": "ALEInfoSign",
\},
\4: {
\"name": "Hint",
\"texthl": "ALEInfo",
\"signText": "⚗",
\"signTexthl": "ALEInfoSign",
\},
\}
let g:tagbar_type_rust = {
\ 'ctagstype' : 'rust',
\ 'kinds' : [
\'T:types,type definitions',
\'f:functions,function definitions',
\'g:enum,enumeration names',
\'s:structure names',
\'m:modules,module names',
\'c:consts,static constants',
\'t:traits',
\'i:impls,trait implementations',
\]
\}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment