sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only absolute/relative auto-import

deger4beger opened this issue · comments

I need to always use absolute imports in my current project, found this option in Preferences: LSP-typescript Settings, by default it specifies the shortest path:

"importModuleSpecifierPreference": "shortest",

Tried to set "absolute" value but it's not working and there is no docs with possible values

If you install LSP-json then you'll get suggestions with available values.

commented

Sorry to bother, but this isn't working for me; lsp-typescript insists on using relative import paths.

This is my LSP-typescript.sublime-settings:

// Settings in here override those in "LSP-typescript/LSP-typescript.sublime-settings"
{
	"schemes": ["file"],

	"initializationOptions": {
		"preferences": {
			"importModuleSpecifierPreference": "relative",
		},
	},
}

LSP-json confirms that these are valid values, I've restarted everything, and aliased imports are configured correctly. My tsconfig.json looks like this:

{
	"compilerOptions": {
		"baseUrl": ".",
		"paths": { "@/*": ["src/*"], "@components/*": ["src/components/*"] },
...
commented

🤦 It was supposed to be non-relative for the behavior I wanted. Confirming this works in LSP-typescript.sublime-settings:

// Settings in here override those in "LSP-typescript/LSP-typescript.sublime-settings"

{
	"schemes": ["file"],

	"initializationOptions": {
		"preferences": {
			"importModuleSpecifierPreference": "non-relative",
		},
	},
	"diagnostics_mode": "workspace",
}