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.4 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", "gd", vim.lsp.buf.definition, opts)
  19. vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
  20. -- vim.keymap.set("n", "gr", function() vim.lsp.buf.references({ includeDeclaration = false }) end, opts)
  21. vim.keymap.set("n", "gh", vim.lsp.buf.signature_help, opts)
  22. vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
  23. vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, opts)
  24. end
  25. function M.setup(client, bufnr)
  26. keymappings(client, bufnr)
  27. end
  28. return M