{"id":13485080,"url":"https://github.com/LumaKernel/vim-tsdetect","last_synced_at":"2025-03-27T17:30:47.812Z","repository":{"id":43280531,"uuid":"339397053","full_name":"LumaKernel/vim-tsdetect","owner":"LumaKernel","description":null,"archived":false,"fork":false,"pushed_at":"2022-10-12T13:56:32.000Z","size":450,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T10:50:31.722Z","etag":null,"topics":["coc","coc-extensions","deno","luma-style","neovim","nodejs","tsserver","typescript","vim","vim-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/coc-tsdetect","language":"TypeScript","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/LumaKernel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-16T12:50:11.000Z","updated_at":"2024-10-21T10:32:09.000Z","dependencies_parsed_at":"2022-09-17T11:23:26.233Z","dependency_job_id":null,"html_url":"https://github.com/LumaKernel/vim-tsdetect","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LumaKernel%2Fvim-tsdetect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LumaKernel%2Fvim-tsdetect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LumaKernel%2Fvim-tsdetect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LumaKernel%2Fvim-tsdetect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LumaKernel","download_url":"https://codeload.github.com/LumaKernel/vim-tsdetect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245892459,"owners_count":20689506,"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":["coc","coc-extensions","deno","luma-style","neovim","nodejs","tsserver","typescript","vim","vim-plugin"],"created_at":"2024-07-31T17:01:45.224Z","updated_at":"2025-03-27T17:30:47.250Z","avatar_url":"https://github.com/LumaKernel.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# vim-tsdetect\n\n[![npm](https://img.shields.io/npm/v/coc-tsdetect?style=flat-square)](https://www.npmjs.com/package/coc-tsdetect)\n[![Luma Style Guide](https://img.shields.io/badge/styled%20with-luma-%23c5ebeb?style=flat-square)](https://github.com/luma-dev/luma-style-guide#readme)\n[![GitHub Workflow Status - CI](https://img.shields.io/github/workflow/status/LumaKernel/vim-tsdetect/CI?style=flat-square)](https://github.com/LumaKernel/vim-tsdetect/actions/workflows/ci.yml?query=branch%3Amain)\n[![Codecov](https://img.shields.io/codecov/c/github/LumaKernel/vim-tsdetect?style=flat-square)](https://app.codecov.io/gh/LumaKernel/vim-tsdetect)\n\n`vim-tsdetect`/`coc-tsdetect` provides [vim](https://github.com/vim/vim)/[neovim](https://github.com/neovim/neovim) and [`coc.nvim`](https://github.com/neoclide/coc.nvim) extension to initialize workspace automatically for [`coc-tsserver`](https://github.com/neoclide/coc-tsserver) and [`coc-deno`](https://github.com/fannheyward/coc-deno).\n\n## Installation\n\nRun `:CocInstall coc-tsdetect` in vim/neovim or install `vim-tsdetect` with your favorite plugin manager and build with `pnpm install \u0026\u0026 pnpm run build`. It is enough to install one of them.\n\n## How does this detect TS environments?\n\nChecking following in order.\n\n1. If buffer name starts with `deno:/` -\u003e **deno**  \n2. If buffer name ends with `.js`, `.ts`, `.tsx` -\u003e check following in order  \n    a. Shebang is present and including `node` -\u003e **node**  \n    b. Shebang is present and including `deno` -\u003e **deno**  \n    c. `node_modules/` directory is found in ancestors of (following) -\u003e **node**  \n        - If buffer name is not empty, search from that path.  \n        - Otherwise, search from current working directory.  \n    d. Otherwise. -\u003e **deno**  \n3. -\u003e Check following in order  \n    a. Shebang is present and including `node` -\u003e **node**  \n    b. Shebang is present and including `deno` -\u003e **deno**  \n4. Otherwise, nothing is detected.  \n\n## When does this try to detect?\n\nThis tries to detect when following events occurred.\n\n- `FileType javascript,javascriptreact,typescript,typescript.tsx,typescriptreact`\n- `BufEnter,BufNewFile,BufWritePost *`\n\n## Options\n\nPlease configure following if necessary by `:CocConfig`.\n\n### `tsdetect.mode`\n\nSet this `\"manual\"` to disable auto initialization. Variable `b:tsdetect_is_node` remains available.\n\nValues: `\"auto\" | \"manual\"`\n\nDefault:\n\n```json\n{\n  \"tsdetect.mode\": \"auto\"\n}\n```\n\n### `tsdetect.doNotCreateOnNode`\n\nBy default, in Node.js environment, tsdetect does not create a workspace configuration (`.vim/coc-settings.json`). Set this `false` to create configuration file whether the configuration exists.\n\nValues: `boolean`\n\nDefault:\n\n```json\n{\n  \"tsdetect.doNotCreateOnNode\": true\n}\n```\n\n### `tsdetect.nodeOverride`\n\nWorkspace configuration to be set in Node.js environment. If you want to extend original configuration, you need to include default ones. Not recommended to touch `deno.enable` and `tsserver.enable`.\n\nValues: `object`\n\nDefault:\n\n```json\n{\n  \"tsdetect.nodeOverride\": {\n    \"deno.lint\": false,\n    \"coc.source.file.trimSameExts\": [\n      \".js\",\n      \".ts\"\n    ],\n    \"prettier.disableLanguages\": []\n  }\n}\n```\n\n### `tsdetect.denoOverride`\n\nWorkspace configuration to be set in Deno environment. If you want to extend original configuration, you need to include default ones. Not recommended not to touch `deno.enable` and `tsserver.enable`.\n\nValues: `object`\n\nDefault:\n\n```json\n{\n  \"tsdetect.denoOverride\": {\n    \"deno.lint\": true,\n    \"coc.source.file.trimSameExts\": [],\n    \"prettier.disableLanguages\": [\n      \"javascript\",\n      \"javascriptreact\",\n      \"typescript\",\n      \"typescriptreact\"\n    ]\n  }\n}\n```\n\n## Events\n\n### `tsdetect#detect`\n\nFired when the tsdetect detects TypeScript environment in the flow shown in above.\n\n### `tsdetect#detect#node`\n\nFired when `tsdetect#detect` is fired and environment was detected as node.\n\n### `tsdetect#detect#deno`\n\nFired when `tsdetect#detect` is fired and environment was detected as deno.\n\n### `tsdetect#coc#auto#switch#node#after`\n\nFired after the automatic switch to node triggered and finished.\n\n### `tsdetect#coc#auto#switch#deno#after`\n\nFired after the automatic switch to deno triggered and finished.\n\n## Variables\n\n### `b:tsdetect_is_node`\n\nSet when `tsdetect#detect` is fired.\n\n## Limitations\n\n- Not recommended to include `deno.enable` and `tsserver.enable` settings in user configuration (`~/.vim/coc-settings.json` that can be opened by `:CocConfig`).\n- To prevent `.vim/` directory being committed by VCS, you can globally ignore `.vim/`, or ignore one by one using `git update-index --skip-worktree .vim` for git projects.\n\n## Example Configurations\n\nExample for deno.cache on save if deno environment is detected:\n```vim\nfunction! s:my_coc_tsdetect_buf_write_post() abort\n  if !get(g:, 'coc_enabled', 0)\n    return\n  endif\n  if exists('b:tsdetect_is_node') \u0026\u0026 !b:tsdetect_is_node\n    CocCommand deno.cache\n  endif\nendfunction\n\naugroup my-coc-tsdetect\n  autocmd!\n  autocmd BufWritePost * call \u003cSID\u003emy_coc_tsdetect_buf_write_post()\naugroup END\n```\n\n## LICENSE\n\n[MIT](./LICENSE)\n\n## Author\n\n[Luma](https://github.com/LumaKernel)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLumaKernel%2Fvim-tsdetect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLumaKernel%2Fvim-tsdetect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLumaKernel%2Fvim-tsdetect/lists"}