-
-
Notifications
You must be signed in to change notification settings - Fork 221
Closed
Labels
questionA user questionA user question
Description
Describe the bug
Whenever I try to import a component into another component, the language server seems to suggest a relative path, rather than a $lib
path.
Reproduction
- Install
lspconfig
- Install
svelte-language-server
usingMason
- Create a new svelte app using
npx sv create app
cd app; nvim .
touch src/lib/components/component-a.svelte
andtouch src/lib/components/component-b.svelte
- Type
<ComponentA/>
into+page.svelte
- Code actions (and autocompletions) will suggest an import from
$lib
:

- Type
<ComponentA/> into
component-a.svelte` - Code actions (and autocompletions) will suggest an import from
./component-a.svelte
:

The same is true for typescript files.
e.g.
echo 'export const test = 'test';' > src/lib/testFile.ts
- In
component-a.svelte
, attempting to importtest
will suggest a relative path.

Expected behaviour
Both imports should be imported through $lib
. Alternatively, suggest a relative import path, but make $lib
the default.
System Info
- OS: [e.g. Windows]
❯ inxi -Sxxx
System:
Host: codevogel-GLU Kernel: 6.8.0-79-generic arch: x86_64 bits: 64
compiler: gcc v: 13.3.0 clocksource: tsc
Desktop: awesome v: 4.3 vt: 7 dm: LightDM v: 1.30.0
Distro: Linux Mint 22.1 Xia base: Ubuntu 24.04 noble
- IDE: [e.g. VSCode, Atom] Neovim with this config
Which package is the issue about?
svelte-language-server
Additional Information, eg. Screenshots
I have tried extending the svelte server capabilities with non-relative
as a preference, like so:
svelte = {
capabilities = {
workspace = {
didChangeWatchedFiles = false,
},
},
settings = {
lint = {
unknownAtRules = 'ignore',
},
typescript = {
preferences = {
importModuleSpecifierPreference = 'non-relative',
},
},
},
preferences = {
importModuleSpecifierPreference = 'non-relative',
},
},
:LspInfo
:
==============================================================================
vim.lsp: require("vim.lsp.health").check()
- LSP log level : WARN
- Log path: /home/codevogel/.local/state/nvim/lsp.log
- Log size: 49080 KB
vim.lsp: Active Clients ~
- GitHub Copilot (id: 1)
- Version: 1.378.0
- Root directory: nil
- Command: { "node", "/home/codevogel/.local/share/nvim/lazy/copilot.vim/copilot-language-server/dist/language-server.js", "--stdio" }
- Settings: {
["github-enterprise"] = {
uri = vim.NIL
},
http = {
proxy = vim.NIL,
proxyStrictSSL = vim.NIL
}
}
- Attached buffers: 30, 28, 110, 23, 159, 19, 138, 174, 173
- eslint (id: 2)
- Version: ? (no serverInfo.version response)
- Root directory: ~/work/test/app
- Command: { "vscode-eslint-language-server", "--stdio" }
- Settings: {
codeAction = {
disableRuleComment = {
enable = true,
location = "separateLine"
},
showDocumentation = {
enable = true
}
},
codeActionOnSave = {
enable = false,
mode = "all"
},
experimental = {
useFlatConfig = true
},
format = true,
nodePath = "",
onIgnoredFiles = "off",
problems = {
shortenToSingleLine = false
},
quiet = false,
rulesCustomizations = {},
run = "onType",
useESLintClass = false,
validate = "on",
workingDirectory = {
mode = "auto"
},
workspaceFolder = {
name = "app",
uri = "/home/codevogel/work/test/app"
}
}
- Attached buffers: 174, 159, 19, 138, 110, 173
- svelte (id: 3)
- Version: ? (no serverInfo.version response)
- Root directory: ~/work/test/app
- Command: { "svelteserver", "--stdio" }
- Settings: {}
- Attached buffers: 138, 159, 19
- lua_ls (id: 4)
- Version: 3.15.0
- Root directory: ~/.dotfiles/neovim/.config/nvim
- Command: { "lua-language-server" }
- Settings: {}
- Attached buffers: 23, 28
- stylua (id: 5)
- Version: 2.3.0
- Root directory: ~/.dotfiles/neovim/.config/nvim
- Command: { "stylua", "--lsp" }
- Settings: {}
- Attached buffers: 23, 28
- ts_ls (id: 6)
- Version: ? (no serverInfo.version response)
- Root directory: ~/work/test/app
- Command: { "typescript-language-server", "--stdio" }
- Settings: {}
- Attached buffers: 110, 174, 173
Metadata
Metadata
Assignees
Labels
questionA user questionA user question