Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s:open_quickfix also handles location list windows #168

Open
blueyed opened this issue Apr 8, 2016 · 2 comments
Open

s:open_quickfix also handles location list windows #168

blueyed opened this issue Apr 8, 2016 · 2 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Apr 8, 2016

There is only one quickfix window per tab, so a loop should not be necessary with

function! s:open_quickfix(request, copen) abort
let was_qf = &buftype ==# 'quickfix'
execute 'botright' (a:copen ? 'copen' : 'cwindow')
if &buftype ==# 'quickfix' && !was_qf && a:copen != 1
wincmd p
endif
for winnr in range(1, winnr('$'))
if getwinvar(winnr, '&buftype') ==# 'quickfix'
call setwinvar(winnr, 'quickfix_title', ':' . a:request.expanded)
let bufnr = winbufnr(winnr)
call setbufvar(bufnr, '&efm', a:request.format)
call setbufvar(bufnr, 'dispatch', escape(a:request.expanded, '%#'))
if has_key(a:request, 'program')
call setbufvar(bufnr, '&makeprg', a:request.program)
endif
if has_key(a:request, 'compiler')
call setbufvar(bufnr, 'current_compiler', a:request.compiler)
endif
endif
endfor
endfunction
.

On the other hand, there does not seem to be a way to find the quickfix window / distinguish it from the location list windows?!

The main issue here is that quickfix_title gets set for e.g. a Syntastic / Neomake location list then.

@blueyed
Copy link
Contributor Author

blueyed commented Apr 8, 2016

I've found something in vim-airline, which uses ls to get to that info (https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/quickfix.vim#L20-L36):

function! s:get_text()
  redir => buffers
  silent ls
  redir END

  let nr = bufnr('%')
  for buf in split(buffers, '\n')
    if match(buf, '\v^\s*'.nr) > -1
      if match(buf, '\cQuickfix') > -1
        return g:airline#extensions#quickfix#quickfix_text
      else
        return g:airline#extensions#quickfix#location_text
      endif
    endif
  endfor
  return ''
endfunction

@blueyed
Copy link
Contributor Author

blueyed commented Apr 9, 2016

Just for reference: the following patch would help by having a buffer variable for it: neovim/neovim#4550.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant