kirilligum
kirilligum•10mo ago

lvim tsx language server

after i clone fresh example in deno deploy, I get an error "Cannot find name 'React' " while opening routes/index.tsx with lunar vim how can i solve this?
No description
5 Replies
Deno AI Helper
Deno AI Helper•10mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message "Cannot find name 'React'", it seems like the issue might be related to TypeScript not recognizing the React namespace or not having the appropriate type definitions for React. Here are a couple of things you might want to check: 1. Ensure that you have the React and ReactDOM type definitions installed. These are usually included if you have a deps.ts file that imports React in a Deno project. 2. Check if your tsconfig.json (if you have one) is properly configured to include JSX support. You might need to set the jsx option to "react" and jsxFactory to React.createElement if you're using React without any JSX transform. 3. Make sure that you are importing React in your routes/index.tsx file. You should have a line at the top of the file that says:
import React from 'https://cdn.skypack.dev/react';

import React from 'https://cdn.skypack.dev/react';

or a similar import that suits your project setup. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. Since you're using LunarVim, which is an environment for Neovim, ensure that your language server is properly configured for Deno and TypeScript. You might also want to check the LunarVim documentation or community for more specific guidance on setting up TypeScript and React support.
Shiddy
Shiddy•2mo ago
@kirilligum Did you ever find a solution to this? I found that if I was using the denols LSP and the tsserver LSP I had to add the following arguments to the setup() calls: https://docs.deno.com/runtime/manual/getting_started/setup_your_environment/#neovim-0.6%2B-using-the-built-in-language-server
kirilligum
kirilligum•2mo ago
that's really cool. I'll give deno in lvim a try again 🤞😀
Lewis Campbell
Lewis Campbell•2mo ago
can you share your init.lua? struggling with this right now, didn't work for me
Shiddy
Shiddy•2mo ago
@Lewis Campbell
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = {"denols"},
})
end,
},
{
"neovim/nvim-lspconfig",
config = function()
local lspconfig = require("lspconfig")
lspconfig.denols.setup({
})
end,
},
}
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = {"denols"},
})
end,
},
{
"neovim/nvim-lspconfig",
config = function()
local lspconfig = require("lspconfig")
lspconfig.denols.setup({
})
end,
},
}
fwiw I only use the denols LSP and it works as expected one thing that you can do if you have a library that is returning react elements you might have to alias the outputs for preact import { BLAH } from 'https://esm.sh/@whatever/library?alias=react:preact/compat&alias=external:preact/compat'; to be fair I don't write lua or javascript so this is what I have learned just reading through the docs thus far