-
Notifications
You must be signed in to change notification settings - Fork 434
feat: add toggle_doc functionality #1647
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
Conversation
fix: Update docs view on entry change
|
The implementation is good but I think the API should be What do you think? |
lua/cmp/config/default.lua
Outdated
| completeopt = 'menu,menuone,noselect', | ||
| keyword_pattern = [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]], | ||
| keyword_length = 1, | ||
| docs_initially_visible = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... I'll consider the better place for this option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I was unsure about it too. IMO it doesn't make sense to put it in WindowConfig since those only involve UI settings, and all other categories don't feel right either...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also just get rid of this option and let users configure if docs should be initially visible or not.
Sounds reasonable to me! |
|
@hrsh7th lmk if this looks good to you. I can add a couple of examples and update the documentation to explain how these work :) |
lua/cmp/view.lua
Outdated
| return | ||
| end | ||
| self.docs_view:open(e, self:_get_entries_view():info()) | ||
| if self.docs_view:visible() then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. I didn't understand why this was needed. Could you explain it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is needed in order to correctly update the documentation window when the selected entry changes.
- If the documentation window is currently closed, then it won't be opened when the entry changes.
- If it's open, then we ensure that its content reflects the new entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm the issue with this is that the docs will initially be hidden. And so I think we do need the docs_initially_visible, or do you have a better idea of how to address this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hrsh7th what are your thoughts on this :) ?
|
Almost looks good. |
|
sorry for the delay. I've been busy with work...😭 I'll push a new commit for this PR. Please wait. |
No worries! Take your time, I’m just trying to help :) |
|
Any update on this? :) |
|
I pushed a fix commit. Can you please confirm? |
I just tried it and it works great :) Thank you so much for taking the time to improve and document the feature! |
…indow * upstream/main: fix: remove usages from vim.lsp.util.parse_snippet (hrsh7th#1734) ci: fix broken tests (hrsh7th#1729) Format with stylua docs: Add comments and type annotations for sorting comparators (hrsh7th#1687) fix(ghost_text): `ephemeral` causes a false positive of no inline support (hrsh7th#1645) perf(core): simplify and improve `find_line_suffix()` (hrsh7th#1675) Format with stylua feat: add toggle_doc functionality (hrsh7th#1647) add context check for invalid detection implement is_invalid detection perf: fix `nvim_replace_termcodes` being called on every `CursorMoved` (hrsh7th#1650) improve pattern handling Format with stylua fix confirm resolve
|
so how to acutally use this like what is the function that I can bind it into a binding |
local cmp = require('cmp')
cmp.setup({
view = { docs = { auto_open = false } },
mapping = cmp.mapping.preset.insert({
['K'] = cmp.mapping(function(fallback)
if cmp.visible_docs() then
cmp.close_docs()
elseif cmp.visible() then
cmp.open_docs()
else
fallback()
end
end),
})
}) |
|
@beh-10257 read the docs: Line 970 in a110e12
|
Refer to #1646
I'm very sorry for the trouble, for some reason GitHub stopped showing all my commits (??).