diff options
author | eine <eine@users.noreply.github.com> | 2020-08-15 18:07:05 +0200 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2020-08-23 21:21:15 +0200 |
commit | 4abeb0683159cdc4482a7f491340bfedf3fe2339 (patch) | |
tree | 9670c82ea88c9d6338ee2be58ea291154ffcaf8b /python/vhdl_langserver/vhdl_ls.py | |
parent | 8789de969e6673b195cbb28a692cc3fbbaa806e1 (diff) | |
download | ghdl-4abeb0683159cdc4482a7f491340bfedf3fe2339.tar.gz ghdl-4abeb0683159cdc4482a7f491340bfedf3fe2339.tar.bz2 ghdl-4abeb0683159cdc4482a7f491340bfedf3fe2339.zip |
python: execute 'black'
Diffstat (limited to 'python/vhdl_langserver/vhdl_ls.py')
-rw-r--r-- | python/vhdl_langserver/vhdl_ls.py | 111 |
1 files changed, 61 insertions, 50 deletions
diff --git a/python/vhdl_langserver/vhdl_ls.py b/python/vhdl_langserver/vhdl_ls.py index c2559630e..61c4aed23 100644 --- a/python/vhdl_langserver/vhdl_ls.py +++ b/python/vhdl_langserver/vhdl_ls.py @@ -12,23 +12,23 @@ class VhdlLanguageServer(object): self.lsp = None self._shutdown = False self.dispatcher = { - 'initialize': self.initialize, - 'initialized': self.initialized, - 'shutdown': self.shutdown, - '$/setTraceNotification': self.setTraceNotification, - 'textDocument/didOpen': self.textDocument_didOpen, - 'textDocument/didChange': self.textDocument_didChange, - 'textDocument/didClose': self.textDocument_didClose, - 'textDocument/didSave': self.textDocument_didSave, + "initialize": self.initialize, + "initialized": self.initialized, + "shutdown": self.shutdown, + "$/setTraceNotification": self.setTraceNotification, + "textDocument/didOpen": self.textDocument_didOpen, + "textDocument/didChange": self.textDocument_didChange, + "textDocument/didClose": self.textDocument_didClose, + "textDocument/didSave": self.textDocument_didSave, # 'textDocument/hover': self.hover, - 'textDocument/definition': self.textDocument_definition, - 'textDocument/documentSymbol': self.textDocument_documentSymbol, + "textDocument/definition": self.textDocument_definition, + "textDocument/documentSymbol": self.textDocument_documentSymbol, # 'textDocument/completion': self.completion, - 'textDocument/rangeFormatting': self.textDocument_rangeFormatting, - 'workspace/xShowAllFiles': self.workspace_xShowAllFiles, - 'workspace/xGetAllEntities': self.workspace_xGetAllEntities, - 'workspace/xGetEntityInterface': self.workspace_xGetEntityInterface, - } + "textDocument/rangeFormatting": self.textDocument_rangeFormatting, + "workspace/xShowAllFiles": self.workspace_xShowAllFiles, + "workspace/xGetAllEntities": self.workspace_xGetAllEntities, + "workspace/xGetEntityInterface": self.workspace_xGetEntityInterface, + } def set_lsp(self, server): self.lsp = server @@ -41,80 +41,91 @@ class VhdlLanguageServer(object): def capabilities(self): server_capabilities = { - 'textDocumentSync': { - 'openClose': True, - 'change': lsp.TextDocumentSyncKind.INCREMENTAL, - 'save': { - 'includeText': True} - }, - 'hoverProvider': False, + "textDocumentSync": { + "openClose": True, + "change": lsp.TextDocumentSyncKind.INCREMENTAL, + "save": {"includeText": True}, + }, + "hoverProvider": False, # 'completionProvider': False, # 'signatureHelpProvider': { # 'triggerCharacters': ['(', ','] # }, - 'definitionProvider': True, - 'referencesProvider': False, - 'documentHighlightProvider': False, - 'documentSymbolProvider': True, - 'codeActionProvider': False, - 'documentFormattingProvider': False, - 'documentRangeFormattingProvider': True, - 'renameProvider': False, + "definitionProvider": True, + "referencesProvider": False, + "documentHighlightProvider": False, + "documentSymbolProvider": True, + "codeActionProvider": False, + "documentFormattingProvider": False, + "documentRangeFormattingProvider": True, + "renameProvider": False, } return server_capabilities - def initialize(self, processId, rootPath, capabilities, rootUri=None, - initializationOptions=None, **_): - log.debug('Language server initialized with %s %s %s %s', - processId, rootUri, rootPath, initializationOptions) + def initialize( + self, + processId, + rootPath, + capabilities, + rootUri=None, + initializationOptions=None, + **_ + ): + log.debug( + "Language server initialized with %s %s %s %s", + processId, + rootUri, + rootPath, + initializationOptions, + ) if rootUri is None: - rootUri = lsp.path_to_uri(rootPath) if rootPath is not None else '' + rootUri = lsp.path_to_uri(rootPath) if rootPath is not None else "" self.workspace = Workspace(rootUri, self.lsp) # Get our capabilities - return {'capabilities': self.capabilities()} + return {"capabilities": self.capabilities()} def initialized(self): # Event when the client is fully initialized. return None def textDocument_didOpen(self, textDocument=None): - doc_uri = textDocument['uri'] - self.workspace.put_document(doc_uri, textDocument['text'], - version=textDocument.get('version')) + doc_uri = textDocument["uri"] + self.workspace.put_document( + doc_uri, textDocument["text"], version=textDocument.get("version") + ) self.lint(doc_uri) - def textDocument_didChange(self, textDocument=None, contentChanges=None, - **_kwargs): - doc_uri = textDocument['uri'] - new_version = textDocument.get('version') + def textDocument_didChange(self, textDocument=None, contentChanges=None, **_kwargs): + doc_uri = textDocument["uri"] + new_version = textDocument.get("version") self.workspace.apply_changes(doc_uri, contentChanges, new_version) def lint(self, doc_uri): self.workspace.lint(doc_uri) def textDocument_didClose(self, textDocument=None, **_kwargs): - self.workspace.rm_document(textDocument['uri']) + self.workspace.rm_document(textDocument["uri"]) def textDocument_didSave(self, textDocument=None, text=None, **_kwargs): if text is not None: # Sanity check: check we have the same content for the document. - self.workspace.check_document(textDocument['uri'], text) + self.workspace.check_document(textDocument["uri"], text) else: log.debug("did save - no text") - self.lint(textDocument['uri']) + self.lint(textDocument["uri"]) def textDocument_definition(self, textDocument=None, position=None): - return self.workspace.goto_definition(textDocument['uri'], position) + return self.workspace.goto_definition(textDocument["uri"], position) def textDocument_documentSymbol(self, textDocument=None): - doc = self.workspace.get_or_create_document(textDocument['uri']) + doc = self.workspace.get_or_create_document(textDocument["uri"]) return doc.document_symbols() def textDocument_rangeFormatting(self, textDocument=None, range=None, options=None): - doc_uri = textDocument['uri'] + doc_uri = textDocument["uri"] doc = self.workspace.get_document(doc_uri) - assert doc is not None, 'Try to format a non-loaded document' + assert doc is not None, "Try to format a non-loaded document" res = doc.format_range(range) if res is not None: self.lint(doc_uri) |