1
0

lsp.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. vim.diagnostic.config({
  2. -- only show virtual text for WARN and higher
  3. virtual_text = { severity = { min = vim.diagnostic.severity.WARN } },
  4. })
  5. vim.lsp.config('*', {
  6. capabilities = require('cmp_nvim_lsp').default_capabilities(),
  7. })
  8. vim.lsp.enable("bashls");
  9. vim.lsp.enable("eslint");
  10. if vim.fn.executable("dprint") == 1 then
  11. local version = vim.version.parse(vim.fn.system("dprint --version"))
  12. if vim.version.cmp(version, {0,45,0}) >= 0 then
  13. vim.lsp.enable("dprint")
  14. end
  15. end
  16. if vim.fn.executable("deno") == 1 then
  17. vim.lsp.enable("deno");
  18. else
  19. require('typescript').setup({
  20. server = {
  21. init_options = {
  22. completionDisableFilterText = true,
  23. preferences = {
  24. importModuleSpecifierPreference = 'non-relative',
  25. -- this prevents renames from aliasing when destructuring
  26. providePrefixAndSuffixTextForRename = false,
  27. },
  28. },
  29. handlers = {
  30. ['$/typescriptVersion'] = function(err, result, ctx, config)
  31. vim.notify(string.format('Typescript %s', result.version))
  32. end
  33. },
  34. flags = {
  35. debounce_text_changes = 150,
  36. },
  37. on_init = function(client)
  38. -- mark tsserver as not having formatting available as we rely on
  39. -- eslint and dprint for that
  40. client.server_capabilities.documentFormattingProvider = false
  41. client.server_capabilities.documentRangeFormattingProvider = false
  42. end,
  43. }
  44. })
  45. end
  46. if vim.fn.executable("gopls") == 1 then
  47. vim.lsp.enable("gopls")
  48. end
  49. if vim.fn.executable("ruby-lsp") == 1 then
  50. vim.lsp.config("ruby_lsp", {
  51. init_options = {
  52. enabledFeatures = {
  53. formatting = false,
  54. },
  55. }
  56. })
  57. vim.lsp.enable("ruby_lsp")
  58. end
  59. if vim.fn.executable("nil") == 1 then
  60. vim.lsp.enable("nil_ls")
  61. end
  62. if vim.fn.executable("jdtls") == 1 then
  63. vim.lsp.config("jdtls", {
  64. handlers = {
  65. ["$/progress"] = function()
  66. -- this is quite noisy so just disable it
  67. end
  68. },
  69. })
  70. vim.lsp.enable("jdtls")
  71. end
  72. -- custom LSP servers
  73. vim.lsp.config("elvish", {
  74. cmd = {'elvish', '--lsp'},
  75. filetypes = {'elvish'},
  76. settings = {},
  77. })
  78. vim.lsp.enable("elvish")