elianiva / dotfiles

.
187 stars 12 forks source link

[question] I'm puzzled that the `vim.api.nvim_buf_set_keymap` can not work #6

Closed lqfxz520 closed 2 years ago

lqfxz520 commented 2 years ago

Parameter 5: Accept callback as key is unknown key, An error occurs when executing code Can you tell me why?

local map = vim.api.nvim_buf_set_keymap
M.lsp_mappings = function(bufnr)
  map(bufnr, "i", "<C-s>", "", {
    callback = vim.lsp.buf.signature_help,
    desc = "Trigger signature help from the language server",
    noremap = true,
    silent = true,
  })
end
elianiva commented 2 years ago

what neovim version do you have?

lqfxz520 commented 2 years ago

The version number of Neovim is 6.1, so it needs a higher version number than neovim, right?

elianiva commented 2 years ago

yes, it's a relatively new API from ~13 days ago

lqfxz520 commented 2 years ago

I see. Your code is very useful to me Thank you for your answer.

lqfxz520 commented 2 years ago

Hello, @elianiva method M.workspace_symbols is called in file modules/lsp/mappings.lua, but method M.workspace_symbols is defined in file plugins/telescope.lua. This is supposed to be a module variable, right? Why can it be used in file modules/lsp/mappings.lua

  -- path: plugins/telescope.lua
  M.workspace_symbols = function()
    require("telescope.builtin").lsp_workspace_symbols {
      path_display = { "absolute" },
    }
  end

  -- path: modules/lsp/mappings.lua
  map(bufnr, "n", "<Leader>gs", "", {
    callback = M.workspace_symbols,
    desc = "Find workspace symbols using Telescope",
    noremap = true,
    silent = true,
  })
elianiva commented 2 years ago

you need to do require("plugins.telescope").workspace_symbols instead