Giter Club home page Giter Club logo

goto-preview's People

Contributors

adoyle-h avatar afonsocarlos avatar benelan avatar cljoly avatar cseickel avatar hobord avatar jlesquembre avatar joshuarubin avatar jrwrigh avatar loqusion avatar mjb47 avatar rintse avatar rmagatti avatar saviocmc avatar tebro avatar tj-adams avatar vojtechj avatar willnorris avatar wookayin avatar xrayya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

goto-preview's Issues

Error opening floating window and mapping issues

Hi @rmagatti,

Just tested this out as I was curious about this functionality, looks quite cool. I ran into an issue which is that I get Error executing vim.schedule lua callback: ...site/pack/packer/start/goto-preview/lua/goto-preview.lua:78: Invalid window id: 1003 when trying to open the floating window i.e. using gpd the go to definition preview mapping.

Also the plugin has a dependency on vimp which isn't documented but tbh I think also not really needed since you could export the functions and use them in the mapping which the plugin creates

e.g.

function M.goto_preview_definition()
-- do stuff
end

vim.api.nvim_set_keymap("n", "gpd", "<Cmd>lua require('goto-preview').goto_preview_definition()<CR>")
-- OR if you need to do it based on some logic in setup then
_G.__goto_preview_definition = M.lsp_request(true)
vim.api.nvim_set_keymap("n", "gpd", "<Cmd>lua _G.__goto_preview_definition()<CR>")

Cursor position outside buffer

@rmagatti done a bit of debugging with quite a minimal init.lua and it seems the underlying error I'm seeing is Error executing vim.schedule lua callback: ...site/pack/packer/start/goto-preview/lua/goto-preview.lua:79: Cursor position outside buffer. Seems setting the cursor is what is failing but I'm not sure why

Originally posted by @akinsho in #1 (comment)

Idea - use nvim's "go to definition" command to support all file types

Hey! While creating #9 I have been thinking about how to avoid having to define a config for each file type. I am not an expert in lua/neovim plugins, so this may be totally wrong, but I still want to run it by the community to see if we can save ourselves some typing

When executing vim.lsp.buf.definition(), neovim automatically tried to go to the definition under the cursor, but that happens in the same window. To do it in a separate window, I can do: :vs | lua vim.lsp.buf.definition(). Here is an example after invoking that command when my cursor was on defineWidget (line 11) in the left window:
image

This is almost the functionality that this plugin has, but vs opens a new window to the side, instead of a floating window.

I have been thinking whether it would be possible to change the implementation of this plugin do to the following:

  1. Open a new floating window with the same buffer as the currently active window. Maintain the cursor position.
  2. Invoke lua vim.lsp.buf.definition() to go to the definition inside of that floating window

If I'm not mistaken, this would leverage existing neovim's configuration to go to the definition for any configured LSP. In the end, the plugin would not have to define a separate config for each filetype.

What do you think? Is that feasible?

Configuration: auto-focus and auto-hide of preview windows

Thanks for implementing a great plugin! This might be a question or feature request (if missing).

First, how can I prevent the cursor from automatically being moved to the preview window? I would want to "peek" the definition only, not disturbing the cursor on the main buffer. This should be a configurable option for all the methods, such as goto_preview_definition(opts).

