Tsserver and denolsp conflict #597
-
Hi. ive been trying to set up lsp and cmp for 2 days and one issue i keep coming back to is tsserver and denolsp conflicting on typescript projects ive looked at configs from a bunch of places ill list them here so you know where im coming from and what ive tried.
i cant seem to get any of these to work on their own or in concert and its killing my mind. please help. here are the important files for the configs.
--lsp zero
local lsp=require('lsp-zero')
lsp.preset("recommended")
lsp.nvim_workspace()
lsp.setup()
-- lsp install
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.settings({
install_root_dir = string.gsub((vim.fn.system("echo $HOME") .. "/.config/nvim/.lsp_servers"), "\n", "")
})
lsp_installer.on_server_ready(function(server)
local opts={
on_attach = require("lsp.handlers").on_attach,
capabilities = require("lsp.handlers").capabilities
}
local opts_exist, server_opts = pcall(require, "lsp.settings.".. server.name)
if opts_exist then
opts = vim.tbl_deep_extend("force", server_opts, opts)
end
server:setup(opts)
end
)
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local capabilities = vim.lsp.protocol.make_client_capabilities()
return {
on_attach = function(client, bufnr)
if client.name == "tsserver" then
client.resolved_capabilities.document_formatting = false
end
end,
capabilities = cmp_nvim_lsp.update_capabilities(capabilities),
}
local util = require "lspconfig.util"
local bin_name = 'typescript-language-server'
local cmd = { bin_name, '--stdio' }
return{
default_config ={
init_options={
hostInfo = 'neovim'
},
cmd = cmd,
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
},
root_dir = function () util.root_pattern("package.json") end
}
} for full configs in context to the rest of neovim configs, please look here: https://github.com/Lite5h4dow/.dotfiles/tree/master/.config/nvim
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Hello! I'm afraid I'm not following what exactly the problem is? |
Beta Was this translation helpful? Give feedback.
-
DONT WRAP YOUR CONFIGS IN |
Beta Was this translation helpful? Give feedback.
-
lsp_installer.on_server_ready(function(server)
elseif server.name == "denols" then
--local settings = require("deno-tool").read()
local opts = {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("deno.json"),
init_options = { --settings,
lint = true,
},
}
server:setup(opts)
elseif server.name == "tsserver" then
local opts = {
on_attach = on_attach,
root_dir = nvim_lsp.util.root_pattern("package.json"),
init_options = {
lint = true,
},
}
server:setup(opts)
else
local opts = {
on_attach = on_attach,
}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end
end) You can set Like this , just config it like nvim-lspconfig wiki said, change the rootpattern |
Beta Was this translation helpful? Give feedback.
DONT WRAP YOUR CONFIGS IN
default_config
, LSPCONFIG IS LYING WITH THE EXAMPLES.