ej-shafran / compile-mode.nvim

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

Feature Request. #8

Closed X3eRo0 closed 9 months ago

X3eRo0 commented 9 months ago

I am using this plugin for quite a while and I am working on a few improvements, one of which is a feature where when the user uses the command on the compilation buffer it jumps to the file in the already opened buffer instead of jumping the compilation buffer. In my case when I am editing a file and I run the compile command and jump to error I end up with 2 buffers with same contents which feels weird. Before using your plugin I was using compile.nvim and this plugin does a wincmd p to go out of the compilation buffer and open the error there.

I was wondering how should I go about adding this feature to compile-mode.nvim. Specifically my question is, which way would be better? to have a config that user can configure to open the error outside of compilation buffer. something like this?

require('compile-mode').setup({
    errors_in_compilation = false,
})

or to have a seperate keybind or seperate command? Waiting for your thoughts on this. BTW I have implemented the config way of doing this.

ej-shafran commented 9 months ago

This feels like a natural thing for people to want. I wouldn't be against having it as the default, and adding a configuration option to disable this behavior. Feel free to open a pull request, and I'll give your code a look :smile_cat:

X3eRo0 commented 9 months ago

So, if we add vim.cmd([[wincmd p]]) before doing vim.cmd.e(filename) in the compile-mode/utils.lua file we can achieve the said functionality. but the problem is how do we bring the config.jump_error_in_buffer to this function because the config variable is not exposed to other files? I tried adding this as an argument to the jump_to_error function and goto_file function.

ej-shafran commented 9 months ago

Take a look at what I've done in #9 and see if it's what you're looking for.

X3eRo0 commented 9 months ago

Hey, this is good we can merge and close the issue