Skip to content

Instantly share code, notes, and snippets.

@waynr
Last active November 19, 2018 21:14
Show Gist options
  • Save waynr/a648b08794060ca390871c5434252a06 to your computer and use it in GitHub Desktop.
Save waynr/a648b08794060ca390871c5434252a06 to your computer and use it in GitHub Desktop.
attempt to get neovim + rls + LanguageClient-neovim working together
11:07:36 INFO reader-main src/vim.rs:390 <= None {"id": 1, "jsonrpc": "2.0", "method": "languageClient/findLocations", "params": {"gotoCmd": null, "character": 43, "handle": true, "languageId": "rust", "method": "textDocument/definition", "line": 8, "buftype": "", "text": ["extern crate rand;", "", "use std::io;", "use rand::Rng;", "", "fn main() {", " println!(\"guess a number\");", "", " let secret_number = rand::thread_rng().gen_range(1, 101);", "", " println!(\"the secret number is: {}\", secret_number);", "", " println!(\"please input your guess:\");", "", " let mut guess = String::new();", "", " io::stdin().read_line(&mut guess)", " .expect(\"failed to read line\");", "", " println!(\"You guessed: {}\", guess);", "}", ""], "filename": "/home/wayne/projects/learn/rust-lang-book/guessing_game/src/main.rs"}}
11:07:36 INFO main src/languageclient.rs:1741 Begin textDocument/didChange
11:07:36 INFO main src/languageclient.rs:49 gather_args: [LanguageId, Filename] = [String("rust"), String("/home/wayne/projects/learn/rust-lang-book/guessing_game/src/main.rs")]
11:07:36 INFO main src/languageclient.rs:49 gather_args: [Text] = [Array([String("extern crate rand;"), String(""), String("use std::io;"), String("use rand::Rng;"), String(""), String("fn main() {"), String(" println!(\"guess a number\");"), String(""), String(" let secret_number = rand::thread_rng().gen_range(1, 101);"), String(""), String(" println!(\"the secret number is: {}\", secret_number);"), String(""), String(" println!(\"please input your guess:\");"), String(""), String(" let mut guess = String::new();"), String(""), String(" io::stdin().read_line(&mut guess)"), String(" .expect(\"failed to read line\");"), String(""), String(" println!(\"You guessed: {}\", guess);"), String("}"), String("")])]
11:07:36 INFO main src/languageclient.rs:1762 Texts equal. Skipping didChange.
11:07:36 INFO main src/languageclient.rs:49 gather_args: ["method"] = [String("textDocument/definition")]
11:07:36 INFO main src/languageclient.rs:1055 Begin textDocument/definition
11:07:36 INFO main src/languageclient.rs:30 Some arguments are not available. Requesting from vim. Keys: ["cword"]. Exps: ["expand(\'<cword>\')"]
11:07:36 INFO main src/vim.rs:92 => None {"jsonrpc":"2.0","method":"eval","params":["[expand('<cword>')]"],"id":26}
11:07:36 INFO reader-main src/vim.rs:390 <= None {"id": 26, "jsonrpc": "2.0", "result": ["gen_range"]}
11:07:36 INFO main src/languageclient.rs:49 gather_args: [LanguageId, Filename, Cword, Line, Character, Handle, GotoCmd] = [String("rust"), String("/home/wayne/projects/learn/rust-lang-book/guessing_game/src/main.rs"), String("gen_range"), Number(8), Number(43), Bool(true), Null]
11:07:36 INFO main src/vim.rs:92 => Some("rust") {"jsonrpc":"2.0","method":"textDocument/definition","params":{"buftype":"","character":43,"filename":"/home/wayne/projects/learn/rust-lang-book/guessing_game/src/main.rs","gotoCmd":null,"handle":true,"languageId":"rust","line":8,"method":"textDocument/definition","position":{"character":43,"line":8},"text":["extern crate rand;","","use std::io;","use rand::Rng;","","fn main() {"," println!(\"guess a number\");",""," let secret_number = rand::thread_rng().gen_range(1, 101);",""," println!(\"the secret number is: {}\", secret_number);",""," println!(\"please input your guess:\");",""," let mut guess = String::new();",""," io::stdin().read_line(&mut guess)"," .expect(\"failed to read line\");",""," println!(\"You guessed: {}\", guess);","}",""],"textDocument":{"uri":"file:///home/wayne/projects/learn/rust-lang-book/guessing_game/src/main.rs"}},"id":27}
11:07:36 INFO reader-rust src/vim.rs:390 <= Some("rust") {"jsonrpc":"2.0","id":27,"result":[]}
11:07:36 INFO main src/vim.rs:92 => None {"jsonrpc":"2.0","method":"s:Echowarn","params":["Not found!"]}
11:07:36 INFO main src/languageclient.rs:1122 End textDocument/definition
11:07:36 INFO main src/vim.rs:92 => None {"jsonrpc":"2.0","result":[],"id":1}
call plug#begin('~/.local/share/nvim/plugged')
Plug 'autozimu/LanguageClient-neovim', { 'do': ':UpdateRemotePlugins' }
Plug 'rust-lang/rust.vim'
call plug#end()
autocmd BufReadPost *.rs setlocal filetype=rust
" Required for operations modifying multiple buffers like rename.
set hidden
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ }
" Always draw sign column. Prevent buffer moving when adding/deleting sign.
set signcolumn=yes
let $RUST_BACKTRACE = 1
let g:LanguageClient_loggingLevel = 'DEBUG'
let g:LanguageClient_loggingFile = expand('~/.local/share/nvim/LanguageClient.log')
let g:LanguageClient_serverStderr = expand('~/.local/share/nvim/LanguageServer.log')
" Automatically start language servers.
let g:LanguageClient_autoStart = 1
" Maps K to hover, gd to goto definition, F2 to rename
nnoremap <silent> K :call LanguageClient_textDocument_hover()
nnoremap <silent> gd :call LanguageClient_textDocument_definition()
nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()
extern crate rand;
use std::io;
use rand::Rng;
fn prompt() {
println!("guess a number");
}
fn main() {
prompt();
let secret_number = rand::thread_rng().gen_range(1, 101);
println!("the secret number is: {}", secret_number);
println!("please input your guess:");
let mut guess = String::new();
io::stdin().read_line(&mut guess)
.expect("failed to read line");
println!("You guessed: {}", guess);
}
@waynr
Copy link
Author

waynr commented Nov 19, 2018

With my cursor over gen_range I attempt :call LanguageClient_textDocument_definition() and get Not Found!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment