I'm trying to develop a plugin that would show results of SQL queries, by executing them inside tmux split and using mysql pager option to save them to the specific file.
What I want now is to either create the new window to show results (if no such window have been created before) or reuse created one. But I don't know how to identify windows and how to switch to the specific window.
For example, let's say I always want to display results in a horizontal split. How do I know that such split doesn't exist already? Try
wincmd j and check if
winnr haven't changed? What if user would move this window to another location? How do a find it?
fu! s:ShowResults(query_hash, jobid, data, event) unlet s:jobid if exists('s:results_window') exe s:results_window . ' wincmd w' else split wincmd j endif exe 'view /tmp/queries/' . a:query_hash let s:results_window = winnr() setlocal nowrap nnoremap <buffer> q :q<CR> endfu