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

Is there any options to remove certain completions? e.g. div(dividend, divisor) #688

Open
pejrich opened this issue Apr 9, 2024 · 6 comments

Comments

@pejrich
Copy link

pejrich commented Apr 9, 2024

This isn't a bug, but rather a question, or maybe feature request.

I'm using the setup for nvim, and I had a similar issue in VSCode which is that Lexical likes to suggest div(dividend, divisor)~ Function for autocomplete, which seems to always be at the top of the list(when i've typed div), however from years of muscle memory, div is always <div>|</div>, so it drives me nuts every time I get div(|dividend, divisor) since it's a function I use so rarely. VSCode seemed to have no way to turn off specific suggestions. I'm curious if there are any options for neovim I can pass to Lexical in the lsp_config.setup({...}) call that would turn off specific suggestions?

@skbolton
Copy link

skbolton commented Apr 9, 2024

All of the neovim lsp callbacks are customizable. So could override the the completion request and swallow ones matching that pattern.

@scohen
Copy link
Collaborator

scohen commented Apr 10, 2024

Currently, lexical doesn't support any configuration. I've been considering adding project-level configuration, but we haven't had the need for configuration yet.

@scohen
Copy link
Collaborator

scohen commented Apr 10, 2024

Another take on this would be to refine completions based on their context. For example, you should not get a completion in heex unless you're inside of an elixir block.

@pejrich
Copy link
Author

pejrich commented Apr 10, 2024

Another take on this would be to refine completions based on their context. For example, you should not get a completion in heex unless you're inside of an elixir block.

This would be amazing. As much as there are a lot of things I like about the new Phoenix stuff since LiveView, the comingling of HTML and Elixir can at times be cumbersome. Either the HTML doesn't format, or intellisense gives me Elixir completions inside of HTML, or equally as bad, SomeModu<tab> in Elixir code gives me <SomeModu></SomeModu>, because in order to get <div>|</div> completion inside a .ex component file, I have to tell the editor(in this case VSCode, for example) that .ex files are html, which means some React HTML completion extension thinks SomeModu might be a React component. (These aren't Lexical specific issues, just general things i've come across)

I guess it's different for everyone in terms of what code assistance they find nice to have, and which things they find hard to live without. Having function completion in Elixir is very nice, but for me having to type out a function is typically less cumbersome(since it generally flows in a single direction), than having to type out HTML tags by hand, because you're either jumping around to the beginning and end of everything, or you're trying to figure out what block is missing a closing tag.

One complexity is that you have Elixir within HTML within Elixir. I'm not sure how much of a challenge that it from the code context side of things

defmodule SomeComponent do

  def some_function(assigns) do
    # ELIXIR HERE
    ~H"""
       HTML HERE
       <div class={ELIXIR HERE}>HTML HERE <%= ELIXIR HERE %></div>
     """
  end
end

@pejrich
Copy link
Author

pejrich commented Apr 10, 2024

All of the neovim lsp callbacks are customizable. So could override the the completion request and swallow ones matching that pattern.

This is very helpful, thank you. I'm still in the long, (sometimes painful) process of switching to Neovim, and while I'm sure everything I want is possible, I have to sometimes block my time, "Ok, I'll only spend 1 hour trying to find the relevant docs/solution to this", otherwise Neovim can at times feel like 90% of your time is coding your editor, and only 10% is coding your code, haha. But this link gets me going in the right direction.

@scohen
Copy link
Collaborator

scohen commented Apr 10, 2024

that .ex files are html

You should be able to get more granular than that. Emacs has something called multi-mode-mode or polymode which allows you to tell it that certain parts of a file are in one language, and the others are in another. Perhaps vscode has similar functionality?

One complexity is that you have Elixir within HTML within Elixir. I'm not sure how much of a challenge that it from the code context side of things

We can detect the ~H sigils in the AST pretty easily, though that's a feature for the 0.7. Would you mind drafting an issue for that? It seems the best way forward.

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

No branches or pull requests

3 participants