{"id":13721923,"url":"https://github.com/leafOfTree/vim-svelte-plugin","last_synced_at":"2025-05-07T14:30:53.794Z","repository":{"id":41188298,"uuid":"204269678","full_name":"leafOfTree/vim-svelte-plugin","owner":"leafOfTree","description":"Vim syntax and indent plugin for .svelte files","archived":false,"fork":false,"pushed_at":"2025-02-27T09:37:40.000Z","size":97,"stargazers_count":147,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T02:08:22.250Z","etag":null,"topics":["indent","plugin","svelte","svelte3","syntax","vim"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leafOfTree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-25T08:53:34.000Z","updated_at":"2025-03-26T19:25:58.000Z","dependencies_parsed_at":"2024-01-06T01:04:58.710Z","dependency_job_id":"119195d4-6ee8-40e3-8890-e357b217d5ca","html_url":"https://github.com/leafOfTree/vim-svelte-plugin","commit_stats":{"total_commits":150,"total_committers":5,"mean_commits":30.0,"dds":"0.040000000000000036","last_synced_commit":"2de4e9f55d061e3296917e3621e022542db74faa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-svelte-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-svelte-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-svelte-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leafOfTree%2Fvim-svelte-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leafOfTree","download_url":"https://codeload.github.com/leafOfTree/vim-svelte-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252895526,"owners_count":21821176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indent","plugin","svelte","svelte3","syntax","vim"],"created_at":"2024-08-03T01:01:22.801Z","updated_at":"2025-05-07T14:30:53.778Z","avatar_url":"https://github.com/leafOfTree.png","language":"Vim Script","readme":"\u003cimg src=\"https://raw.githubusercontent.com/leafOfTree/leafOfTree.github.io/master/vim-svelte-plugin-icon.svg\" width=\"60\" height=\"60\" alt=\"icon\" align=\"left\"/\u003e\n\n# vim-svelte-plugin\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/altercation/vim-colors-solarized\"\u003e\n\u003cimg alt=\"screenshot\" src=\"https://raw.githubusercontent.com/leafOfTree/leafOfTree.github.io/master/vim-svelte-solarized.png\" width=\"220\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/leafOfTree/vim-svelte-theme\"\u003e\n\u003cimg alt=\"screenshot\" src=\"https://raw.githubusercontent.com/leafOfTree/leafOfTree.github.io/master/vim-svelte-theme.png\" width=\"220\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\nVim syntax and indent plugin for `.svelte` files. Forked from [vim-vue-plugin][3].\n\n## Installation\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\u003ca\u003eHow to install\u003c/a\u003e\u003c/summary\u003e\n\n- [VundleVim][2]\n\n        Plugin 'leafOfTree/vim-svelte-plugin'\n\n- [vim-pathogen][5]\n\n        cd ~/.vim/bundle \u0026\u0026 \\\n        git clone https://github.com/leafOfTree/vim-svelte-plugin --depth 1\n\n- [vim-plug][7]\n\n        Plug 'leafOfTree/vim-svelte-plugin'\n        :PlugInstall\n\n- Or manually, clone this plugin to `path/to/this_plugin`, and add it to `rtp` in vimrc\n\n        set rtp+=path/to/this_plugin\n\n\u003cbr /\u003e\n\u003c/details\u003e\n\nThis plugin works if it has set `filetype` to `svelte`. Please stay up to date. Feel free to open an issue or pull request.\n\n## How it works\n\nIt combines HTML, CSS and JavaScript syntax and indent in one file.\n\nSupports\n\n- Svelte directives.\n- Less/Sass/Scss, Pug with [vim-pug][4], Coffee with [vim-coffee-script][6], TypeScript with [typescript-vim][14] or [yats.vim][15].^\n\n    Relative plugins need to be installed.\n\n- A builtin `foldexpr` foldmethod.^\n- [emmet-vim][10] HTML/CSS/JavaScript filetype detection.\n\n^: see Configuration for details.\n\n## Configuration\n\nSet global variable to `1` to enable or `0` to disable. Ex:\n\n    let g:vim_svelte_plugin_load_full_syntax = 1\n\n| variable                               | description                                                                                                                                                                 | default |\n|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|\n| g:vim_svelte_plugin_load_full_syntax \\* | Enable: load all syntax files in `runtimepath` to enable related syntax plugins.\u003cbr\u003e Disable: only in `$VIMRUNTIME/syntax`, `~/.vim/syntax` and `$VIM/vimfiles/syntax` | 0       |\n| g:vim_svelte_plugin_use_pug \\*          | Enable pug syntax for `\u003ctemplate lang=\"pug\"\u003e`.                                                                                                                              | 0       |\n| g:vim_svelte_plugin_use_coffee         | Enable coffee syntax for `\u003cscript lang=\"coffee\"\u003e`.                                                                                                                          | 0       |\n| g:vim_svelte_plugin_use_typescript     | Enable typescript syntax for `\u003cscript lang=\"ts\"\u003e`.                                                                                                                          | 0       |\n| g:vim_svelte_plugin_use_less           | Enable less syntax for `\u003cstyle lang=\"less\"\u003e`.                                                                                                                               | 0       |\n| g:vim_svelte_plugin_use_sass           | Enable scss syntax for `\u003cstyle lang=\"scss\"\u003e`(or sass for `lang=\"sass\"`).                                                                                                    | 0       |\n| g:vim_svelte_plugin_use_stylus           | Enable stylus syntax for `\u003cstyle lang=\"stylus\"\u003e`.                                                                                                                               | 0       |\n| g:vim_svelte_plugin_has_init_indent    | Initially indent one tab inside `style/script` tags.                                                                                                                        | 1       |\n| g:vim_svelte_plugin_use_foldexpr       | Enable builtin `foldexpr` foldmethod.                                                                                                                                       | 0       |\n| g:vim_svelte_plugin_debug              | Echo debug messages in `messages` list. Useful to debug if unexpected indents occur.                                                                                        | 0       |\n| g:vim_svelte_plugin_open_devdocs       | Key mapping to search documentation on https://devdocs.io for the word under the cursor or selected | `\u003cF1\u003e`       |\n\n\\*: Vim may be slow if the feature is enabled. Find a balance between syntax highlight and speed. By the way, custom syntax can be added in `~/.vim/syntax` or `$VIM/vimfiles/syntax`.\n\n**Note**\n\n- `filetype` is set to `svelte` so autocmds and other custom settings for `javascript` have to be manually enabled for `svelte`.\n- `g:vim_svelte_plugin_load_full_syntax` applies to `HTML/Sass/Less`.\n- See \u003chttps://svelte.dev/docs#svelte_preprocess\u003e for how to use `Less/Sass/Pug`... in svelte.\n\n### Neovim \u0026 [Treesiter](https://github.com/nvim-treesitter/nvim-treesitter)\n\nFor css syntax highlighting you will need the css language parser for [Treesiter](https://github.com/nvim-treesitter/nvim-treesitter). You can install it like so:\n\n```\n:TSInstall css\n```\n\n## Context based behavior\n\nAs there are more than one language in `.svelte` file, the different behaviors like mapping, completion, and local options may be expected according to tags or subtypes(current language type).\n\nThis plugin provides functions to get the tag/subtype where the cursor is in.\n\n- **GetSvelteTag() =\u003e String**: Return value is one of `'template', 'script', 'style'`.\n\n  ```vim\n  \" Example\n  autocmd FileType svelte inoremap \u003cbuffer\u003e\u003cexpr\u003e : InsertColon()\n\n  function! InsertColon()\n    let tag = GetSvelteTag()\n    return tag == 'template' ? ':' : ': '\n  endfunction\n  ```\n\n- **GetSvelteSubtype() =\u003e String**: Return value is one of `'html', 'javascript', 'css', 'scss', ...`.\n\n- **OnChangeSvelteSubtype(subtype)**: An event listener that is called when subtype changes.\n\n    You can also define an event listener function `OnChangeSvelteSubtype(subtype)` in your `vimrc` to get the subtype and set its local options whenever it changes.\n\n    ```vim\n    \" Example: set local options based on subtype\n    function! OnChangeSvelteSubtype(subtype)\n      echom 'Subtype is '.a:subtype\n      if empty(a:subtype) || a:subtype == 'html'\n        setlocal commentstring=\u003c!--%s--\u003e\n        setlocal comments=s:\u003c!--,m:\\ \\ \\ \\ ,e:--\u003e\n      elseif a:subtype =~ 'css'\n        setlocal comments=s1:/*,mb:*,ex:*/ commentstring\u0026\n      else\n        setlocal commentstring=//%s\n        setlocal comments=sO:*\\ -,mO:*\\ \\ ,exO:*/,s1:/*,mb:*,ex:*/,://\n      endif\n    endfunction\n    ```\n\n### emmet-vim\n\nCurrently emmet-vim works regarding your HTML/CSS/JavaScript emmet settings, but it depends on how emmet-vim gets `filetype` and may change in the future. Feel free to report an issue if any problem appears.\n\n## Avoid overload\n\nSince there are many sub languages included, most delays come from syntax files overload. A variable named `b:current_loading_main_syntax` is set to `svelte` which can be used as loading condition if you'd like to manually find and modify the syntax files causing overload.\n\nFor example, the builtin syntax `sass.vim` and `less.vim` in vim8.1 runtime always load `css.vim` which this plugin already loads. It can be optimized like\n\n```diff\n- runtime! syntax/css.vim\n+ if !exists(\"b:current_loading_main_syntax\")\n+   runtime! syntax/css.vim\n+ endif\n```\n\n## See also\n\n- [vim-svelte-theme][11] svelte syntax color\n- [vim-vue-plugin][3]\n- [mxw/vim-jsx][1]\n\n## License\n\nThis plugin is under [The Unlicense][8]. Other than this, `lib/indent/*` files are extracted from vim runtime.\n\n[1]: https://github.com/mxw/vim-jsx \"mxw: vim-jsx\"\n[2]: https://github.com/VundleVim/Vundle.vim\n[3]: https://github.com/leafOfTree/vim-vue-plugin\n[4]: https://github.com/digitaltoad/vim-pug\n[5]: https://github.com/tpope/vim-pathogen\n[6]: https://github.com/kchmck/vim-coffee-script\n[7]: https://github.com/junegunn/vim-plug\n[8]: https://choosealicense.com/licenses/unlicense/\n[10]: https://github.com/mattn/emmet-vim\n[11]: https://github.com/leafOfTree/vim-svelte-theme\n[12]: https://travis-ci.com/leafOfTree/vim-svelte-plugin.svg?branch=master\n[14]: https://github.com/leafgarland/typescript-vim\n[15]: https://github.com/HerringtonDarkholme/yats.vim\n","funding_links":[],"categories":["integrations","Dev Tools"],"sub_categories":["editor tools","Editors"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FleafOfTree%2Fvim-svelte-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FleafOfTree%2Fvim-svelte-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FleafOfTree%2Fvim-svelte-plugin/lists"}