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)
exe s:results_window . ' wincmd w'
exe 'view /tmp/queries/' . a:query_hash
let s:results_window = winnr()
nnoremap <buffer> q :q<CR>