coc-extensions / coc-svelte Goto Github PK
View Code? Open in Web Editor NEWsvelte support for (Neo)Vim
License: MIT License
svelte support for (Neo)Vim
License: MIT License
Maybe related to #1
Hi.
After installation, features such as auto-completion do not work.
Got this issue when running coc-svelte
with svelte-kit and TS. The coc-svelte
won't lint my code and give any error messages when the this error below pop ups
You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.
initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer
[svelte:]
This kinda thing is supported in svelte-preprocess
:
<template lang="pug">
main
h2 Title
p lorem ipsum
</template>
It currently works in VSCode. But unfortunately not in this extension. Any idea how to make it work?
Are their plans to sync this extension back with the vscode-svelte extension?
It appears the implementation is now old enough that parts are broken. For example: sveltejs/language-tools#932
I tried my hand at the upgrade, but quickly realized I do not know enough about coc.nvim
. It appears to not provide many of the exports that vscode
does.
I have coc intellisense working fine in svelte files, and coc eslint working fine in .js files, but no eslint in svelte files. Is this known to work? If so, what configuration is necessary?
I have no coc-specific stuff in my init.vim other than loading the coc plugin and having :CocInstall'd coc-svelte, coc-eslint and
coc-tserver. I'm loading evanleck/vim-svelte and setting filetype to svelte. Here's my eslintrc.json:
{ "env": { "browser": true, "es6": true }, "parser": "babel-eslint", "parserOptions": { "ecmaVersion": 2019, "sourceType": "module" }, "plugins": ["svelte3"], "extends": ["eslint:recommended"], "overrides": [ { "files": ["**/*.svelte"], "processor": "svelte3/svelte3" } ], "rules": { "indent": ["error", 2], "semi": ["error", "never"], "quotes": ["error", "single"] } }
I am getting this error when installing from scratch. First coc.vim via Plug and then simply :CocInstall coc-svelte
. When opening svelte files I see this in my :CocInfo log
ERROR (pid:6017) [extensions] - Error on createExtension coc-svelte from
/Users/johndoe/.config/coc/extensions/node_modules/coc-svelte/lib/src/extension.js Error:
Cannot find module './html/autoClose'
Looking into the coc-svelte/lib/src directory I can only see extension.js, no other files...
Any ideas?
nvim 0.4.4
coc.nvim version: 0.0.80-2cece2600a
coc-svelte 0.2.3
macOS 11.2.3
Hi,
when migrating from svelte 3 to 4, coc-svelte complains in every file's top line with this message:
⚠ <script lang="ts">
Cannot find module '/home/user/src/my_project/node_modules/svelte/compiler'
Require stack:
- /home/user/.config/coc/extensions/node_modules/coc-svelte/node_modules/
svelte-language-server/dist/src/importPackage.js
- /home/user/.config/coc/extensions/node_modules/coc-svelte/node_modules/
svelte-language-server/dist/src/lib/documents/configLoader.js
- /home/user/.config/coc/extensions/node_modules/coc-svelte/node_modules/
svelte-language-server/dist/src/lib/documents/Document.js
- /home/user/.config/coc/extensions/node_modules/coc-svelte/node_modules/
svelte-language-server/dist/src/lib/documents/index.js
- /home/user/.config/coc/extensions/node_modules/coc-svelte/node_modules/
svelte-language-server/dist/src/server.js
- /home/user/.config/coc/extensions/node_modules/coc-svelte/node_modules/
svelte-language-server/bin/server.js (svelte)
When going back to svelte 3, the issue is gone.
Any pointers?
## versions
vim version: NVIM v0.7.2
node version: v18.12.1
coc.nvim version: 0.0.82-75f2b7eb 2022-12-06 00:50:36 +0800
coc.nvim directory: /home/marekdedic/.local/share/nvim/plugged/coc.nvim
term: tmux
platform: linux
## Log of coc.nvim
2022-12-09T23:50:39.090 INFO (pid:230614) [plugin] - coc.nvim initialized with node: v18.12.1 after 216
2022-12-09T23:50:39.103 INFO (pid:230614) [language-client-index] - Language server "svelte" started with 230629
2022-12-09T23:50:39.343 INFO (pid:230614) [attach] - receive notification: highlight []
2022-12-09T23:50:40.405 INFO (pid:230614) [attach] - receive notification: highlight []
2022-12-09T23:50:44.019 INFO (pid:230614) [attach] - receive notification: showInfo []
I get an error when CoC completion is triggered
[coc.nvim]: UnhandledRejection: Cannot read properties of null (reading 'word')
TypeError: Cannot read properties of null (reading 'word')
at Ov.convertVimCompleteItem (/home/marekdedic/.local/share/nvim/plugged/coc.nvim/build/index.js:214:9521)
at Ov.convertToDurationItem (/home/marekdedic/.local/share/nvim/plugged/coc.nvim/build/index.js:214:9418)
at /home/marekdedic/.local/share/nvim/plugged/coc.nvim/build/index.js:257:38120
at Array.map (<anonymous>)
at /home/marekdedic/.local/share/nvim/plugged/coc.nvim/build/index.js:257:38104
(Happens with coc-svelte, but the backtrace points tot coc itself...)
We will close your issue when you don't provide minimal vimrc and we can't
reproduce it
mini.lua
with:local Plug = vim.fn['plug#']
vim.call('plug#begin', vim.fn.stdpath('data') .. '/plugged')
Plug('neoclide/coc.nvim', {branch = 'release'})
Plug('coc-extensions/coc-svelte', {['do'] = 'yarn install --frozen-lockfile'})
vim.call('plug#end')
nvim -u mini.lua
Previously reported to CoC as neoclide/coc.nvim#4426
Trying to type /
or >
on any file type except for the Svelte files, leads to this error at the bottom of the screen :
[coc.nvim]: UnhandledRejection: Request html/tag failed with message: Cannot call methods on an unopened document
Error: Request html/tag failed with message: Cannot call methods on an unopened document
at gu (/home/nima/.local/share/nvim/plugged/coc.nvim/build/index.js:38:224)
at bp (/home/nima/.local/share/nvim/plugged/coc.nvim/build/index.js:37:11261)
at Immediate.<anonymous> (/home/nima/.local/share/nvim/plugged/coc.nvim/build/index.js:37:11111)
at processImmediate (node:internal/timers:466:21)
Open a svelte file(activate Svelte LSP), open another file type(ts, js, json, anything except svelte), then try to issue /
or >
in insert mode, this error hits, and it's so destructive!
I think this is how you try to handle closing tags like below:
<SvelteComponent> </
<!-- ^ here / issued -->
Why there is an html/tag
request for other filetypes than Svelte or HTML?
vim version: NVIM v0.7.2
node version: v18.9.0
coc.nvim version: 0.0.82-488d6ae7 2022-09-22 01:50:53 +0800
coc.nvim directory: /Users/aspirin2d/.local/share/nvim/plugged/coc.nvim
term: iTerm.app
platform: darwin
2022-09-22T23:12:02.827 INFO (pid:12804) [plugin] - coc.nvim initialized with node: v18.9.0 after 23ms
2022-09-22T23:12:10.300 INFO (pid:12804) [attach] - receive notification: showInfo []
2022-09-22T23:13:07.993 ERROR (pid:12804) [language-client-client] - Server svelte initialization failed. Xm [Error]: Request initialize failed with message: Cannot read properties of undefined (reading 'debug')
at Fe (/Users/aspirin2d/.local/share/nvim/plugged/coc.nvim/build/index.js:25:233)
at Ni (/Users/aspirin2d/.local/share/nvim/plugged/coc.nvim/build/index.js:24:6872)
at Immediate. (/Users/aspirin2d/.local/share/nvim/plugged/coc.nvim/build/index.js:24:6719)
at process.processImmediate (node:internal/timers:471:21) {
code: -32603,
data: undefined
}
vim :check health
import neovim
. Using the first available executable for diagnostics.let g:loaded_python3_provider = 0
to your init.vimUpdate 12/15 -- Still troubleshooting this, but I discovered that if I use <script type="text/typescript">
then I do get some syntax highlighting and the code formats correctly (e.g., if I press Enter, it correctly indents on the next line, instead of going all the way to the left-hand side.). It doesn't seem to recognize lang="ts"
or lang="typescript"
for some reason.
Hi there - I have coc-svelte installed and I'm experimenting with Sveltekit. Whenever I use a regular <script>
tag inside a .svelte component, the functionality, syntax coloring, etc. works just fine. However, when I add <script lang="ts">
, the code coloring turns to all white and the formatting gets really messed up. It still recognizes and allows me to use TS inside, but all the syntax highlight, formatting, etc. is removed. Only when I save will the formatting work (but the syntax highlighting is still gone -- everything is white).
Any help is greatly appreciated!
I used this amazing plugin for months, now I just clone one of my company projects and nothing works, VSCode just open it in same environment except this plugin 😉,
How I can find the problem?!
Is there a way to get 'go to definition' working with @rollup/plugin-alias?
Go to difinition works as expected with relative paths but as soon as I change the import to use an alias I get:
[coc.nvim]: Error on notification "jumpDefinition": Cannot read property 'start' of undefined
As my Project grows the relative import paths are getting quite messy. Thats the reason way would like to use @rollup/plugin-alias. Or is there another way to use abolute paths that works well with 'go to definition'?
Thanks for providing coc-svelte :)
This feature seems to be available in vs-code but not here. am i doing something wrong or is it simply not there?
Hello,
the HTMLProps interface in svelte2tsx complains when you give custom attributes to HTML tags. For example,
<div bp="grid"></div>
results in the following error: Property 'bp' does not exist on type 'HTMLProps<HTMLDivElement>'.
I've tried to augment the module, but to no success as my project is out of scope of the plugin. There are a couple options I know of:
In script blocks, using the lang="ts"
attribute doesn't enable typescript in the script tag. Using lang="typescript"
works as expected, but "ts" does not.
So - when I start vim I get this message:
But then, when I try to type a HTML tag - I get Error detected while processing function <lambda>9[1]..<SNR>60_execute:
:
--
And also - don't know if this is related, but I don't get real intellisense. For example - if I try import { onMount } from ...
- then I don't get any completion suggestions for onMount or onDestroy or whatever.
I was having trouble with Typescript and noticed that dependencies are way behind Svelte's lang server. Problem went away after I updated them to latest and greatest.
I now maintain my own fork of the plugin, but what thinking if this can somehow be automated to keep upstream deps in sync?
In coc-explorer Svelte files show an outlined rectangle when using an appropriate Nerd Font. :(
Hi there.
Noticed that 'setup instructions' link in Typescript FAQ section is broken.
And it seems like I need it 😅 because can't get typescript working for .svelte
files. I can see TS intellisense if I change from lang="ts"
to lang="typescript"
, but it disappears almost instantly.
I have this weird behavior that is shown on this gif
As you can see when i select emmet autocompletion item for some reason it removes
previously typed word and then i hit autocomplete key to expand it. But when format called by saving buffer or just calling CocAction('format') it on each invocation adds this removed part of the word.
I don't have this behavior with normal emmet in html files - it actually properly selects autocompletion item without removing part of a typed word and do not add anything with format.
Only me?
Cannot install this, getting the below error:
Get info from https://registry.npmjs.org/
Downloading from https://registry.npmjs.org/coc-svelte/-/coc-svelte-0.4.2.tgz
Download progress 3.1%
Download progress 8.5%
Download progress 13.8%
Download progress 19.2%
Download progress 24.6%
Download progress 29.9%
Download progress 35.3%
Download progress 40.7%
Download progress 46.0%
Download progress 51.4%
Download progress 56.7%
Download progress 62.1%
Download progress 67.5%
Download progress 72.8%
Download progress 78.2%
Download progress 83.5%
Download progress 88.9%
Download progress 94.3%
Download progress 99.6%
Download progress 100.0%
Extension download at /tmp/nvimMniz5h/coc-svelte-jQ64rc
Installing dependencies by: /usr/bin/npm install --ignore-scripts --no-lockfile --production --legacy-peer-deps --no-global.
npm ERR! code ETARGET
npm ERR! notarget No matching version found for @types/lodash@^4.14.172.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/brad/.npm/_logs/2022-05-03T07_56_50_471Z-debug-0.log
/usr/bin/npm install exited with 1
I will try PR this later with another version of @types/lodash
Hello, thanks for this extension!
I'm sorry I have to post such a vague issue, but I can't seem to make the extension work at all. I have no syntax highlighting on .svelte
files and none of the features advertised in the documentation.
I've installed the extension using :CocInstall coc-svelte
. I have also tried installing svelte-language-server
globally and pointing Coc to the executable (successfully) with "svelte.language-server.runtime": "/home/fausto/.volta/bin/svelteserver"
. But I still can't get it to work.
There seem to be two things that may influence this:
set filetype?
on my App.svelte
file I get filetype=
(empty). However, if I set it with set filetype=svelte
, it doesn't work either.svelte.restartLanguageServer
, the server apparently doesn't start at all (going by the logs, there's no mention of the extension there). However, even after I run svelte.restartLanguageServer
, the server restarts successfully but the extension has no effect.Results of CocOpenLog
after opening App.svelte
:
2020-07-03T21:58:57.897 INFO (pid:20017) [services] - registered service "eslint"
2020-07-03T21:58:58.124 INFO (pid:20017) [plugin] - coc.nvim 0.0.78-c9246e45a1 initialized with node: v12.18.1 after 306ms
Results of CocOpenLog
after additionally running svelte.restartLanguageServer
:
2020-07-03T22:01:31.038 INFO (pid:20665) [services] - registered service "eslint"
2020-07-03T22:01:31.259 INFO (pid:20665) [plugin] - coc.nvim 0.0.78-c9246e45a1 initialized with node: v12.18.2 after 295ms
2020-07-03T22:02:02.569 INFO (pid:20665) [language-client-index] - svelte started with 20763
2020-07-03T22:02:03.071 INFO (pid:20665) [language-client-index] - svelte started with 20772
Suspiciously there are two entries for svelte now.
Any idea what could be happening?
If I have both coc-svelte and coc-html loaded, with html.autoClosingTags: true
then I get some weird behavior.
Suppose I have this code:
<dl>
<dt>Term</dt>
<dd>Description</dd>
</dl>
If at this point I add another
</dl>dt>
:
<dl>
<dt>Term</dt>
<dd>Description</dd>
<dt></dl>dt>
</dl>
I can reproduce this with any HTML element.
If I only install coc-html, the auto closing feature works as expected. When I only use coc-svelte I have no auto close functionality.
Not sure if this is the correct repo to report this issue.
Setting html.autoClosingTags
to false acts as a workaround but of course disables auto closure entirely.
Whenever I use the auto import feature of coc or the CocAction('runCommand', 'editor.action.organizeImport')
the line endings will be in windows format.
Example
import Foo from './Foo.svelte';^M
This only happens in svelte
files. js
and ts
use Unix
line endings.
Is there a way to specify the type of line endings?
My current workaround is to run :%s/^M//g
from time to time.
Edit: I found a related issue on sveltejs/language-tools#854 but I don't know what to do with the information.
Coc now supports installing extensions using Vim package managers. See: https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions#use-vims-plugin-manager-for-coc-extension . This extension does not work for me when installed with my package manager. For example, with vim-packager:
call packager#add('[email protected]:coc-extensions/coc-svelte.git', {
\ 'do': 'yarn install',
\ })
This technique works for every other extension I've used so far . I also confirm that coc-svelte works for me when installed using CocInstall coc-svelte.
My environment:
## versions
vim version: NVIM v0.5.0-dev
node version: v12.9.1
coc.nvim version: 0.0.74-6700e7468d
term: xterm-256color
platform: linux
## Messages
## Output channel: snippets
The README indicates that this extension provides syntax highlighting. However, for it to work, it needs to be installed in tandem with a syntax highlighting plugin (I used leafOfTree/vim-svelte-plugin
).
Does this need to be mentioned in the README?
To replicate, npx degit "sveltejs/sapper-template#rollup" test
, open the test
directory in vim and open a .svelte file.
You will see a notice [coc.nvim] The "svelte" server crashed 5 times in the last 3 minutes.
.
I'm using the latest versions of both coc and coc-svelte. NVIM 0.4.4
Svelte recently created an official language server that's still in "beta".
Perhaps this plugin should consider adopting at some point?
I followed the guide listed here. I do not understand why you'd need to understand the VSCode extension because I'm trying to avoid it.
I have installed coc-tailwindcss3 for this though, and it's not working with this extension.
How can I active Prettier when I save in .svelte with this extension?
Thans for your work!
Hey, I've been using for a while this extension and I've enjoyed it a lot, it helps with a lot of stuff but today I've tried using it and couldn't because of some error I'm not sure why is happening...
I've tried searching for the possible source of it but couldn't find anything... any ideas on how to fix this?
Steps to reproduce:
[~]$ uname -a
Linux archlinux 5.17.1-arch1-1 #1 SMP PREEMPT Mon, 28 Mar 2022 20:55:33 +0000 x86_64 GNU/Linux
[~]$ npm --version
8.5.5
[~]$ node --version
v17.8.0
[~]$ nvim --version
NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
When running the command "yarn build" (after "yarn install", of course) on the latest master, the build fails with the following message involving DocumentSymbolParams and WorkspaceSymbolParams:
$ yarn build
yarn run v1.17.3
warning [email protected]: The engine "coc" appears to be invalid.
$ rm -rf ./out && tsc -p ./
node_modules/coc.nvim/node_modules/vscode-languageserver-protocol/lib/protocol.d.ts:2:129 - error TS2305: Module '"../node_modules/vscode-languageserver-types/lib/umd/main"' has no exported member 'WorkspaceSymbolParams'.
2 import { TextDocumentContentChangeEvent, Position, Range, Location, LocationLink, Diagnostic, Command, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, DocumentUri, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, TextDocumentSaveReason, CompletionItem, CompletionList, Hover, SignatureHelp, ReferenceContext, DocumentHighlight, DocumentSymbolParams, SymbolInformation, CodeLens, CodeActionContext, FormattingOptions, DocumentLink, MarkupKind, SymbolKind, CompletionItemKind, CodeAction, CodeActionKind, DocumentSymbol } from 'vscode-languageserver-types';
~~~~~~~~~~~~~~~~~~~~~
node_modules/coc.nvim/node_modules/vscode-languageserver-protocol/lib/protocol.d.ts:2:355 - error TS2305: Module '"../node_modules/vscode-languageserver-types/lib/umd/main"' has no exported member 'DocumentSymbolParams'.
2 import { TextDocumentContentChangeEvent, Position, Range, Location, LocationLink, Diagnostic, Command, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, DocumentUri, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextDocumentItem, TextDocumentSaveReason, CompletionItem, CompletionList, Hover, SignatureHelp, ReferenceContext, DocumentHighlight, DocumentSymbolParams, SymbolInformation, CodeLens, CodeActionContext, FormattingOptions, DocumentLink, MarkupKind, SymbolKind, CompletionItemKind, CodeAction, CodeActionKind, DocumentSymbol } from 'vscode-languageserver-types';
~~~~~~~~~~~~~~~~~~~~
Found 2 errors.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Node: v12.9.1
Yarn: 1.17.3
Hey there,
when moving/ renaming a file that is imported by another file, the combination of watchman and coc-tsserver prompts you if you want to update the imports. The svelte vs code extension allows for the same thing. However, I can't get this to work for svelte files.
I set svelte.plugin.svelte.rename to true, however this did not do anything. I assume I would need some sort of process to watch my files and notify coc-svelte?
Hey,
thank you very much for creating this fantastic extension.
The default project template of svelte kit, which will soon be the default template for svelte in general, features new svelte-kit specific syntax, that is not supported in the language-server version used in the newest version of the coc-svelte extension.
This is a snippet from the default template:
<ul>
<li class:active={$page.path === '/about'}>
<a sveltekit:prefetch href="/about">About</a>
</li>
</ul>
It results in a "[js 1003] Identifier expected" and a flood of red for the remaining markdown path.
For now, I have forked this repo and published a temporary solution on npm under coc-svelte-kit
I will also make a pull request, so that coc-svelte works for svelte-kit projects as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.