{"id":16639759,"url":"https://github.com/artemave/vjs","last_synced_at":"2025-10-30T09:30:51.364Z","repository":{"id":42825349,"uuid":"127455685","full_name":"artemave/vjs","owner":"artemave","description":"Missing javascript refactoring tools for nvim","archived":false,"fork":false,"pushed_at":"2023-10-06T11:14:27.000Z","size":1569,"stargazers_count":7,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-18T07:24:39.328Z","etag":null,"topics":["javascript","vim","vim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/artemave.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}},"created_at":"2018-03-30T17:36:04.000Z","updated_at":"2023-11-08T15:36:59.000Z","dependencies_parsed_at":"2023-01-31T17:16:35.425Z","dependency_job_id":null,"html_url":"https://github.com/artemave/vjs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemave%2Fvjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemave%2Fvjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemave%2Fvjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/artemave%2Fvjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/artemave","download_url":"https://codeload.github.com/artemave/vjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236766724,"owners_count":19201412,"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":["javascript","vim","vim-plugin"],"created_at":"2024-10-12T07:06:58.288Z","updated_at":"2025-10-30T09:30:46.035Z","avatar_url":"https://github.com/artemave.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vjs [![CircleCI](https://circleci.com/gh/artemave/vjs.svg?style=svg)](https://circleci.com/gh/artemave/vjs)\n\n## What is this?\n\nA Neovim plugin that adds a bunch of refactoring tools for Javascript/TypeScript. Namely:\n\n- extract variable\n- extract function/method\n- extract class/function/variable declaration into a separate file\n- declare undefined variable/method/function/class\n- list imports for current file\n- update imports when moving file (also works in NERDTree)\n- autocomplete `require`/`import` paths\n- turn a string into a template string once `${}` detected\n\n## Installation\n\nRequires [treesitter](https://github.com/nvim-treesitter/nvim-treesitter).\n\nUse [a plugin manager](https://github.com/junegunn/vim-plug):\n\n```vim script\nPlug 'artemave/vjs'\n```\n\n## Usage\n\n#### Complete import/require paths\n\nVjs comes with an `omnifunc` for `require`/`import` path completion:\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/80413735-38752d80-88d0-11ea-8030-de1b17ee4796.gif\" loading=\"lazy\" width=550\u003e\n\nSet it up:\n\n```viml\nautocmd FileType {javascript,typescript} setlocal omnifunc=vjs#ModuleComplete\n```\n\n#### `:VjsRenameFile`\n\nRename/move file and update imports. It updates both imports in current file and all files that import current file.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/82894765-62fbea00-9f53-11ea-8a64-d3bd123fe553.gif\" loading=\"lazy\" width=550\u003e\n\nIt's also possible to batch rename files by calling `vjs#imports#RenameFile` directly. For example, assuming there is a bunch of `.mjs` files in quickfix window that I want to rename to `.jsx`, the following command will perform batch rename and update all the imports:\n\n```\n:cdo call vjs#imports#RenameFile({ 'new_name': expand('%:r') . '.jsx' })\n```\n\nThere is an experimental integration with [NERDTree](https://github.com/preservim/nerdtree) project explorer. Renaming/moving javascript/typescript files in NERDTree automatically updates imports ([watch demo](https://www.veed.io/view/823c1c54-fbaf-4c6e-97a4-5a89203a1e07?panel=share)).\n\n#### `:'\u003c,'\u003eVjsExtractVariable`\n\nExtracts selected code into a variable.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/80576166-01ecff00-8a05-11ea-8826-01ae86e227e1.gif\" loading=\"lazy\" width=550\u003e\n\n#### `:'\u003c,'\u003eVjsExtractFunctionOrMethod`\n\nExtracts selected code into a global function.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/80576556-b38c3000-8a05-11ea-8be8-5b1b18e5ac87.gif\" loading=\"lazy\" width=550\u003e\n\n#### `:ExtractDeclarationIntoFile`\n\nExtracts enclosing function/class into a separate file. Inserts import into the original file.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/87256789-ef2b8780-c495-11ea-84ff-ed8d10fdec1f.gif\" loading=\"lazy\" width=550\u003e\n\n#### `:VjsCreateDeclaration`\n\nIf a reference under cursor happens to be undefined, this will insert a declaration for it. The appropriate declaration - variable, class or function - is automatically picked.\n\nIn a similar manner, if a method/property is not defined for `this` in the current scope, this will insert its declaration.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/87256609-7b3caf80-c494-11ea-97aa-868b245dfd85.gif\" loading=\"lazy\" width=550\u003e\n\n#### `:VjsListDependents`\n\nShows list of modules that require/import current file in quickfix window.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/23721/80421625-0f0ece80-88dd-11ea-8057-93ff00adbf3e.gif\" loading=\"lazy\" width=550\u003e\n\n#### Template strings\n\nVjs can automatically convert normal string to template string once the string contains `${}`. To enable this:\n\n```viml\nautocmd TextChanged * if \u0026ft =~ 'javascript\\|typescript' | call luaeval(\"require'vjs'.to_template_string()\") | endif\nautocmd InsertLeave * if \u0026ft =~ 'javascript\\|typescript' | call luaeval(\"require'vjs'.to_template_string()\") | endif\n```\n\n#### npm workspaces support\n\nImport update on rename, list dependants and `gf` follow package references. E.g, in the following example, pressing `gf` when the cursor is within `'abc'` in `./lib/index.js`, jumps to `./packages/abc/index.js`:\n\n```js\n// ./packages/abc/index.js\nmodule.exports = 'abc'\n\n// ./lib/index.js\nconst moduleA = require('abc')\n```\n\n### Example bindings\n\nThere are no default bindings. But you can use these:\n\n```vim script\nau FileType {javascript,javascript.jsx,typescript} vmap \u003cleader\u003evv :VjsExtractVariable\u003ccr\u003e\nau FileType {javascript,javascript.jsx,typescript} vmap \u003cleader\u003evf :VjsExtractFunctionOrMethod\u003ccr\u003e\nau FileType {javascript,javascript.jsx,typescript} nmap \u003cleader\u003eve :VjsExtractDeclarationIntoFile\u003ccr\u003e\nau FileType {javascript,javascript.jsx,typescript} nmap \u003cleader\u003evd :VjsCreateDeclaration\u003ccr\u003e\nau FileType {javascript,javascript.jsx,typescript} nmap \u003cleader\u003evr :VjsRenameFile\u003ccr\u003e\nau FileType {javascript,javascript.jsx,typescript} nmap \u003cleader\u003evl :VjsListDependents\u003ccr\u003e\n```\n\nIf you don't like binding explosion, then perhaps you could add those as code actions via [null-ls](https://github.com/jose-elias-alvarez/null-ls.nvim).\n\n### Configuration\n\n`g:vjs_es_modules_complete` - don't strip out file extension from autocompleted modules and also show `index` modules. Defaults to `0`.\n\n`g:vjs_nerd_tree_overriden` - if truthy, disables nerdtree integration. Defaults to `0`.\n\n## Development\n\n```\ngit clone https://github.com/artemave/vjs.git\ncd vjs\n./run_tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemave%2Fvjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fartemave%2Fvjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fartemave%2Fvjs/lists"}