You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
I am experiencing trouble getting rust-tools to work smoothly with nvim-lsp rust analyzer setup. Depending on the position of require"rust-tools".setup({}) line relative to require"lspconfig".rust_analyzer.setup(opts) things break in two ways:
require"rust-tools".setup({})beforerequire"lspconfig".rust_analyzer.setup(opts) : A large part of "rust-tools" commands goes missing (e.g. RustDebuggables, RustRunnables are not there)
require"rust-tools".setup({})afterrequire"lspconfig".rust_analyzer.setup(...): My keymaps stop working for the nvim lsp commands (running commands directly works just fine: lua vim.lsp.buf.rename() does the job)
I have checked out #114 which sounded similar to my case but couldn't find any one plugin that interfered with the expected behaviour.
Would be grateful for hints on where to look further!
System Info (Arch Linux):
NVIM v0.6.0
Build type: Release
LuaJIT 2.0.5
Compiled by builduser
Miminal init.lua to reproduce the issue:
vim.g.mapleader = ' '
local fn = vim.fn
local execute = vim.api.nvim_command
local install_path = fn.stdpath('data')..'/site/pack/packer/opt/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
execute('!git clone https://github.com/wbthomason/packer.nvim '..install_path)
end
vim.cmd [[packadd packer.nvim]]
vim.cmd 'autocmd BufWritePost plugins.lua PackerCompile' -- Auto compile when there are
require('packer').startup(function()
-- native Neovim Lsp
use {'neovim/nvim-lspconfig'}
use {'simrat39/rust-tools.nvim'}
end)
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', { noremap=true })
buf_set_keymap('n', '<space>gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
end
nvim_lsp.rust_analyzer.setup{
on_attach = on_attach,
settings = {
["rust-analyzer"] = {
cargo = { loadOutDirsFromCheck = true },
procMacro = { enable = true },
},
},
}
require("rust-tools").setup({})
and a sample rust file where renaming and going to definitions shortcuts can be tested to work or not depending on the position of the require("rust-tools").setup({}) line:
The text was updated successfully, but these errors were encountered:
ambushed
changed the title
rust-tools.setup{} messes with keymaps of lsp setup for rust_analyzer
rust-tools.setup{} seems to mess with keymaps of lsp setup for rust_analyzer
Jan 12, 2022
I realize that the problem description is a bit vague, so i have included the minimal init.lua that showcases the issue i am having. Any help is appreciated!
You aren't supposed to setup both lspconfig's rust analyzer and rust-tools as rust-tools automatically sets up the lsp. you can pass your on attach and other server config to the server table in the opts (check the example config in the readme).
Sorry for the late reply, haven't gotten much free time on my hands lately.
I am experiencing trouble getting rust-tools to work smoothly with nvim-lsp rust analyzer setup. Depending on the position of
require"rust-tools".setup({})
line relative torequire"lspconfig".rust_analyzer.setup(opts)
things break in two ways:require"rust-tools".setup({})
beforerequire"lspconfig".rust_analyzer.setup(opts)
: A large part of "rust-tools" commands goes missing (e.g. RustDebuggables, RustRunnables are not there)require"rust-tools".setup({})
afterrequire"lspconfig".rust_analyzer.setup(...)
: My keymaps stop working for the nvim lsp commands (running commands directly works just fine:lua vim.lsp.buf.rename()
does the job)I have checked out #114 which sounded similar to my case but couldn't find any one plugin that interfered with the expected behaviour.
Would be grateful for hints on where to look further!
System Info (Arch Linux):
Miminal init.lua to reproduce the issue:
and a sample rust file where renaming and going to definitions shortcuts can be tested to work or not depending on the position of the
require("rust-tools").setup({})
line:The text was updated successfully, but these errors were encountered: