lua.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua
  2. local runtime_path = vim.split(package.path, ";")
  3. table.insert(runtime_path, "lua/?.lua")
  4. table.insert(runtime_path, "lua/?/init.lua")
  5. return {
  6. on_setup = function(server)
  7. server.setup({
  8. single_file_support = true,
  9. settings = {
  10. Lua = {
  11. runtime = {
  12. version = "LuaJIT",
  13. path = runtime_path,
  14. },
  15. diagnostics = {
  16. -- Get the language server to recognize the `vim` global
  17. globals = {
  18. "vim",
  19. },
  20. },
  21. workspace = {
  22. -- Make the server aware of Neovim runtime files
  23. library = vim.api.nvim_get_runtime_file("", true),
  24. checkThirdParty = false,
  25. },
  26. -- Do not send telemetry data containing a randomized but unique identifier
  27. telemetry = {
  28. enable = false,
  29. },
  30. },
  31. },
  32. on_attach = function(client, bufnr)
  33. -- 禁用格式化功能,交给专门插件插件处理
  34. client.server_capabilities.document_formatting = false
  35. client.server_capabilities.document_range_formatting = false
  36. require("keybindings").lspList(bufnr)
  37. -- 保存时自动格式化
  38. -- vim.cmd("autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync()")
  39. end,
  40. })
  41. end,
  42. }