lsp.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. return {
  2. {
  3. "neovim/nvim-lspconfig",
  4. enabled = true,
  5. lazy = false,
  6. config = function(_, _)
  7. -- Configuration on attach
  8. vim.api.nvim_create_autocmd("LspAttach", {
  9. group = vim.api.nvim_create_augroup("UserLspConfig", {}),
  10. callback = function(args)
  11. if vim.treesitter ~= nil and type(vim.treesitter.highlighter.active[args.buf]) ~= "nil" then
  12. local client = vim.lsp.get_client_by_id(args.data
  13. .client_id)
  14. client.server_capabilities.semanticTokensProvider = nil
  15. end
  16. vim.keymap.set("n", "SR", vim.lsp.buf.rename)
  17. vim.keymap.set("n", "Sx", vim.lsp.buf.code_action)
  18. vim.keymap.set("n", "SI", function()
  19. local diagnostic_config = vim.diagnostic.config()
  20. if (vim.lsp.inlay_hint.is_enabled()) then
  21. vim.lsp.inlay_hint.enable(false)
  22. vim.diagnostic.config({
  23. virtual_lines = {
  24. current_line = true,
  25. format = diagnostic_config.format
  26. }
  27. })
  28. else
  29. vim.lsp.inlay_hint.enable(true)
  30. vim.diagnostic.config({
  31. virtual_lines = true,
  32. format = diagnostic_config.format
  33. })
  34. end
  35. end)
  36. vim.keymap.set("n", "<Space>", vim.lsp.buf.hover)
  37. end
  38. })
  39. end
  40. }
  41. }