pyls 配置

若如初见. 提交于 2020-02-26 15:54:22

设置代码行为 120 字

~/.config/pycodestyle pycodestyle 官方文档 https://www.osgeo.cn/pycodestyle/intro.html

在项目级别,asetup.cfg文件或tox.ini如果存在,则读取文件。如果这些文件都没有[pycodestyle]节,未加载项目特定的配置。

[pycodestyle]
# count = False
# ignore = E226,E302,E41
max-line-length = 120
# statistics = True

pyls 的main

#!/opt/miniconda3/bin/python

# -*- coding: utf-8 -*-
import re
import sys

from pyls.__main__ import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

python_ls.py 定义了

start_io_lang_server start_tcp_lang_server

LINT_DEBOUNCE_S = 0.5  # 500 ms
PARENT_PROCESS_WATCH_INTERVAL = 10  # 10 s
MAX_WORKERS = 64
PYTHON_FILE_EXTENSIONS = ('.py', '.pyi')
CONFIG_FILEs = ('pycodestyle.cfg', 'setup.cfg', 'tox.ini', '.flake8')
  def start_io_lang_server(rfile, wfile, check_parent_process, handler_class):
      if not issubclass(handler_class, PythonLanguageServer):
         raise ValueError('Handler class must be an instance of PythonLanguageServer')  # E501 line too long (85 > 79 characters)
      log.info('Starting %s IO language server', handler_class.__name__)
      server = handler_class(rfile, wfile, check_parent_process)
      server.start()

handler_class 是 PythonLanguageServer类型 使用这个类型的 实例 的 start() 函数.

PythonLanguageServer 类也是在文件python_ls.py 中定义的.

  class PythonLanguageServer(MethodDispatcher):
      """ Implementation of the Microsoft VSCode Language Server Protocol
      https://github.com/Microsoft/language-server-protocol/blob/master/versions/protocol-1-x.md
	        def __init__(self, rx, tx, check_parent_process=False):
          self.workspace = None
          self.config = None
          self.root_uri = None
          self.watching_thread = None
          self.workspaces = {}
          self.uri_workspace_mapper = {}

          self._jsonrpc_stream_reader = JsonRpcStreamReader(rx)
          self._jsonrpc_stream_writer = JsonRpcStreamWriter(tx)
          self._check_parent_process = check_parent_process
         self._endpoint = Endpoint(self, self._jsonrpc_stream_writer.write, max_workers=MAX_WORKERS) E501 line too long (99 > 79 characters)
          self._dispatchers = []
          self._shutdown = False
      """

      # pylint: disable=too-many-public-methods,redefined-builtin
2020-02-15 22:32:08,879 UTC - INFO - pyls.python_ls - Starting PythonLanguageServer IO language server
2020-02-15 22:32:09,428 UTC - INFO - pyls.config.config - Loaded pyls plugin autopep8 from <module 'pyls.plugins.autopep8_format' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/autopep8_format.py'>
2020-02-15 22:32:09,428 UTC - INFO - pyls.config.config - Loaded pyls plugin flake8 from <module 'pyls.plugins.flake8_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/flake8_lint.py'>
2020-02-15 22:32:09,428 UTC - INFO - pyls.config.config - Loaded pyls plugin folding from <module 'pyls.plugins.folding' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/folding.py'>
2020-02-15 22:32:09,428 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_completion from <module 'pyls.plugins.jedi_completion' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/jedi_completion.py'>
2020-02-15 22:32:09,428 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_definition from <module 'pyls.plugins.definition' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/definition.py'>
2020-02-15 22:32:09,428 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_highlight from <module 'pyls.plugins.highlight' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/highlight.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_hover from <module 'pyls.plugins.hover' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/hover.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_references from <module 'pyls.plugins.references' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/references.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_signature_help from <module 'pyls.plugins.signature' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/signature.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin jedi_symbols from <module 'pyls.plugins.symbols' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/symbols.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin mccabe from <module 'pyls.plugins.mccabe_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/mccabe_lint.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin preload from <module 'pyls.plugins.preload_imports' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/preload_imports.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin pycodestyle from <module 'pyls.plugins.pycodestyle_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/pycodestyle_lint.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin pydocstyle from <module 'pyls.plugins.pydocstyle_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/pydocstyle_lint.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin pyflakes from <module 'pyls.plugins.pyflakes_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/pyflakes_lint.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin pylint from <module 'pyls.plugins.pylint_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/pylint_lint.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin rope_completion from <module 'pyls.plugins.rope_completion' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/rope_completion.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin rope_rename from <module 'pyls.plugins.rope_rename' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/rope_rename.py'>
2020-02-15 22:32:09,429 UTC - INFO - pyls.config.config - Loaded pyls plugin yapf from <module 'pyls.plugins.yapf_format' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/yapf_format.py'>
2020-02-15 22:32:09,430 UTC - INFO - pyls.config.config - Disabled plugins: [<module 'pyls.plugins.flake8_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/flake8_lint.py'>, <module 'pyls.plugins.pydocstyle_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/pydocstyle_lint.py'>, <module 'pyls.plugins.pylint_lint' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/pylint_lint.py'>, <module 'pyls.plugins.rope_completion' from '/opt/miniconda3/lib/python3.7/site-packages/pyls/plugins/rope_completion.py'>]
2020-02-15 22:32:09,831 UTC - INFO - pyls.python_ls - Server capabilities: {'codeActionProvider': True, 'codeLensProvider': {'resolveProvider': False}, 'completionProvider': {'resolveProvider': False, 'triggerCharacters': ['.']}, 'documentFormattingProvider': True, 'documentHighlightProvider': True, 'documentRangeFormattingProvider': True, 'documentSymbolProvider': True, 'definitionProvider': True, 'executeCommandProvider': {'commands': []}, 'hoverProvider': True, 'referencesProvider': True, 'renameProvider': True, 'foldingRangeProvider': True, 'signatureHelpProvider': {'triggerCharacters': ['(', ',', '=']}, 'textDocumentSync': {'change': 2, 'save': {'includeText': True}, 'openClose': True}, 'workspace': {'workspaceFolders': {'supported': True, 'changeNotifications': True}}, 'experimental': {}}



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!