Updated ts-tools to use node modules bin if there

Updated neovim project back to main repo
This commit is contained in:
2024-03-25 15:58:32 +01:00
parent 1fef045f35
commit fd4133ff85
2 changed files with 16 additions and 11 deletions

View File

@@ -6,12 +6,7 @@ return {
"neovim/nvim-lspconfig",
"hrsh7th/cmp-nvim-lsp",
},
ft = {
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
},
event = { "BufReadPre", "BufNewFile" },
config = function()
local typescript_tools = require("typescript-tools")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
@@ -20,6 +15,16 @@ return {
local capabilities = cmp_nvim_lsp.default_capabilities()
local augroup = vim.api.nvim_create_augroup("Typescript_tools", {})
local cwd = vim.fn.getcwd()
local tsserver_path = cwd .. "/node_modules/.bin/tsserver"
local cmd = ""
if vim.loop.fs_stat(tsserver_path) then
cmd = tsserver_path
else
cmd = "typescript-language-server"
end
typescript_tools.setup({
capabilities = capabilities,
on_attach = function(client, bufnr)
@@ -32,8 +37,12 @@ return {
vim.lsp.buf.format({ async = false })
end,
})
if cmd == "typescript-language-server" then
print("Using global tsserver")
end
end,
settings = {
cmd = { cmd, "--stdio" },
tsserver_file_preferences = {
includeCompletionsForModuleExports = true,
quotePreference = "auto",