Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mappings don't get applied for rust_analyzer #42

Closed
itmecho opened this issue Oct 26, 2022 · 1 comment
Closed

Mappings don't get applied for rust_analyzer #42

itmecho opened this issue Oct 26, 2022 · 1 comment

Comments

@itmecho
Copy link

itmecho commented Oct 26, 2022

First off thanks for the great plugin! It really simplifies the LSP experience for neovim.

I'm having an issue where my mappings aren't getting set when rust_analyzer attaches to a buffer. They work fine for all the other language servers I have configured.

This is my config for lsp-setup:

require('lsp-setup').setup({
  default_mappings = false,
  mappings = {
    gd = 'Telescope lsp_definitions',
    gD = 'lua vim.lsp.buf.declaration()',
    gT = 'Telescope lsp_type_definitions',
    gr = 'Telescope lsp_references',
    gI = 'Telescope lsp_implementations',
    gR = 'lua vim.lsp.buf.rename()',
    ga = 'lua vim.lsp.buf.code_action()',
    gs = 'Telescope lsp_document_symbols',
    gS = 'Telescope lsp_dynamic_workspace_symbols',
    gx = 'LspRestart',
    go = 'SymbolsOutline',
    K = 'lua vim.lsp.buf.hover()',
  },
  on_attach = function(client)
    if client.name ~= 'null-ls' then
      client.server_capabilities.documentFormattingProvider = false
    end
  end,
  servers = {
    astro = {},
    emmet_ls = {},
    gopls = {
      flags = {
        debounce_text_changes = 300,
      },
    },
    rust_analyzer = {
      settings = {
        ['rust-analyzer'] = {
          cargo = {
            buildScripts = {
              enable = true,
            },
          },
        },
      },
    },
    sumneko_lua = {
      settings = {
        Lua = {
          runtime = {
            version = 'LuaJIT',
          },
          diagnostics = {
            globals = { 'vim', 's', 't', 'i', 'c', 'fmt', 'fmta' },
          },
          workspace = {
            library = vim.api.nvim_get_runtime_file('', true),
          },
        },
      },
    },
    tsserver = {
      flags = {
        debounce_text_changes = 300,
      },
    },
  },
})

LspInfo shows that rust_analyzer has successfully attached to the buffer:

 Language client log: ~/.local/state/nvim/lsp.log
 Detected filetype:   rust
 
 2 client(s) attached to this buffer: 
 
 Client: rust_analyzer (id: 1, pid: nil, bufnr: [1, 36, 18])
 	filetypes:       rust
 	autostart:       true
 	root directory:  ~/src/gallery
 	cmd:             rust-analyzer
 
 Client: null-ls (id: 2, pid: 5001, bufnr: [1, 47, 18, 36])
 	filetypes:       python, go, css, astro, rust, lua, luau, tf, terraform
 	autostart:       false
 	root directory:  ~/src/gallery
 	cmd:             <function>

Calling the functions manually works fine too:

image

@junnplus
Copy link
Owner

junnplus commented Mar 18, 2023

I seem to have missed this issue. I'm sorry I can't reproduce it, is this problem still present now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants