I'm working on a TypeScript-React project using neovim, because I love it. I want a feature: when my cursor is on a name that has not been imported, I can press some key-combination to choose which library I would like to import. E.g.
Input:
import { Head } from "next/head"
import { Another } from "./another"
export default function Home() {
const foo = <Another/>
return (
<div className="container">
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
</Head>
Output:
import { Head } from "next/head"
export default function Home() {
const foo = <Another/>
return (
<div className="container">
<Head>
<title>Create Next App</title>
<link rel="icon" href="/favicon.ico" />
</Head>
What I've tried:
- I installed a plugin, vim-import-js, that works well on importing javascript module. But it doesn't work on
.ts
and.tsx
.
I know very little about Lua, LSP, .tsconfig.json
, and eslintrc.js
. It seems like these files also need to be set to make these plugins to work. I will also appreciate if you can provide more context on how these settings are referenced to make things work.