Giter Club home page Giter Club logo

Comments (8)

rmagatti avatar rmagatti commented on June 16, 2024

Hey, thanks for the submission.

I'm a little unsure of what you mean though. Could you maybe elaborate?

from goto-preview.

0xRZ avatar 0xRZ commented on June 16, 2024

@rmagatti Okay. Here is a gif of what i mean:
Peek 2021-11-28 10-40

You see after i close goto-preview window with a definition of the TEST macro, previously loaded buffer common.h is unloaded.

Files i use to reproduce:

init.vim with clangd language server, vim-plug and lsp-config plugin

call plug#begin() 
     Plug 'neovim/nvim-lspconfig'
     Plug 'rmagatti/goto-preview'
call plug#end()

lua << EOF
      require'lspconfig'.clangd.setup{}
      require('goto-preview').setup{}
EOF

nnoremap gf <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap gpd <cmd>lua require('goto-preview').goto_preview_definition()<CR>
nnoremap gP <cmd>lua require('goto-preview').close_all_win()<CR>

common.h

#define TEST 1

test.c

#include "common.h"

int main (int argc, char *argv[])
{
        int a = 1 + TEST;
        return 0;
}

neovim commit i pulled yesterday: b51b0aecc969040641da29dbd7cf28e419972f15

from goto-preview.

rmagatti avatar rmagatti commented on June 16, 2024

Assuming you're closing the preview window through the goto-preview mapping. This is what the documentation about the function I use to close it says.

-- Closes the window (like |:close| with a |window-ID|).
--- @param window window #Window handle, or 0 for current window
--- @param force boolean #Behave like `:close!` The last window of a
---               buffer with unwritten changes can be closed. The
---               buffer will become hidden, even if 'hidden' is
---               not set.
function vim.api.nvim_win_close(window, force) end

And this is how I'm calling it.
vim.api.nvim_win_close(win_handle, true)

I'm adding an option to not force close in a PR as I think this is likely the cause of what you're seeing, i.e I think your buffer is becoming hidden.

from goto-preview.

rmagatti avatar rmagatti commented on June 16, 2024

@0xRZ would you mind testing out the changes by installing with the branch of the PR linked here and setting force_close = false in the setup?

from goto-preview.

0xRZ avatar 0xRZ commented on June 16, 2024

@rmagatti i pulled add-force-close-option, tried to set force_close = false but it doesn't fix anything for me, <cmd>lua require('goto-preview').close_all_win()<CR> still unloads buffer after preview window is closed 🤷‍♂️
Im not really sure what this force parameter of nvim_win_close do, but i found out that https://github.com/rmagatti/goto-preview/blob/main/lua/goto-preview/lib.lua#L130 bufhidden option can be changed from wipe to hide, that way existing buffer won't be unloaded, imo it seems to be the correct behaviour.

from goto-preview.

rmagatti avatar rmagatti commented on June 16, 2024

Oh interesting. Good find. I'll add an option for that to too.

from goto-preview.

rmagatti avatar rmagatti commented on June 16, 2024

@0xRZ added the option to change bufhidden too. Lmk if that works for you.

from goto-preview.

0xRZ avatar 0xRZ commented on June 16, 2024

@rmagatti yeah, just pulled add-force-close-option, when specifying bufhidden = "hide", buffers are not lost. thx

from goto-preview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.