Comments (10)
Ah I see what you mean. That depends if your preview ends up opening the same buffer or not, if it doesn't you wouldn't have the issue you're seeing. Since the mapping is unaware of anything goto-preview related when it is already in place, since it is the same buffer you'll end up having the mapping still unfortunately.
from goto-preview.
Thanks for opening the neovim issue, it would definitely be nice to have a way to limit the scope of mappings to just one window, especially now that we have more floating windows.
from goto-preview.
@sahilsehwag hey, you can already do that by just normally closing :q
the window if you have it focused.
But the idea is interesting for when you don't have the preview float focused anymore, I'll give it some thought.
Thanks for the submission!
from goto-preview.
@rmagatti could it be possible to close the preview window by just hitting 'q', as in other plugins (e.g., lspsaga)?
from goto-preview.
@serhez well, yes. But that's not something I would want to add as a default or anything like that. I like the fact that these preview windows are just normal windows that you can do anything with, rebinding q
would mean not being able to record a macro in them anymore, which might be what you want ofc but not something I'd want to make the plugin decide for you.
That said in response to this I created this PR #15 which should enable you to set whatever mappings you'd like on a float preview window. Hope that does it for you.
from goto-preview.
@rmagatti #15 looks good, thanks! Agreed that it is a nice option but may not necessarily be a default. Cheers!
from goto-preview.
@serhez this is an example config for doing what you want, i.e closing the preview window with q
.
require('goto-preview').setup {
post_open_hook = function()
vim.cmd[[nnoremap <buffer> q :q<CR>]]
end
}
from goto-preview.
In case this helps anyone else: I wanted the close mapping to only apply to the preview window; the example above will mean that q will continue to be mapped to close the window/vim in that buffer, which I didn't want. I can't see any nice way to limit the mapping to just the goto preview window, so I'm using this hack where the mapping disables itself after closing the window:
require('goto-preview').setup {
post_open_hook = function()
vim.cmd [[nnoremap <buffer> gq <c-w>c :unmap <buffer> gq<CR>]]
end
}
from goto-preview.
Actually @benallan with how the hooks are being triggered now, I do check if the window is a preview window and only then call the hook function, that hook function, because it's causing nnoremap <buffer> q :q<CR>
the <buffer>
means it's buffer local, so it'll only apply to the preview window's buffer, so my example should work exactly the way you would expect.
from goto-preview.
it's buffer local, so it'll only apply to the preview window's buffer, so my example should work exactly the way you would expect.
I'm probably misunderstanding something, but when I use goto preview on a function which is defined in the same file, the preview window appears so I now have two windows, but it's the same buffer displayed in both windows. So the buffer local mapping will persist after the preview window is closed, and it definitely seems to when I test it. Is that not the case for you?
Or when the preview window is opened, is it supposed to use a different buffer to the one that was already open?
from goto-preview.
Related Issues (20)
- Change border color HOT 1
- How to close only one preview and how to open focused preview in current split but new buffer?
- Setting on `post_open_hook` will be shared if I split window? HOT 1
- [BUG] attempt to index field 'lsp_configs' (a nil value) HOT 9
- [FEATURE]: 'Enter' key in a preview window to close all preview windows and go to the definition,refs, etc HOT 6
- Filename in float window
- Getting "Invalid key" error when go to definition HOT 6
- [FEATURE]: Toggle single preview window and show definition automatically when cursor moving in source window. HOT 5
- Esc to close the floating window (similar functionality as telescope.nvim) HOT 1
- [FEATURE] add `post_close_hook` option which executes after `close_all_win()` HOT 2
- [BUG] Do not work with lazy? HOT 2
- [FEATURE] Better floating window focusing method HOT 1
- [BUG] Preview window won't show if "dismiss_on_move = true" and "focus_on_open = true" HOT 1
- [FEATURE] Close floating window when cursor leaves buffer HOT 3
- [Feature] Only show the first implementation HOT 3
- Provide an option for making preview window unchangeable. HOT 7
- [BUG] incorrect floating window closed in case multiple floating previews are opened HOT 5
- [FEATURE] Configurable starting zindex HOT 3
- [FEATURE] Close Currently focussed preview window with q HOT 2
- [FEATURE] Trigger goto-preview from any Telescope.nvim picker
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goto-preview.