Python vim.buffers() Examples
The following are 14
code examples of vim.buffers().
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: repeater.py From pappy-proxy with MIT License | 6 votes |
def update_buffers(req): b1_id = int(vim.eval("s:b1")) b1 = vim.buffers[b1_id] b2_id = int(vim.eval("s:b2")) b2 = vim.buffers[b2_id] # Set up the buffers set_buffer_content(b1, req.full_message()) if req.response is not None: set_buffer_content(b2, req.response.full_message()) # Save the port, ssl, host setting vim.command("let s:dest_port=%d" % req.dest_port) vim.command("let s:dest_host='%s'" % escape(req.dest_host)) if req.use_tls: vim.command("let s:use_tls=1") else: vim.command("let s:use_tls=0")
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] if sys.version_info.major != 2: # python3 needs decode obj = decode_if_bytes(obj) return obj return walk(handler, msg)
Example #4
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 #5
Source File: neovim_rpc_methods.py From vim-hug-neovim-rpc with MIT License | 5 votes |
def nvim_list_bufs(): return list(vim.buffers)
Example #6
Source File: repeater.py From pappy-proxy with MIT License | 5 votes |
def submit_current_buffer(): curbuf = vim.current.buffer b2_id = int(vim.eval("s:b2")) b2 = vim.buffers[b2_id] vim.command("let s:b1=bufnr('$')") vim.command("only") vim.command("rightbelow vertical new") vim.command("b %d" % b2_id) vim.command("wincmd h") full_request = '\n'.join(curbuf) req = parse_request(full_request) dest_host, dest_port, use_tls, storage_id = dest_loc() req.dest_host = dest_host req.dest_port = dest_port req.use_tls = use_tls comm_type, comm_addr = get_conn_addr() with ProxyConnection(kind=comm_type, addr=comm_addr) as conn: new_req = conn.submit(req, storage=storage_id) conn.add_tag(new_req.db_id, "repeater", storage_id) update_buffers(new_req) # (left, right) = set_up_windows() # set_buffer_content(left, 'Hello\nWorld') # set_buffer_content(right, 'Hello\nOther\nWorld') #print "Arg is %s" % vim.eval("a:arg")
Example #7
Source File: test_vim_helpers.py From vim-hdl with GNU General Public License v3.0 | 5 votes |
def test(): it.assertEquals( vim_helpers._getBufferVars(vim.buffers[0]), {'buffer_0_var_0' : 'buffer_0_var_value_0', 'buffer_0_var_1' : 'buffer_0_var_value_1',} ) it.assertEquals( vim_helpers._getBufferVars(vim.buffers[1]), {'buffer_1_var_0' : 'buffer_1_var_value_0', 'buffer_1_var_1' : 'buffer_1_var_value_1',} )
Example #8
Source File: test_vim_helpers.py From vim-hdl with GNU General Public License v3.0 | 5 votes |
def test(): it.assertEquals( vim_helpers._getBufferVars(vim.buffers[0], 'buffer_0_var_0'), 'buffer_0_var_value_0',)
Example #9
Source File: vimsupport.py From DyeVim with MIT License | 5 votes |
def GetFileType( bufnr ): ft = vim.buffers[ bufnr ].options[ 'filetype' ] return _ToUnicode( ft )
Example #10
Source File: vimsupport.py From DyeVim with MIT License | 5 votes |
def GetBufferLen( bufnr ): return len( vim.buffers[ bufnr ] )
Example #11
Source File: vimsupport.py From DyeVim with MIT License | 5 votes |
def GetLineLen( bufnr, line ): # line index is 1 based, but vim python interface is 0 based return len( vim.buffers[ bufnr ][ line - 1 ] )
Example #12
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 #13
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 #14
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