You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.3 KiB

  1. local M = {}
  2. local keymap = vim.api.nvim_set_keymap
  3. local buf_keymap = vim.api.nvim_buf_set_keymap
  4. local function keymappings(client, bufnr)
  5. local opts = { noremap = true, silent = true }
  6. -- Key mappings
  7. vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
  8. vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
  9. vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
  10. vim.keymap.set("n", "[e", function () vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR}) end, opts)
  11. vim.keymap.set("n", "]e", function () vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR}) end, opts)
  12. vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
  13. vim.keymap.set("n", "K", vim.lsp.buf.code_action, opts)
  14. vim.keymap.set("n", "<leader>of", vim.diagnostic.open_float, opts)
  15. if client.resolved_capabilities.document_formatting then
  16. vim.keymap.set("n", "<leader>ff", vim.lsp.buf.formatting, opts)
  17. end
  18. vim.keymap.set("n", "<leader>d", vim.lsp.buf.definition, opts)
  19. vim.keymap.set("n", "<leader>D", vim.lsp.buf.declaration, opts)
  20. vim.keymap.set("n", "<leader>h", vim.lsp.buf.signature_help, opts)
  21. vim.keymap.set("n", "<leader>i", vim.lsp.buf.implementation, opts)
  22. vim.keymap.set("n", "<leader>T", vim.lsp.buf.type_definition, opts)
  23. end
  24. function M.setup(client, bufnr)
  25. keymappings(client, bufnr)
  26. end
  27. return M