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

Add missing requires from comment should not add to ns #1316

Closed
mainej opened this issue Oct 9, 2022 · 4 comments
Closed

Add missing requires from comment should not add to ns #1316

mainej opened this issue Oct 9, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mainej
Copy link
Collaborator

mainej commented Oct 9, 2022

Is your feature request related to a problem? Please describe.

Currently add-missing-require always adds the missing namespace to the ns's :require form. But when in an RCF, a top-level (comment ...) form, this isn't what some users want. They feel that this clutters their ns with namespaces that aren't really used. They'd prefer that the missing namespace be put in a (require ...) form in the RCF.

Describe the solution you'd like

I'd like one of two things. I think the best would be a configuration option that modified add-missing-require's behavior. Bonus points for adding the missing namespace to an existing (require ...). Alternatively, there could be a new command.

Describe alternatives you've considered
It's possible to add (require ...) by hand.

Additional context
See discussion in Slack

@mainej mainej added the enhancement New feature or request label Oct 9, 2022
@ericdallo
Copy link
Member

I see 2 good possible options:

  • Add support as a flag, we can discuss the default value.
  • Always ask when adding a require inside a RCF if user wants to add on comment or top-level ns

@mainej
Copy link
Collaborator Author

mainej commented Oct 13, 2022

Yeah, either of those would work. Prompting the user is a nice idea. This is a rare enough use-case that a prompt wouldn't be too intrusive, IMO.

@ericdallo ericdallo added the good first issue Good for newcomers label Oct 14, 2022
@blnote
Copy link
Contributor

blnote commented Feb 1, 2024

Hi, I'm working on this a little: right now I've introduced a flag add-require-inside-comments and I'm showing a prompt whenever the code-action add-missing-libspec is called within a comment form and this flag is not set (neither true or false).
However, code-completion adds lib-specs too and asking might be difficult in this case, since the edit seems to be done before the user commits to a completion (?)...
so maybe I'd just stick to the setting of the flag in this case and default to the old behavior if it is not present ? ...just writing down thoughts :)

ericdallo pushed a commit that referenced this issue Feb 15, 2024
…t comment form during code action and completion. [#1316] (#1767)

* add inside-rcf? predicate to edit ns

* added rcf-position info to (unresolved) alias completion

* added prompt and setting {:completion {:add-require-inside-comments true|false|nil}

* added quick-fix functionality for require, renamed setting

* added import-case and fixed autocompletion conflict

* accounted for the new parameter rcf-pos

* extracted shared code from ns-add-to-namespace to 2 new functions

* fixed issue error when inserting 0 white-spaces, typo  in parameter, changed check for existing forms

* fixed: without resolving, the zloc was not at the root and the comment position could not be found

* added unit tests

* updated changelog

* changed name of setting

* updated docs

* fixed changelog, order in seettings.md

* changed position of new setting

---------

Co-authored-by: blnote <b@s>
@ericdallo
Copy link
Member

Fixed by #1767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy