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

support trim specific extension on import #123

Closed
tjx666 opened this issue Jan 15, 2023 · 6 comments
Closed

support trim specific extension on import #123

tjx666 opened this issue Jan 15, 2023 · 6 comments

Comments

@tjx666
Copy link
Collaborator

tjx666 commented Jan 15, 2023

In normal web project, when import js/ts/jsx/tsx/mts/mjs/cjs they needn't complete extension. But like less/scss/png etc need.

So, it would be better to have a configuration to configure to make only trim specific extension on import.

@mihai-vlc

@tjx666
Copy link
Collaborator Author

tjx666 commented Feb 2, 2023

@mihai-vlc My use case is that in my project, vscode builtin typescript relative path module suggestion doesn't work. So I want to use this extension to support path suggestion.
But you can see this extension provide suggestion with file extension:

image

For now, we have setting path-autocomplete.extensionOnImport, but that can't solve my need.

I want to trim file extension for ts/js, but not for css/scss/less etc

@mihai-vlc
Copy link
Owner

Hi @tjx666 ,

Can you try configuring the language specific settings in v1.23 ?

    "path-autocomplete.extensionOnImport": true,
    "[typescript]": {
        "path-autocomplete.extensionOnImport": false,
    },

Please feel free to reopen the ticket if you still encounter issues.

@mihai-vlc
Copy link
Owner

mihai-vlc commented Feb 2, 2023

You may also want to combine this with path-autocomplete.transformations if you want to remove the extension for certain completion items but keep it for others.

@tjx666
Copy link
Collaborator Author

tjx666 commented Feb 2, 2023

I need use autocomplete.transformations setting to restore scss/less which is a little complex.

My thought is to let path-autocomplete.extensionOnImport setting support object value. like:

{
    "path-autocomplete.extensionOnImport": {
        "*.{ts,tsx,js,jsx}": false
    }
}

@mihai-vlc
Copy link
Owner

would something like this work ?

"path-autocomplete.extensionOnImport": true,
    "path-autocomplete.transformations": [
        {
            "type": "replace",
            "parameters": [
                "\\.\\w+$",
                ""
            ],
            "when": {
                "fileName": "\\.(ts|tsx|js|jsx)$"
            }
        }
    ],

@tjx666
Copy link
Collaborator Author

tjx666 commented Feb 3, 2023

would something like this work ?

Nice work.

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

2 participants