1
0

lsp.lua 2.0 KB

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