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.

61 lines
1.4 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 = cababilities,
  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. volar = {
  39. filetypes = {'typescript', 'javascript', 'vue', 'json'},
  40. init_options = {
  41. typescript = {
  42. tsdk = '/usr/lib/node_modules/typescript/lib'
  43. }
  44. }
  45. }
  46. }
  47. function M.setup()
  48. for server_name, o in pairs(servers) do
  49. require('lspconfig')[server_name].setup(o)
  50. end
  51. end
  52. return M