コード例 #1
0
ファイル: __init__.py プロジェクト: gish/nvim-typescript
 def on_bufenter(self, args=None):
     """
    Send open event when a ts file is open
     """
     if client.server_handle is None:
         self.tsstart()
     else:
         client.open(self.relative_file())
コード例 #2
0
ファイル: __init__.py プロジェクト: gish/nvim-typescript
 def tsstart(self):
     """
     Stat the client
     """
     if client.server_handle is None:
         should_debug = self.vim.vars["nvim_typescript#debug_enabled"]
         debug_options = self.vim.vars["nvim_typescript#debug_settings"]
         client.setServerPath(self.vim.vars["nvim_typescript#server_path"])
         if client.start(should_debug, debug_options):
             client.setTsConfigVersion()
             client.open(self.relative_file())
             self.printMsg('Server Started')
コード例 #3
0
def parseJson(move_data, plycount):
    print(move_data)

    if (move_data == None):
        return "Data empty"

    _from = move_data["from"]
    to = move_data["to"]

    rowA, colA = _from[:1].upper(), int(_from[1:])
    cellA = (rowA, colA)

    rowB, colB = to[:1].upper(), int(to[1:])
    cellB = (rowB, colB)

    # Make sure client connection is open
    if cl.conn_open == False:
        cl.open()

    # Do take_piece
    if (move_data["capture"]["capture"]):
        pieceA = move_data['piece']
        pieceB = move_data['capture']['piece']
        piece_str = move_data["capture"]["initial_pos_piece"]
        rowP, colP = piece_str[:1].upper(), int(piece_str[1:])
        piece_cell = (rowP, colP)

        cl.take_piece(cellA, cellB, piece_cell, pieceA, pieceB)
        plycount += 1
        return plycount

    # Do castling
    elif (move_data["castle"]["castle"]):
        if (move_data["castle"]["side"] == 'k'):
            cellC = ('H', cellA[1])
            cellD = ('F', cellB[1])
        else:
            cellC = ('A', cellA[1])
            cellD = ('D', cellB[1])

        pieceA = 'k'
        pieceB = 'r'
        cl.perform_castling_at(cellA, cellC, cellB, cellD, pieceA, pieceB)
        plycount += 1
        return plycount

    # Do en_passant
    elif (move_data["en_passant"]["en_passant"]):
        piece = move_data["en_passant"]["initial_pos_piece"]
        rowP, colP = piece[:1].upper(), int(piece[1:])
        piece_cell = (rowP, colP)

        cellTake = move_data["en_passant"]["square"]
        cl.en_passant(cellA, cellB, cellTake, piece_cell)
        plycount += 1
        return plycount

    # Do move_piece
    else:
        piece = move_data['piece']
        cl.move_piece(cellA, cellB, piece)
        plycount += 1
        return plycount