lsp_client.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:vim-clangd 作者: Chilledheart 项目源码 文件源码
def StartProcess(executable_name, clangd_log_path=None):
    if not clangd_log_path or not log.logger.isEnabledFor(log.DEBUG):
        clangd_log_path = os.devnull
    fdClangd = open(clangd_log_path, 'w+')

    # fix executable file name under windows (both cygwin and native win32)
    if sys_platform == 'msys' or sys_platform == 'win32':
        if not executable_name.endswith('.exe'):
            executable_name += '.exe'

    # apply platform-specific hacks
    if sys_platform != 'win32':
        # for posix or cygwin
        fdInRead, fdInWrite = Pipe()
        fdOutRead, fdOutWrite = Pipe()
        SetCloseOnExec(fdInWrite)
        SetCloseOnExec(fdOutRead)
    else:
        # only native win32
        fdInRead, fdInWrite = Win32SocketPair()
        fdOutRead, fdOutWrite = Win32SocketPair()
    cwd = os.path.dirname(executable_name)
    # apply native win32's hack
    if sys_platform == 'win32':
        # we need hide this subprocess's window under windows, or it opens a new visible window
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
        startupinfo.wShowWindow = subprocess.SW_HIDE
        clangd = Popen(
            executable_name,
            stdin=fdInRead,
            stdout=fdOutWrite,
            stderr=fdClangd,
            cwd=cwd,
            creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
            startupinfo=startupinfo)
    else:
        clangd = Popen(
            executable_name,
            stdin=fdInRead,
            stdout=fdOutWrite,
            stderr=fdClangd,
            cwd=cwd)

    return clangd, fdInWrite, fdOutRead, fdClangd
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号