Python vim.windows() Examples
The following are 8
code examples of vim.windows().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
vim
, or try the search function
.
Example #1
Source File: roast.py From roast.vim with MIT License | 6 votes |
def highlight_line(group, buf_number, line_number): match_id = int(vim.buffers[buf_number].vars.get('_roast_match_id', 0)) if match_id: win = None for win in vim.windows: if win.buffer.number == buf_number: break try: vim.eval(f'matchdelete({match_id})' if win is None else f'matchdelete({match_id}, {win.number})') except vim.error: # TODO: Only hide E803 error, which is thrown if this match_id has already been deleted. pass vim.buffers[buf_number].vars['_roast_match_id'] = vim.eval( fr"matchadd('{group}', '\V' . escape(getbufline({buf_number}, {line_number + 1})[0], '\') . '\$')" )
Example #2
Source File: neovim_rpc_protocol.py From vim-hug-neovim-rpc with MIT License | 5 votes |
def from_client(msg): def handler(obj): if type(obj) is msgpack.ExtType: if obj.code == BUFFER_TYPE_ID: return vim.buffers[msgpack.unpackb(obj.data)] if obj.code == WINDOW_TYPE_ID: return vim.windows[msgpack.unpackb(obj.data) - 1] if sys.version_info.major != 2: # python3 needs decode obj = decode_if_bytes(obj) return obj return walk(handler, msg)
Example #3
Source File: neovim_rpc_protocol.py From vim-hug-neovim-rpc with MIT License | 5 votes |
def from_client(msg): def handler(obj): if type(obj) is msgpack.ExtType: if obj.code == BUFFER_TYPE_ID: return vim.buffers[msgpack.unpackb(obj.data)] if obj.code == WINDOW_TYPE_ID: return vim.windows[msgpack.unpackb(obj.data) - 1] elif obj is None: return '' if sys.version_info.major != 2: # python3 needs decode obj = decode_if_bytes(obj) return obj return walk(handler, msg)
Example #4
Source File: vim_ipython.py From sos with BSD 3-Clause "New" or "Revised" License | 5 votes |
def vim_ipython_is_open(): """ Helper function to let us know if the vim-ipython shell is currently visible """ for w in vim.windows: if w.buffer.name is not None and w.buffer.name.endswith("vim-ipython"): return True return False
Example #5
Source File: minimap.py From vim-minimap with MIT License | 5 votes |
def getmmwindow(): for b in vim.buffers: if b.name.endswith(MINIMAP): for w in vim.windows: if w.buffer == b: return w return None
Example #6
Source File: minimap.py From vim-minimap with MIT License | 5 votes |
def getmainwindow(): for b in vim.buffers: if not b.name.endswith(MINIMAP) and not "NERD_tree" in b.name: for w in vim.windows: if w.buffer == b: return w return None
Example #7
Source File: minimap.py From vim-minimap with MIT License | 5 votes |
def closeminimap(): minimap = getmmwindow() src = vim.current.window if minimap: vim.current.window = minimap # clear the minimap autocmds setmmautocmd(True) vim.command(":quit!") # try the last window, but sometimes this one was already closed # (ex. tagbar toggle) which will lead to an exception try: vim.current.window = src except: vim.current.window = vim.windows[0]
Example #8
Source File: roast.py From roast.vim with MIT License | 4 votes |
def show_response(response: requests.Response): # A window holding a roast buffer, to be used as a workspace for setting up all roast buffers. workspace_window = workspace_renderer = None for window in vim.windows: if '_roast_renderer' in window.buffer.vars: workspace_window = window workspace_renderer = window.buffer.vars['_roast_renderer'] if not isinstance(workspace_renderer, str): workspace_renderer = workspace_renderer.decode() break # Switch to workspace window. prev_window = vim.current.window for renderer in renderers: buf_name = f'__roast_{renderer}__' num = bufnr(buf_name) if num < 0: if workspace_window is not None: vim.current.window = workspace_window vim.command(f'keepalt edit {buf_name} | setl bt=nofile bh=hide noswf nornu') num = bufnr(buf_name) else: vim.command(f'keepalt vnew {buf_name} | setl bt=nofile bh=hide noswf nornu') num = bufnr(buf_name) vim.current.window = workspace_window = vim.windows[int(vim.eval(f'bufwinnr({num})')) - 1] else: if workspace_window is not None: vim.current.window = workspace_window vim.command(f'keepalt {num}buffer') else: vim.command(f'keepalt vertical {num}sbuffer') vim.current.window = workspace_window = vim.windows[int(vim.eval(f'bufwinnr({num})')) - 1] buf = vim.buffers[num] buf[:] = None buf.vars['_roast_renderer'] = renderer actions = getattr(roast_api, f'render_{renderer}')(buf, response) apply_actions(buf, actions) workspace_window.options['statusline'] = "Roast <%{get(b:, '_roast_renderer', 'N/A')}> " + \ ('' if response.ok else '%#Error#') + " HTTP:" + str(response.status_code) + " %* %{&ft}" vim.command(f'{workspace_window.number}windo keepalt buffer __roast_{workspace_renderer or renderers[0]}__') vim.current.window = prev_window