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
Support disabling function symbol comletion when there is snippet equivalent #638
Comments
@tami5 I'd like to understand this one better, for me we show the elements before the snippets, at least for me on emacs: |
Yes exactly, 9/10 what the user want is the snippet. it's rare that I'd want to complete and confirm a symbol by it's own. What I'm suggesting is an option to filter out function/macro symbol when there's a symbol with the same name.
Of course this would be tricky to implement because we'd need to take in consideration some cases:
Symbol completion is cool, but completion for code structure is awesome. "tab" over to fill the blank 🤣 and that's it. This would solve another issue I have when writing functions that are new to me, basically, I'd repeatedly press srry I keep jumping out scope 😆 |
So what you want is snippets sorted first than symbols, not sure it makes sense remove the symbols since it's a general completion. About the snippets enhancement, we could have some improvements on snippets maybe to add custom capabilities I think |
Alright, I see your point, maybe for some key symbols like
actually, it shows with a |
I don't understand why the current Here you can find all snippets code: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/completion_snippet.clj#L10-L70
It was something I added to differ from snippets, but I think it makes sense to drop it, we already have the kind to define that is a snippet.
They could be command which is what code actions call under the hood, but since the kind there is snippet, probably is just a snippet indeed. |
I'd suspect some user would want to overwrite it to add the documentation part or other stuff. I was trying to understand how rust-analyzer does it without defining a list of snippets, some relevant parts worth looking into, https://github.com/rust-analyzer/rust-analyzer/blob/a8247685cfa09084bd620c0877ea1eb3d605d8a2/crates/ide_completion/src/lib.rs
I agree, somehow on enter, they are deleting text range and moving the cursor, e.g. |
Move cursor also works with snippets, and it's way easier to implement then with code actions, maybe we just need to enhance the snippets with documentation about the symbol and things like that dynamically |
@tami5 I made a commit that should fix this, could you test it on master? we know replace the symbols with the equivalent snippets |
Okay, managed to test it just now, Remarks:
Missing:
@ericdallo Should I rename this is issue to be more general "Improve Function Completion"? |
I don't think we should remove new lines in snippets, they totally makes sense for a lot of snippets and works very well for most cases, probably something to fix on parinfer-rust? The JVM certainly affects the performance vs the graalvm one, maybe you should compare with and without the latest commit?
I thought about that, but that doesn't makes sense since it's indeed a snippet kind, it could be misleading to people complete defn saying that is a function but it'd introduce a snippet without any feedback.
Maybe we could replace the snippet detail with the symbol detail which I think usually is the docs |
I agree, but a found a proper workaround: Anything with new line should be followed by named placeholder,
Yep, its the JVM
hmmm, I don't know about that, it will still show
AWESOME, testing it out now |
Almost sure it will show the ~ only when the kind is a snippet, also other editors don't have this ~ thing, so it's a neovim thing.
Could you elaborate?
I'll double check the spec, is not fresh on my mind how the snippets works, but just to make it clear, we are not changing the snippet based on the symbol yet, so they are all static, in the future we could replace the snippet args with the function args, but I'd leave to another issue as is not that easy |
e.g. description, examples from clojure docs
KK |
I'm not on the PC right now, but I need to check the spec docs, I'm not sure that the detail is the correct place to put those things |
I just checked that there is the field |
@tami5 I just found that I didn't have the completion popup enabled on my emacs 😅 I enabled and I'm fixing the issue: |
😍 Awesome we're getting closer |
@tami5 I think everything is good now, could you please test it master again? |
Works flawlessly, I'd add before closing this issue is to modify the snippets that has new lines and |
This break things, $0 is part of the snippet LSP spec where it tells to client that tabstop number, if we change that we loose the tabstop: https://microsoft.github.io/language-server-protocol/specification#snippet_syntax |
Yah also, we can keep $0 as last place outside {:use-metadata-for-privacy? true
:clean {:ns-inner-blocks-indentation :same-line}
:text-document-sync-kind :full
:auto-add-ns-to-new-files? true
:hover {:hide-file-location? true}
:notify-references-on-file-change true
:additional-snippets [{:name "wrap-let"
:detail "Wrap in let sexpr"
:snippet "(let [$1]\n $0$current-form)"}
{:name "defn"
:snippet "(defn%s $\{1:name} [$2]\n $\{3:body})$0"}]
} |
I made one more commit improving the snippets and adding descriptive names to $0 |
Okay much better now. I think this resolves this issue, I will move parts that ware out of the scope to a new issue later. Thanks @ericdallo for your amazing work 🙏 |
Good, glad to fix it, thanks for the help on improving it |
Is your feature request related to a problem? Please describe.
I'm always frustrated when with seeing duplication of symbols, and hate that fact that snippet is less prioritized in my editor.
For me instead of
letf|<cr>
, I have toletf|<down><cr>
Describe the solution you'd like
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: