Skip to content

Instantly share code, notes, and snippets.

@barrbrain
Last active September 27, 2022 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrbrain/9e539f93367f5d9ba2ea9158f0ecc69b to your computer and use it in GitHub Desktop.
Save barrbrain/9e539f93367f5d9ba2ea9158f0ecc69b to your computer and use it in GitHub Desktop.
nvim language server/client configuration from scratch
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
export DENO_TLS_CA_STORE="system"
call plug#begin('~/.local/share/nvim/plugged')
Plug 'rust-lang/rust.vim'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
Plug 'vim-denops/denops.vim'
Plug 'vim-denops/denops-helloworld.vim'
Plug 'Shougo/ddu.vim'
Plug 'Shougo/ddu-ui-ff'
Plug 'Shougo/ddu-kind-file'
Plug 'Shougo/ddu-filter-matcher_substring'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/echodoc.vim'
call plug#end()
autocmd BufReadPost *.rs setlocal filetype=rust
autocmd BufReadPost *.js setlocal filetype=javascript
autocmd BufReadPost *.py setlocal filetype=python
" Required for operations modifying multiple buffers like rename.
set hidden
let g:LanguageClient_serverCommands = {
\ 'rust': ['rust-analyzer'],
\ 'javascript': ['typescript-language-server', '--stdio'],
\ 'python': ['pyls'],
\ }
" You must set the default ui.
" Note: ff ui
" https://github.com/Shougo/ddu-ui-ff
call ddu#custom#patch_global({
\ 'ui': 'ff',
\ })
" You must set the default action.
" Note: file kind
" https://github.com/Shougo/ddu-kind-file
call ddu#custom#patch_global({
\ 'kindOptions': {
\ 'file': {
\ 'defaultAction': 'open',
\ },
\ }
\ })
" Specify matcher.
" Note: matcher_substring filter
" https://github.com/Shougo/ddu-filter-matcher_substring
call ddu#custom#patch_global({
\ 'sourceOptions': {
\ '_': {
\ 'matchers': ['matcher_substring'],
\ },
\ }
\ })
" Automatically start language servers.
let g:LanguageClient_autoStart = 1
let g:deoplete#enable_at_startup = 1
" Or, you could use neovim's floating text feature.
let g:echodoc#enable_at_startup = 1
let g:echodoc#type = 'floating'
" To use a custom highlight for the float window,
" change Pmenu to your highlight group
highlight link EchoDocFloat Pmenu
" Automatically run :RustFmt when saving a buffer.
let g:rustfmt_autosave = 1
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
nnoremap <silent> cf :silent !cargo fix --lib --broken-code --allow-dirty<CR>
sudo apt install neovim npm node-tslib node-typescript node-gulp-tsb python3-pyls
sudo npm install -g typescript-language-server typescript
curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
curl -fsSL https://deno.land/install.sh | sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile complete -y
tee -a ~/.bashrc < env.sh
git clone --depth=1 -b release https://github.com/rust-lang/rust-analyzer.git ~/rust-analyzer
cd ~/rust-analyzer
CARGO_PROFILE_RELEASE_LTO="true" CARGO_PROFILE_RELEASE_CODEGEN_UNITS="1" \
RUSTFLAGS="-Ctarget-cpu=native" cargo xtask install --server
cd -
mkdir -p ~/.config/nvim
cp init.vim ~/.config/nvim/
nvim +PlugInstall +UpdateRemotePlugins +qa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment