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(cpp): Add <Leader>lw keymap to switch between source and header #900

Merged
merged 4 commits into from
Apr 25, 2024

Conversation

rameshsanth
Copy link
Contributor

@rameshsanth rameshsanth commented Apr 20, 2024

lw to sWitch between source and header.

"w" isn't assigned to any other key currently.

📑 Description

ℹ Additional Information

Caveat: The keybinding will stay for all LSP although only Clangd supports it. Ideally the keybinding should appear only for buffers Clangd is attached.

Copy link

github-actions bot commented Apr 20, 2024

Review Checklist

Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:

Proper conventional commit scoping:

  • If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin

  • If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error

  • Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above

  • README is properly formatted and uses fenced in links with <url> unless they are inside a [title](url)

  • Proper usage of opts table rather than setting things up with the config function.

@rameshsanth rameshsanth changed the title lsp: clangd: Add <Leader>lw keymap to switch between source and header fix(clangd_extensions): Add <Leader>lw keymap to switch between source and header Apr 20, 2024
Uzaaft
Uzaaft previously requested changes Apr 20, 2024
Copy link
Member

@Uzaaft Uzaaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See feedback

lua/astrocommunity/pack/cpp/init.lua Outdated Show resolved Hide resolved
@rameshsanth rameshsanth requested a review from Uzaaft April 20, 2024 04:26
@rameshsanth
Copy link
Contributor Author

Caveat: The keybinding will stay for all LSP although only Clangd supports it. Ideally the keybinding should appear only for buffers Clangd is attached.
If you know the trick to fix make the key map only to C/C++ files, let me know. Otherwise its a minor hassle

@Uzaaft
Copy link
Member

Uzaaft commented Apr 20, 2024

Caveat: The keybinding will stay for all LSP although only Clangd supports it. Ideally the keybinding should appear only for buffers Clangd is attached. If you know the trick to fix make the key map only to C/C++ files, let me know. Otherwise its a minor hassle

We'll have to fix this.

@Uzaaft
Copy link
Member

Uzaaft commented Apr 20, 2024

@rameshsanth I'm pretty sure we have the logic for it somewhere in astrocommunity. :)

@Uzaaft Uzaaft marked this pull request as draft April 20, 2024 07:07
@Uzaaft
Copy link
Member

Uzaaft commented Apr 20, 2024

Marking this as a draft until we fix it.

@rameshsanth
Copy link
Contributor Author

Marking this as a draft until we fix it.

IMHO, this is not a major issue. There are several key maps that don't apply for every buffer. However it's still loaded and available in vim.
When you get use this short cut on a non CPP file you see this notification.
Screenshot 2024-04-20 at 12 31 37 AM

@Uzaaft
Copy link
Member

Uzaaft commented Apr 21, 2024

We should add an autocmd for cleaning up.
For semantic token, we've used this before:

vim.api.nvim_create_autocmd("lspattach", {
  callback = function(args)
    local client = vim.lsp.get_client_by_id(args.data.client_id)
    client.server_capabilities.semantictokensprovider = nil
  end

Should use same logic, just with the astrocore functionality instead.

lua/astrocommunity/pack/cpp/init.lua Outdated Show resolved Hide resolved
lua/astrocommunity/pack/cpp/init.lua Show resolved Hide resolved
@mehalter mehalter changed the title fix(clangd_extensions): Add <Leader>lw keymap to switch between source and header feat(cpp): Add <Leader>lw keymap to switch between source and header Apr 22, 2024
@Uzaaft
Copy link
Member

Uzaaft commented Apr 24, 2024

@rameshsanth Can you test to see if this works as expected now? :)

@Uzaaft Uzaaft marked this pull request as ready for review April 24, 2024 08:04
@mehalter mehalter dismissed Uzaaft’s stale review April 24, 2024 13:36

Issues resolved, now just waiting to hear back from user

@mehalter mehalter merged commit 9371f0c into AstroNvim:main Apr 25, 2024
12 checks passed
@rameshsanth
Copy link
Contributor Author

Sorry I got busy at work. Thanks for completing this. it is working correctly.

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.

3 participants