python-ls.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- npm i -g pyright
  2. require'lspconfig'.pyright.setup {
  3. cmd = {
  4. DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver",
  5. "--stdio"
  6. },
  7. on_attach = require'lsp'.common_on_attach,
  8. handlers = {
  9. ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic
  10. .on_publish_diagnostics,
  11. {
  12. virtual_text = O.lang.python.diagnostics.virtual_text,
  13. signs = O.lang.python.diagnostics.signs,
  14. underline = O.lang.python.diagnostics.underline,
  15. update_in_insert = true
  16. })
  17. },
  18. settings = {
  19. python = {
  20. analysis = {
  21. typeCheckingMode = O.lang.python.analysis.type_checking,
  22. autoSearchPaths = O.lang.python.analysis.auto_search_paths,
  23. useLibraryCodeForTypes = O.lang.python.analysis
  24. .use_library_code_types
  25. }
  26. }
  27. }
  28. }
  29. if O.lang.python.autoformat then
  30. require('lv-utils').define_augroups({
  31. _python_autoformat = {
  32. {
  33. 'BufWritePre', '*.py',
  34. 'lua vim.lsp.buf.formatting_sync(nil, 1000)'
  35. }
  36. }
  37. })
  38. end