ej-shafran / compile-mode.nvim

A plugin for Neovim inspired by Emacs' Compilation Mode
The Unlicense
81 stars 15 forks source link

:NextError jumps between top and bottom buffer #14

Closed i-terzic closed 8 months ago

i-terzic commented 8 months ago

Describe the bug The respectable error causing code is opened in different buffers. Switching between top and bottom in my case.

To Reproduce Steps to reproduce the behavior:

  1. Run :Recompile or :Compile Note: There should be more than 2 compilation warnings/errors
  2. Run :NextError multiple times

Expected behavior The errors should be opened in the same window/buffer and not jump arround from top to bottom and so on. Also i would expect the compilation errors (the temporary buffer) to stay open for further error information.

Screenshots If applicable, add screenshots to help explain your problem.

Neovim Version Include the result of nvim -v:

v0.9.4

compile-mode.nvim Version Specify what version of compile-mode.nvim you are using.

latest

Additional context Add any other context about the problem here.

I use make and cc for compiling the code. Also i am running neovim inside WSL.

C code for testing:

#include <stdio.h>

int main(void)
{

    int i = 17;
    int *ip = &i;
    char *cp;
    char *cp1;
    void *vp1;
    void *vp2;

    printf("ip1: pointer: %p, value: %d\n", (void *) ip, *ip);

    return 0;
}
ej-shafran commented 8 months ago

Will give this a look and try to fix.

i-terzic commented 8 months ago

https://github.com/ej-shafran/compile-mode.nvim/assets/91913247/177348b7-d07d-4fba-85e9-2314ddee265e

I hope this video illustrates the issue fine. :)

ej-shafran commented 8 months ago

Just checking - are you using the same_window_errors config option? Maybe check it out and see if it's what you're looking for?

i-terzic commented 8 months ago

Sort of, is there an (automatic) option to use/open the respective buffer below the compilation output to keep the info of the compilations errors open? When running :Compile and :NextError e.g. while Netrw is open the info of the errors is lost. I guess it will be more of a convenience feature, than a bug. I would expect the temporary buffer to stay at the top and open, and :NextError to open the respecive buffer/location below.

i-terzic commented 8 months ago

I think retaning the focus on the buffer in which you run the command in combination with same_window_errors should fix the issue right there. Maybe adding that as a configuration option for that will improve the convenience (in my opinion). What do you think of that idea?

ej-shafran commented 8 months ago

I see... So what you're looking for would be like the behavior of

Such that the top window shows the compilation buffer, and the bottom window shows the location of the error?

i-terzic commented 8 months ago

Actually, i'm looking for the option that the compilation buffer will stay open when i run :NextError, so if there are multiple compilation errors, i don't loose sight of whats the issue there. Since the buffer is opened vertically on top, i would expect :NextError to open the repective malicious code in the window below and keep the compilation buffer open at the same time.

ej-shafran commented 8 months ago

Well, with same_window_errors, :NextError opens the error in the buffer which the cursor is currently on.

How about trying:

autocmd FileType compilation wincmd w

or

vim.api.nvim_create_autocmd("FileType", {
  pattern = "compilation",
  command = "wincmd w",
})

To not switch focus to the compilation buffer once its created? Try it and see if it fits what you're looking for?

i-terzic commented 8 months ago

Thats exactly what i was looking for. Thank you for the support!