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.

164 lines
3.8 KiB

4 years ago
  1. """
  2. This module contains variables with global |jedi| settings. To change the
  3. behavior of |jedi|, change the variables defined in :mod:`jedi.settings`.
  4. Plugins should expose an interface so that the user can adjust the
  5. configuration.
  6. Example usage::
  7. from jedi import settings
  8. settings.case_insensitive_completion = True
  9. Completion output
  10. ~~~~~~~~~~~~~~~~~
  11. .. autodata:: case_insensitive_completion
  12. .. autodata:: add_bracket_after_function
  13. .. autodata:: no_completion_duplicates
  14. Filesystem cache
  15. ~~~~~~~~~~~~~~~~
  16. .. autodata:: cache_directory
  17. .. autodata:: use_filesystem_cache
  18. Parser
  19. ~~~~~~
  20. .. autodata:: fast_parser
  21. Dynamic stuff
  22. ~~~~~~~~~~~~~
  23. .. autodata:: dynamic_array_additions
  24. .. autodata:: dynamic_params
  25. .. autodata:: dynamic_params_for_other_modules
  26. .. autodata:: additional_dynamic_modules
  27. .. autodata:: auto_import_modules
  28. Caching
  29. ~~~~~~~
  30. .. autodata:: call_signatures_validity
  31. """
  32. import os
  33. import platform
  34. # ----------------
  35. # completion output settings
  36. # ----------------
  37. case_insensitive_completion = True
  38. """
  39. The completion is by default case insensitive.
  40. """
  41. add_bracket_after_function = False
  42. """
  43. Adds an opening bracket after a function, because that's normal behaviour.
  44. Removed it again, because in VIM that is not very practical.
  45. """
  46. no_completion_duplicates = True
  47. """
  48. If set, completions with the same name don't appear in the output anymore,
  49. but are in the `same_name_completions` attribute.
  50. """
  51. # ----------------
  52. # Filesystem cache
  53. # ----------------
  54. use_filesystem_cache = True
  55. """
  56. Use filesystem cache to save once parsed files with pickle.
  57. """
  58. if platform.system().lower() == 'windows':
  59. _cache_directory = os.path.join(os.getenv('APPDATA') or '~', 'Jedi',
  60. 'Jedi')
  61. elif platform.system().lower() == 'darwin':
  62. _cache_directory = os.path.join('~', 'Library', 'Caches', 'Jedi')
  63. else:
  64. _cache_directory = os.path.join(os.getenv('XDG_CACHE_HOME') or '~/.cache',
  65. 'jedi')
  66. cache_directory = os.path.expanduser(_cache_directory)
  67. """
  68. The path where the cache is stored.
  69. On Linux, this defaults to ``~/.cache/jedi/``, on OS X to
  70. ``~/Library/Caches/Jedi/`` and on Windows to ``%APPDATA%\\Jedi\\Jedi\\``.
  71. On Linux, if environment variable ``$XDG_CACHE_HOME`` is set,
  72. ``$XDG_CACHE_HOME/jedi`` is used instead of the default one.
  73. """
  74. # ----------------
  75. # parser
  76. # ----------------
  77. fast_parser = True
  78. """
  79. Use the fast parser. This means that reparsing is only being done if
  80. something has been changed e.g. to a function. If this happens, only the
  81. function is being reparsed.
  82. """
  83. # ----------------
  84. # dynamic stuff
  85. # ----------------
  86. dynamic_array_additions = True
  87. """
  88. check for `append`, etc. on arrays: [], {}, () as well as list/set calls.
  89. """
  90. dynamic_params = True
  91. """
  92. A dynamic param completion, finds the callees of the function, which define
  93. the params of a function.
  94. """
  95. dynamic_params_for_other_modules = True
  96. """
  97. Do the same for other modules.
  98. """
  99. additional_dynamic_modules = []
  100. """
  101. Additional modules in which |jedi| checks if statements are to be found. This
  102. is practical for IDEs, that want to administrate their modules themselves.
  103. """
  104. dynamic_flow_information = True
  105. """
  106. Check for `isinstance` and other information to infer a type.
  107. """
  108. auto_import_modules = [
  109. 'hashlib', # hashlib is mostly using setattr, which jedi doesn't understand
  110. 'gi', # This third-party repository (GTK stuff) doesn't really work with jedi
  111. ]
  112. """
  113. Modules that are not analyzed but imported, although they contain Python code.
  114. This improves autocompletion for libraries that use ``setattr`` or
  115. ``globals()`` modifications a lot.
  116. """
  117. # ----------------
  118. # caching validity (time)
  119. # ----------------
  120. call_signatures_validity = 3.0
  121. """
  122. Finding function calls might be slow (0.1-0.5s). This is not acceptible for
  123. normal writing. Therefore cache it for a short time.
  124. """