├── LICENSE ├── README.md ├── autoload └── svelte_inspector.vim ├── launch_editor.sh └── lua └── svelte_inspector.lua /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2023 Ryotaro "Justin" Kimura 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-svelte-inspector 2 | 3 | 4 | https://github.com/ryoppippi/sveltekit_inspector.vim/assets/1560508/4b8a3903-3339-43d2-817a-2ff246b81416 5 | 6 | 7 | 8 | Based on [this article](https://theosteiner.de/open-neovim-from-your-browser-integrating-nvim-with-sveltes-inspector) 9 | You can learn how to use the inspector from [the official readme](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#inspector) 10 | 11 | ## Dependencies 12 | You need to install 13 | - [flatten.nvim](https://github.com/willothy/flatten.nvim) or [guice.vim](https://github.com/lambdalisue/guise.vim/tree/main) 14 | - [fileline.nvim](https://github.com/lewis6991/fileline.nvim), [File-line](https://github.com/bogado/file-line) or [vim-fetch](https://github.com/wsdjeg/vim-fetch) 15 | - [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) 16 | 17 | ## Config 18 | 19 | Setup with your favorite plugin manager: 20 | 21 | vim script: 22 | ```vim 23 | svelte_inspector#setup() 24 | ``` 25 | 26 | lua: 27 | ```lua 28 | require("svelte_inspector").setup() 29 | ``` 30 | 31 | This is my config with lazy.nvim 32 | ```lua 33 | return { 34 | "ryoppippi/vim-svelte-inspector", 35 | dependencies = { 36 | "willothy/flatten.nvim", 37 | "lewis6991/fileline.nvim", 38 | "nvim-lua/plenary.nvim", 39 | }, 40 | lazy = false, 41 | config = true, 42 | } 43 | ``` 44 | 45 | Then, enable inspector in `svelte.config.js`: 46 | 47 | ```js 48 | export default { 49 | vitePlugin: { 50 | inspector: true 51 | } 52 | }; 53 | ``` 54 | 55 | # Limitation 56 | - Only works in vim terminal 57 | 58 | # License 59 | MIT 60 | -------------------------------------------------------------------------------- /autoload/svelte_inspector.vim: -------------------------------------------------------------------------------- 1 | function! svelte_inspector#setup() 2 | let $CURRENT_EDITOR_FOR_SVELTE_INSPECTOR_VIM = has("nvim") == 1 ? "nvim" : "vim" 3 | let $LAUNCH_EDITOR = fnamemodify(expand(''), ":h:h") .. "/launch_editor.sh" 4 | endfunction 5 | 6 | -------------------------------------------------------------------------------- /launch_editor.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | filename=$1 3 | line=${2:-"1"} 4 | column=${3:-"1"} 5 | $CURRENT_EDITOR_FOR_SVELTE_INSPECTOR_VIM $filename:$line:$column 6 | -------------------------------------------------------------------------------- /lua/svelte_inspector.lua: -------------------------------------------------------------------------------- 1 | local Path = require("plenary.path") 2 | 3 | local M = {} 4 | function M.setup() 5 | vim.env.CURRENT_EDITOR_FOR_SVELTE_INSPECTOR_VIM = vim.fn.has("nvim") == 1 and "nvim" or "vim" 6 | vim.env.LAUNCH_EDITOR = Path:new(debug.getinfo(1).source:sub(2)):parent():parent() .. "/launch_editor.sh" 7 | end 8 | 9 | return M 10 | --------------------------------------------------------------------------------