-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsserver.lua
More file actions
71 lines (66 loc) · 2.44 KB
/
tsserver.lua
File metadata and controls
71 lines (66 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local util = require("conf.lsp.util")
local M = {}
M.setup = function()
require("typescript/config").setupConfig({})
vim.api.nvim_create_autocmd("FileType", {
pattern = table.concat({
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
}, ","),
callback = function(data)
vim.lsp.start({
name = "tsserver",
cmd = { "typescript-language-server", "--stdio" },
root_dir = util.find_root_dir({ ".git" }, data.file) or util.find_root_dir({
"package.json",
"tsconfig.json",
"jsconfig.json",
}, data.file) or vim.fn.getcwd(),
init_options = { hostInfo = "neovim" },
handlers = vim.tbl_extend("force", util.get_handlers(), {
["_typescript.rename"] = require("typescript/handlers").renameHandler,
}),
capabilities = util.get_capabilities(),
on_init = function(client, _)
client.notify("workspace/didChangeConfiguration", {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
})
end,
on_attach = function(client, bufnr)
util.disable_formatting(client)
if not require("typescript/config").config.disable_commands then
require("typescript/commands").setupCommands(bufnr)
end
end,
})
end,
})
end
return M