Second, I would want to have the preview window automatically closed and dismissed when the cursor moves (assuming the cursor hasn't be taken to the preview window). This is similar to vim-quickui's persist = 0 option. How can I achieve that? Writing a custom post_open_hook function for adding autocmd events would be definitely possible, but is there any chance you'd want to implement this is a built-in option?

[BUG] preview window triggers twice in vue 3 router file

Describe the bug
I recently discover this weird behavior, works fine with CoC, but not with Volar

sometimes trigger gpd will show popup window showing the same definition twice

To Reproduce
Steps to reproduce the behavior:

In index.ts router file,

import moduleA from './moduleAfile';
import moduleB from './moduleBfile';

then move cursor to moduleA type gpd

Expected behavior
popup window only show once

Screenshots

Screen Shot 2022-08-22 at 10 01 17 AM

Baseline (please complete the following information):

  • OS. e.g uname -a: Darwin MacBook-Pro-2.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
  • Neovim version nvim --version
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

  system vimrc file: "$VIM/sysinit.vim"
 fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.7.2_1/share/nvim"

Run :checkhealth for more info
  • URL to your current config (if public)

my goto-preview.lua

require('goto-preview').setup {
    default_mappings = true;
}

Additional context
:checkhealth result


null-ls: require("null-ls.health").check()
========================================================================
  - INFO: no sources registered

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='iTerm.app'
  - INFO: $COLORTERM='truecolor'

nvim-lsp-installer: require("nvim-lsp-installer.health").check()
========================================================================
## nvim-lsp-installer report
  - OK: neovim version >= 0.7.0
  - OK: **Go**: `go version go1.19 darwin/arm64`
  - WARNING: **cargo**: not available
  - WARNING: **luarocks**: not available
  - OK: **Ruby**: `ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]`
  - OK: **RubyGem**: `3.0.3.1`
  - WARNING: **Composer**: not available
  - OK: **PHP**: `PHP 8.1.9 (cli) (built: Aug  4 2022 14:00:20) (NTS)`
  - OK: **npm**: `8.11.0`
  - OK: **node**: `v16.15.1`
  - OK: **python3**: `Python 3.10.6`
  - OK: **pip3**: `pip 22.2.2 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)`
  - WARNING: **javac**: not available
  - WARNING: **java**: not available
  - WARNING: **julia**: not available
  - OK: **wget**: `GNU Wget 1.21.3 built on darwin21.3.0.`
  - OK: **curl**: `curl 7.79.1 (x86_64-apple-darwin21.0) libcurl/7.79.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.45.1`
  - OK: **gzip**: `Apple gzip 353.100.22`
  - OK: **tar**: `bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 `
  - OK: **bash**: `GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)`
  - OK: **sh**: `Ok`
  - OK: GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Mon Aug 22 11:19:03 2022.

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found 0.20.6 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v16.15.1 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - json           ✓ ✓ ✓ ✓ .
  - python         ✓ ✓ ✓ ✓ ✓
  - css            ✓ . ✓ ✓ ✓
  - typescript     ✓ ✓ ✓ ✓ ✓
  - html           ✓ ✓ ✓ ✓ ✓
  - javascript     ✓ ✓ ✓ ✓ ✓
  - vue            ✓ . ✓ ✓ ✓
  - lua            ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3.9 in the environment.
  - INFO: Executable: /opt/homebrew/bin/python3.9
  - INFO: Python version: 3.9.13
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.
      - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

## Node.js provider (optional)
  - INFO: Node.js: v16.15.1
  - INFO: Nvim node.js host: /Users/xintan/.nvm/versions/node/v16.15.1/lib/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.10.1

## Perl provider (optional)
  - WARNING: "Neovim::Ext" cpan module is not installed
    - ADVICE:
      - See :help |provider-perl| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.4.0

## ===== Installed extensions =====

## Telescope Extension: `file_browser`
  - INFO: No healthcheck provided

## Telescope Extension: `notify`
  - INFO: No healthcheck provided

## Telescope Extension: `session-lens`
  - INFO: No healthcheck provided

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /Users/xintan/.cache/nvim/lsp.log
  - INFO: Log size: 1361 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for css: ABI version 13
  - OK: Loaded parser for html: ABI version 13
  - OK: Loaded parser for javascript: ABI version 13
  - OK: Loaded parser for json: ABI version 13
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for python: ABI version 13
  - OK: Loaded parser for typescript: ABI version 13
  - OK: Loaded parser for vue: ABI version 13

/lib.lua:225: attempt to index field 'lsp_configs' (a nil valu e)

Describe the bug

Error executing vim.schedule lua callback: ...te/pack/packer/opt/goto-preview/lua/goto-preview/lib.lua:225: attempt to index field 'lsp_configs' (a nil valu
e)
stack traceback:
        ...te/pack/packer/opt/goto-preview/lua/goto-preview/lib.lua:225: in function 'handle'
        ...te/pack/packer/opt/goto-preview/lua/goto-preview/lib.lua:259: in function 'handler'
        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1025: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

step to produce

git clone https://github.com/bryceyang/dotConfigs.git
git checkout navigator-again-new-theme
cd neovim-lua-refactor-version
source ./playground.sh  # this won't affect your config, just set a custom xdg env
nvp some_projects # nvp is an alias to nvim with custom xdg env from above source step
# use gpd (my custom hot-key for goto-preview) 

Expected behavior
preview window show up

Baseline (please complete the following information):

Additional context
I loaded nvim-lspconfigs plugin on vimEnter event.

Support for closing only current window

It would be great if we can have additional command/function/mapping to close only current window instead of all the windows together, since sometimes we want to go back and branch onto some other definitions.

It would be even better if that command can accept count, like close last 2 or last 3 windows.

Bug: Cannot focus via mouse click

Describe the bug

When clicking on the floating preview window, the focus (cursor) is expected to move to the window.

To Reproduce

  1. Open any goto-preview window (floating)
  2. Click left mouse on the window

Expected behavior

The cursor window moves to the preview window.

Current behavior

It remains on the current window from which goto-preview was triggered.

Baseline (please complete the following information):

  • OS. e.g uname -a: Linux, macOS (both)
  • Neovim version nvim --version: nvim 0.5.1. and 0.6.0 nightly
  • URL to your current config (if public)

[FEATURE] Close preview with standard keys

Is your feature request related to a problem? Please describe.
I use goto preview to "peek" definitions described in #44. In these cases my muscle memory is to close popovers with c-[ (or alternatively esc or c-c, etc).

Describe the solution you'd like
A config option that allows the popover to be closed using the usual vim keys for closing popovers or menus

Describe alternatives you've considered
Creating my own mappings - but figured this might be a useful feature to compliment #44

[BUG] Doesn't work with clojure-lsp attempt to index local 'data' nil

Describe the bug
When trying to use goto-preview with clojure lsp, I get the following error ...m/site/pack/packer/opt/goto-preview/lua/goto-preview.lua:15: attempt to index local 'data' (a nil value)

Expected behavior
no error, normal behavior

Baseline (please complete the following information):

  • OS. e.g MacOs
  • Neovim version nightly
  • URL to your current config (if public)

Ability to open current preview in split

Hey @rmagatti, awesome plugin, I love it. Thanks a lot for your time in developing it.

Sometimes I maybe previewing something and I want to "zoom in". It would be nice to do something like v and have the buffer registered in my tab line.

Additionally, as noted with the positioning bug, yes the popup go all over the place. However, it might be worth it to take vscode/preview popup approach and let them stack under each other.

Any ways thanks again

[FEATURE] if reference is in current file, just jump to it

Is your feature request related to a problem? Please describe.
I find myself avoiding gd when I know the definition is in the file I'm on, because I just want to jump there without opening a pop-up

Describe the solution you'd like
I'd like a config option to toggle that behavior

Describe alternatives you've considered
Maybe post_open hook?

Additional context
I would rather not disable the plugin because it's great for inspecting files in node_modules, for example

[FEATURE] Add a wiki for repo

Basically as an option to add some config examples/advanced configurations. For example, I have now setup goto-preview to behave similarly to telescope in regards to "expanding" preview windows into full windows. You can press <CR>, <C-v>, <C-x>, <C-t> to expand the preview into the current (main) window, vertical split, horizontal split, and a new tab, respectively.

local gtp = require('goto-preview')
local select_to_edit_map = {
  default    = "edit",
  horizontal = "new",
  vertical   = "vnew",
  tab        = "tabedit",
}

local function open_file(orig_window, filename, cursor_position, command)
  if orig_window ~= 0 and orig_window ~= nil then
    vim.api.nvim_set_current_win(orig_window)
  end
  pcall(vim.cmd, string.format('%s %s', command, filename))
  vim.api.nvim_win_set_cursor(0, cursor_position)
end

local function open_preview(preview_win, type)
  return function()
    local command         = select_to_edit_map[type]
    local orig_window     = vim.api.nvim_win_get_config(preview_win).win
    local cursor_position = vim.api.nvim_win_get_cursor(preview_win)
    local filename        = vim.api.nvim_buf_get_name(0)

    vim.api.nvim_win_close(preview_win, gtp.conf.force_close)
    open_file(orig_window, filename, cursor_position, command)

    local buffer = vim.api.nvim_get_current_buf()
    vim.api.nvim_buf_del_keymap(buffer, 'n', '<C-v>')
    vim.api.nvim_buf_del_keymap(buffer, 'n', '<CR>')
    vim.api.nvim_buf_del_keymap(buffer, 'n', '<C-x>')
    vim.api.nvim_buf_del_keymap(buffer, 'n', '<C-t>')
  end
end

local function post_open_hook(buf, win)
  vim.keymap.set('n', '<C-v>', open_preview(win, "vertical"),   { buffer = buf })
  vim.keymap.set('n', '<CR>',  open_preview(win, "default"),    { buffer = buf })
  vim.keymap.set('n', '<C-x>', open_preview(win, "horizontal"), { buffer = buf })
  vim.keymap.set('n', '<C-t>', open_preview(win, "tab"),        { buffer = buf })
end

require('goto-preview').setup {
  post_open_hook = post_open_hook,
}

I don't see any particular reason for this to be "officially" incorporated into the plugin, but I think it'd be nice to share with others as an option.

Different color theme in flat window

Hey, thank you for the fantastic plugin.

Somehow color theme in the float windows are different from my main theme (it is with black bg). I have quite a number of plugins that might influence the color (like shade that shades inactive windows, but I disabled it for trying this one).

Any ideas why this might be the case or any hints where to look?
Thanks!

Screenshot 2022-06-17 at 15 59 48

[BUG] Exception in get_config when LSP responds without any data (vetur)

Describe the bug
I get the following exception when triggering preview inside a <template> in Vue filetype when using the vetur LSP.

Error executing vim.schedule lua callback: ...site/pack/packer/start/goto-preview/lua/goto-preview.lua:18: attempt to index local 'range' (a nil value)
stack traceback:
        ...site/pack/packer/start/goto-preview/lua/goto-preview.lua:18: in function 'get_config'
        .../pack/packer/start/goto-preview/lua/goto-preview/lib.lua:220: in function 'handle'
        .../pack/packer/start/goto-preview/lua/goto-preview/lib.lua:254: in function 'handler'
        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:964: in function ''
        vim.lua: in function <vim.lua:0>

This works like expected inside a <script> section, so this is definitely an issue with the LSP itself.

The lib.logger.debug(vim.inspect(data)) statement gives {}, so it's no wonder why this fails.

So maybe add some additional checks here so that it doesn't fail with an exception?

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Vue file
  2. Write a basic template
  3. Set cursor above a component tag and trigger preview
  4. See error

Expected behavior
A popup, or nothing if no data available.

Baseline (please complete the following information):

bug?

Hello, thank you for the plugin. However, there is one thing that is weird to me. After i close the preview window with already existing before hidden buffer, the buffer is unloaded. As i understand noone reported this before, which is wierd, is it possible to fix this? Im on the latest neovim master.

Support for opening in current window

It would be great, if an additional command/function/mapping can be provided that opens the preview in active topmost window, so that we can choose if we want to open the next preview in same window or in a new one, since sometimes we encounter some symbols that we know we want to skip and go inside.

This would satisfy another usecase where we just want to go inside to find a specific symbol without opening a lot of buffers or a lot of floating windows(flow is kind of like vscode where we can open a file and jump to different locations and it will change the buffer in the same window, unless we double click, kind of like transient buffer)

Support for opening buffer in the active preview window in the background as a normal buffer

Sometimes we are navigating the code and while digging some definitions we find some important symbol that we need to understand more carefully(like it keeping it aside and thinking something like I'll come back to this).

It would be better if we can have support to open the buffer in active preview window to a normal buffer (without loosing the focus of floating preview)

Keep the last directory structure after close the preview window

Is your feature request related to a problem? Please describe.
First i am in the first directory structure and then use the goto-preview plugin to only show the preview buffer.
And the I close the preview buffer, unfortunatelly, the last directory structure has changed and every time I must open the directory again and again.

Describe the solution you'd like
keep the last directory structure after close the preview window?

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

close_all_win() is not working

It is just me, or does this function not do anything? I just installed this plugin a few days ago so I can't say if it used to work and just broke on a recent commit, but it definitely does not do anything right now. I am using this command to test it:

lua require('goto-preview').close_all_win()

[FEATURE] Allow not to automatically initialize telescope

Is your feature request related to a problem? Please describe.

Hello, my telescope is set to be lazily loaded based on keys and commands. But it seems that this plugin would automatically initialize telescope if it exists. That would add another extra 30ms for my config right now.

if has_telescope then
  init_telescope()
end

Describe the solution you'd like

Add an option for decoupling telescope would be awesome. If the user set the option, then skip checking if telescope exists.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

[BUG] Current buffer closes with preview if the preview and parent buffer are the same file

Describe the bug
If I preview the definition of something that is defined in the same file, and then close the preview, and then navigate to another buffer, the original buffer I was editing closes and no longer shows up in :ls

All key mappings are assuming the defaults.

To Reproduce
Steps to reproduce the behaviour:
In a file that both defines a new object and refers to that defined object:

  1. With the cursor over the referrer, preview the definition with gpd
  2. Close the preview with gP
    2a. Note at this stage that :ls still shows the parent buffer.
  3. Navigate away from the current buffer with :bn (or any other way you like)
  4. :ls no longer shows the buffer, :bp and <C-^> cant return to it, the latter displaying "E23: No alternate file`

Expected behavior
The buffer I was editing/previewing from would still exist and be navigable to with <C-^>.

Baseline (please complete the following information):

  • OS: macOS Monterey (M1)
  • Neovim version: 0.7.0

Make Telescope an optional dependency

I'm not particularly fond of Telescope as a whole, so it would be great if Telescope could be an optional dependency. I'm currently stuck using an older version of goto-preview because the more recent versions require Telescope.

`post_open_hook` not working for buffers opened in preview window

Current behavior
If we open another buffer in the current preview window (like LSP's goto-definition), then post_open_hook won't be called for the new buffer opened in the same preview window.

Expected behavior
If we open/jump to another buffer from within preview-window then post_open_hook should be called for the new buffer, Hence the code executed in the hook(like creating buffer local mappings) will be retained.

Highlight group?

What highlight group does goto-preview use? It seems different.

image

I don't want to use this italic font.

Remove vimp warning notice

Since a user no longer requires vimp to use this plugin the error message warning about needing it should also be removed 🙏🏾

[BUG] Fails if you haven't done regular go to definition first

Describe the bug

Error when you try to use any functions.

To Reproduce
Steps to reproduce the behavior:

  1. Call require('goto-preview').goto_preview_definition() on a buffer with an LSP enabled

Expected behavior
It opens the definition in a floating window

Screenshots
image

Baseline (please complete the following information):

Additional context
Add any other context about the problem here.

[Feature] Allow users to configure custom ways to choose which reference to open

I'd love to be able to integrate the find-references popup with plugins like https://github.com/folke/trouble.nvim
this would be pretty easy to implement if you either allowed users to provide some custom hook that decides how to select a location / provide some easy function that just opens "whatever" buffer@location in a popup.
Alternatively, a simple solution would be to make use of the vim-builtin quickfix / loclist menu, which tools like trouble can wrap

[BUG] attempt to index local 'data' (a nil value)

Describe the bug

lua require('goto-preview').goto_preview_definition() returns an error:

Error executing vim.schedule lua callback: ...ack/home-manager/start/goto-preview/lua/goto-preview.lua:14: attempt to index local 'data' (a nil value)

but lua vim.lsp.buf.definition() works properly.

Manually executing vim.lsp.buf_request, 0, "textDocument/implementation", vim.lsp.util.make_position_params() seems to return valid data, e.g.:

<function 1> 0 "textDocument/implementation" {
  position = {
    character = 34,
    line = 344
  },
  textDocument = {
    uri = "file:///.../views.cljs"
  }
}

The issue is happening with clojure-lsp, with typescript-lsp goto-preview seems to work ok, but I don't get the reason for that

Baseline (please complete the following information):

  • OS. e.g uname -a: Linux 5.10.76 #1-NixOS SMP Wed Oct 27 07:56:57 UTC 2021 x86_64 GNU/Linux
  • Neovim version nvim --version:
NVIM v0.5.1
Build type: Release
LuaJIT 2.1.0-beta3
Compilation:
Compiled by nixbld

Features: +acl +iconv +tui

Better documentation

Documentation doesn't mention what's the default mapping
Documentation doesn't mention how to set custom mapping

[Suggestion] Remove vim.inspect

There are too many vim.inspect for debug.

It is unnecessary that the handler always inspect the result.

local handler = function(lsp_call, opts)
return function(_, result, _, _)
if lsp_call ~= nil and lsp_call == "textDocument/references" then
logger.debug("raw result", vim.inspect(result))
handle_references(result)
else
handle(result, opts)
end
end
end

[FEATURE] Closing `n+1` preview should move the focus to the `n` preview

Describe the solution you'd like
If I open previews a,b, and c, closing c should put my focus on b; closing b — on a.

Describe alternatives you've considered
I have a function that I dovim.keymap.set with the local buffer inside the post_open_hook:

local function close_and_move_focus_on_prev()
  local prev_win = vim.fn.winnr()
  vim.cmd("wincmd p")
  return vim.cmd((prev_win .. "wincmd q"))
end

Additional context
On the gif below I do:

  1. Show that I commented my buffer keymap.
  2. Open project and demonstrate, that after closing second preview I didn't go to the first one;
  3. Reopen config and uncomment my close_and_move_focus_on_prev function;
  4. Open project again and demonstrate that the problem is fixed.

(my config is in fennel).

demo

[FEATURE] Explain vim-plug setup

Is your feature request related to a problem? Please describe.
Many users use vim-plug to manage their plugins and are used to simply putting down a Plug ... command.
Doing so for this plugin means that the setup function is not executed, resulting in unclear nil errors.

Describe the solution you'd like
Add info on different plugin managers to the readme, like for vim-plug;

Plug 'rmagatti/goto-preview'
:lua require('goto-preview').setup()

Doesn't work with ZenMode

I'm using this distraction-free plugin: https://github.com/folke/zen-mode.nvim

If I try to open goto-preview while ZenMode is activated - I don't see a popup window, but my cursor is constrained within some invisible border, in other words it seems the window exists, but it's completely transparent. If a type :bd my cursor gets back to normal.

[BUG] Does not play well with omnisharp-extended-lsp

This is probably not a bug, but probably not a feature request either.

Besides omnisharp-nvim and lsp, I am relying on https://github.com/Hoffs/omnisharp-extended-lsp.nvim in order to find definitions for external libraries. In short, this enables me to open a scratch buffer with a generated definition of the external source file.

However, it does not work out-of-the-box with goto-preview, as I get the error:

Error executing vim.schedule lua callback: .../pack/packer/start/goto-preview/lua/goto-preview/lib.lua:158: Cursor position outside buffer

I am not sure if this is fixable or not. Might be that this is not a general enough case, might also be that something needs to be done in omnishharp-extended-lsp.

Thanks in advance for any amount of time you choose to spend on this.

Getting `attempt to index field 'lsp_configs' (a nil value)`

Hi,

Just caught your (?) post on reddit, and this is something I have been looking for as an alternative to lsputils or lspsaga. All I want is the preview, so this is good stuff.

However, after setting up I get the following error:

Error executing vim.schedule lua callback: .../pack/packer/start/goto-preview/lua/goto-preview/lib.lua:120: attempt to index field 'lsp_configs' (a nil value)

I used the (minimal) setup instructions from the README. And I've double checked that it's 1:1.

Edit:

  • Tested with TypeScript- and Vue LSP
  • Commit 5b9c7f2
  • Neovim from source
NVIM v0.6.0-dev+253-ge31652879
Build type: Release
LuaJIT 2.1.0-beta3

Can't use goto-preview while it is installed, how to troubleshoot it ? [BUG]

Hello,

Thanks for the repo, it seems to be quite awesome.

I am trying to use it but I am having trouble to make it work.

I installed it using packer.nvim as required in the README.

It seems to be installed since the keymap gdp does different things whether default_mappings is set to true or false in the config file (paste when set to false, and nothing when set to true). When it is set to true, it does nothing and I don't have an error message. I tried to set my own keybinding, similarly nothing happens when I press the keybinding. I made sure it were mapped to nothing before setting it.

I tried with a simple .py file :

def foo(x):
    print(x)


foo("test")

pressing keybindings on the word foo.

I just wanted to know if you have any advice on how to troubleshoot this, since no error message is displayed.

  • Ubuntu 22-04
  • NVIM v0.9.0-dev-494+g407eef473

Thanks :))

[BUG] typescript-language-server goto_preview_references not working

Describe the bug
When editing a file with an active tsserver, the reference preview window does not appear when the function
lua require('goto-preview').goto_preview_references()
is invoked on a symbol containing references. References can be previewed successfully on other language servers such as bash and lua.

To Reproduce
Steps to reproduce the behavior:

  1. Install telescope and goto-preview on vim
  2. Open a typescript or javascript file and ensure tsserver is running
  3. Move cursor to a referenced symbol and invoke lua require('goto-preview').goto_preview_references() (either by a command or keybinding)
  4. No window appears

Expected behavior
A window containing references to the symbol under the cursor should be displayed upon invoking
lua require('goto-preview').goto_preview_references()

Screenshots
If nessecary I can provide screenshots, but I think my report adequately describes the issue.

Baseline (please complete the following information):

  • OS. Debian Bullseye (11)
  • Neovim version 0.6.0
  • Current config not public

Additional context
-Telescope can find tsserver references itself with no issue

  • goto-preview preoperly displays references in other languages (tested bash and lua).
  • A blank preview window will appear on non referenced symbols (ie close brackets), while no window appear on referenced symbols (ie a function parameter).
  • Using lunarvim IDE layer: https://github.com/LunarVim/LunarVim

Show filepath as the preview title?

Really nice addon! It's helping me on my transition away from VSCode.

I wonder, did you consider showing the path to the file in the preview window "title" area?

Thanks again! 🙏

Ability to modify file in floating window, without the need to full open it

Is your feature request related to a problem? Please describe.
Ability to modify a file in a floating window, without the need to fully open it

Describe the solution you'd like
I would like to do some small changes to the floating window (ex. add a property to a class), save, then close (ideally just with the escape key), without fully opening it to split.

Inspiration: Visual Studio (the IDE not the text editor)

[BUG] Does not play well with stevearc/aerial.vnim

Describe the bug
when triggering the default mapping "gpd", instead of previewing the definition,
nvim is throwing an error regarding another plugin, namely stevearc/aerial.nvim

To Reproduce
Steps to reproduce the behavior:

  1. Install aerial.nvim alongside or clone my config after safeguarding yours
  2. I don't tweak those a lot, so default settings should suffice
  3. try to "gpd" on some usage of something ... (eg.: with cursor on the import of a React Component, in normal mode, press "gpd")
  4. observe neovim throwing the above error ...

Expected behavior
I would like to see the actual preview of the definition of the import/thingy

Screenshots
EF9CE19A-ACF5-4312-B00B-5C9CCD0C4403

Baseline (please complete the following information):

Additional context
Justy a quick note: I dblchecked on the default mappings of aerial, and "gpd" doesn't seem to be one of them

Add TS-related file types

Hey 👋 First of all, the plugin is great! I've been looking for a similar functionality for some time already

I am mostly working with TS/JS files, and while it works great in TS files, I have noticed that in other files types that are handled by tsserver:

  • javascript
  • typescriptreact
  • javascriptreact

I get an error since

target, cursor_position = M.conf.lsp_configs[vim.bo.filetype].get_config(data)
is trying to access get_config from nil.

I have 2 suggestions here:

  1. We could add those filetypes that I mentioned above that are handled by tsserver. The implementation of get_config should be the same as for the typescript file type. Of course, I could do that myself in my vim config, but IMO it would be beneficial for everyone.
  2. We could add a nicer error message in case the user is trying to get a preview in a buffer whose filetype is not configured. This would be more user friendly than Error executing vim.schedule lua callback: ...z/.config/nvim/plugged/goto-preview/lua/goto-preview.lua:101: attempt to index a nil value

Again, thanks for a great plugin 👍

Support for references preview

Firstly... love this plugin. I realize support for references would perhaps entail some extra UI for cycling through the different references with something like a preview window for the locations but I think this would be a shoe-in for this awesome plugin given what it can do already.

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.