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.

75 lines
1.7 KiB

  1. local M = {}
  2. local function on_attach(client, bufnr)
  3. -- Enable completion triggered by <C-X><C-O>
  4. -- See `:help omnifunc` and `:help ins-completion` for more information.
  5. vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
  6. -- Use LSP as the handler for formatexpr.
  7. -- See `:help formatexpr` for more information.
  8. vim.api.nvim_buf_set_option(0, "formatexpr", "v:lua.vim.lsp.formatexpr()")
  9. -- Configure key mappings
  10. require("config.lsp.keymaps").setup(client, bufnr)
  11. end
  12. local lsp_signature = require "lsp_signature"
  13. lsp_signature.setup {
  14. bind = true,
  15. handler_opts = {
  16. border = "rounded",
  17. },
  18. }
  19. local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
  20. local opts = {
  21. on_attach = on_attach,
  22. capabilities = capabilities,
  23. flags = {
  24. debounce_text_changes = 150,
  25. },
  26. };
  27. local servers = {
  28. gopls = opts,
  29. html = opts,
  30. jsonls = opts,
  31. pyright = opts,
  32. tsserver = opts,
  33. vimls = opts,
  34. dartls = opts,
  35. dockerls = opts,
  36. intelephense = opts,
  37. sqlls = opts,
  38. vuels = {
  39. on_attach = on_attach,
  40. capabilities = capabilities,
  41. flags = {
  42. debounce_text_changes = 150,
  43. },
  44. init_options = {
  45. config = {
  46. vetur = {
  47. ignoreProjectWarning = true,
  48. }
  49. }
  50. },
  51. },
  52. volar = {
  53. filetypes = {'typescript', 'javascript', 'vue', 'json'},
  54. init_options = {
  55. typescript = {
  56. tsdk = '/usr/lib/node_modules/typescript/lib'
  57. }
  58. }
  59. }
  60. }
  61. function M.setup()
  62. for server_name, o in pairs(servers) do
  63. require('lspconfig')[server_name].setup(o)
  64. end
  65. end
  66. return M