Closed dimameln closed 2 years ago
pcall
function return two value one is status two is nvim_lsp
so it should be
local ok,nvim_lsp = pcall('lspconfig')
if not ok then
do something stuff
end
nvim_lsp.tsserver.setup({})
I tried your advice, but still in tsserver not working autocomplete and codehighlight for .jsx, .js, unfortunately(
My full lspconfig.rc.lua:
local status, nvim_lsp = pcall(require, 'lspconfig') if (not status) then return end
local protocol = require('vim.lsp.protocol')
local on_attach = function(client, bufnr)
--formating
if client.server_capabilities.documentFormattingProvider then
vim.api.nvim_command [[augroup Fromat]]
vim.api.nvim_command [[autocmd! *
nvim_lsp.tsserver.setup { on_attach = on_attach, filetypes = { "typescript", "typescriptreact", "typescript.tsx", "javascript", "javascriptreact", "javascript.jsx" }, cmd = { "typescript-language-server", "--stdio" } }
nvim_lsp.sumneko_lua.setup { on_attach = on_attach, settings = { Lua = { diagnostics = { -- Get the language server to recognize the 'vim' global globals = { 'vim' } },
workspace = {
--Make the server aware of NeoVim runtime files
library = vim.api.nvim_get_runtime_file("", true)
}
}
} }
this is no need to config the filetypes. these filetype support by default. try the :LspInfo
Description
Tsserver doesn`t work for .jsx and .js
Neovim version
NVIM v0.8.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3
Nvim-lspconfig version
No response
Operating system and version
Ubuntu 22.04.1 LTS
Affected language servers
tsserver
Steps to reproduce
lspconfig.rc.lua
Actual behavior
Only works for files .tsx .ts
Expected behavior
workd for files .jsx .js .ts. tsx
Minimal config
LSP log
https://github.com/dimameln/nvim_log/blob/main/lsp.log