Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: apply jump_type only if the definition file is different from the current file #2324

Merged
merged 3 commits into from
Feb 19, 2023

Conversation

luyuhuang
Copy link
Contributor

Description

Apply jump_type rule only if the definition file is different from the current file. I think most people expect open the definition on a new tab (or a split pane) only when we need to go to another file.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Set a key mapping vim.keymap.set('n', 'gd', function() builtin.lsp_definitions{jump_type = 'tab'} end, bufopts):

  • Move the cursor on a symbol that has only one definition and type gd. If the definition is in the current file, it'll just jump to the corresponding position of the current file; otherwise it'll open the definition on a new tab.

Set a key mapping vim.keymap.set('n', 'gr', function() builtin.lsp_references{jump_type = 'tab'} end, bufopts):

  • Move the cursor on a symbol that has only one reference and type gr. If the reference is in the current file, it'll just jump to the corresponding position of the current file; otherwise it'll open the reference on a new tab.

Configuration:

  • Neovim version (nvim --version): NVIM v0.8.2
  • Operating system and version: Ubuntu 20.04 LTS (WSL2)

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@Conni2461
Copy link
Member

thanks :)

@ahouseago
Copy link

Hi @luyuhuang. I'd like to add a config value to control this because I don't want to reuse the same window when I've specified a jump type.

I wanted to check before I did that: if I were to revert the change from this PR, would using the reuse_win option work for you? Or do you want it so it only ignores the jump_type when the definition exists in the same file?

@luyuhuang
Copy link
Contributor Author

Hi @luyuhuang. I'd like to add a config value to control this because I don't want to reuse the same window when I've specified a jump type.

I wanted to check before I did that: if I were to revert the change from this PR, would using the reuse_win option work for you? Or do you want it so it only ignores the jump_type when the definition exists in the same file?

Yes it's OK for me.

@leoperegrino
Copy link

@ahouseago @luyuhuang so, should this be reverted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants