Comments (7)
Hi!
I'm not an expert too, but I recommend to take a look at the lspsaga source, I think they solved this issue.
from goto-preview.
@Gelio the flow you are suggesting is something along the lines of
- Open window -> execute jump to definition -> open window -> execute jump to definition
Whereas I'm suggesting - Get definition data -> open window to correct location -> get definition data -> open window to correct.
Btw I'm not suggesting that that wouldn't work but rather that depending directly on this functionality is less flexible i.e. rather than having this work exactly the way this plugin needs it depends on the specific behaviour of that api meanwhile the only thing that is actually needed from that function is how it converts the lsp location data into a vim address for all filetypes.
Say the plugin wanted to be able to do something with the locations it had opened so far can't think of what but it wouldn't have any internal knowledge of what the path was without maybe having to dig around the jump list or something.
It would also require a refactor towards this less flexible method rather than copy pasting what I'm guessing are a few lines into the location handling 🤷🏾 any just my 2 cents will leave this for the author 👍🏾
from goto-preview.
Hey all, cool discussion here!
Apparently, there aren't as many variations as I initially thought?
I'm changing this to do something like @hobord's suggestion with what lspsaga does. Thanks for pointing me to that chunk of code!
from goto-preview.
I think @hobord's makes a good suggestion. I think you should be able to generalise, the functionality to all filetypes since nvim is able to jump to definition for all lsp filetypes. I think as the lspsaga example shows it's probably a matter of checking a few different formats. I think you could probably re-use the logic inside vim.lsp.buf.goto_definition
rather than depending on it directly.
from goto-preview.
Thanks for providing additional suggestions. I'm wondering what's the benefit of using some additional logic rather than using a built-in nvim API for going to the definition. I would say calling a single function should be easier but looks like I may be wrong. Do you know?
from goto-preview.
@Gelio the lsp handlers are quite specific about how they work and their internal workings can't be easily overriden i.e. go to definition not using the current window but a float instead.
This is why lspsaga as an example re-implements a lot of the handlers or uses some of the other lower level utils rather than tries to re-use the methods directly.
I think rather than trying to work around this behaviour which frankly could change (granted that's unlikely as the API stabilises) it's better to just use the functionality/utils the lsp exposes to produce the exact desired outcome. This is all up to @rmagatti anyway though so 🤷🏾 , just my opinion
from goto-preview.
@akinsho Thanks for answering. I still don't understand one thing, though:
the lsp handlers are quite specific about how they work and their internal workings can't be easily overriden i.e. go to definition not using the current window but a float instead.
In the steps I have listed in the issue description, using the current window is exactly the behavior we want, is it not? So, it would appear to me that if only the plugin opened a floating window with exactly the same buffer as the main window and then invoked vim.lsp.buf.definition()
, that floating window would now show the definition, exactly as it does right now, but without having to configure each filetype.
I don't see the need to use lower-level utils here. What am I missing?
from goto-preview.
Related Issues (20)
- 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
- [FEATURE] HOT 5
- 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
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.