-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
typescript.lua
112 lines (107 loc) · 3.31 KB
/
typescript.lua
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
local utils = require "astronvim.utils"
local function on_file_remove(args)
local ts_clients = vim.lsp.get_active_clients { name = "tsserver" }
for _, ts_client in ipairs(ts_clients) do
ts_client.request("workspace/executeCommand", {
command = "_typescript.applyRenameFile",
arguments = {
{
sourceUri = vim.uri_from_fname(args.source),
targetUri = vim.uri_from_fname(args.destination),
},
},
})
end
end
return {
{ import = "astrocommunity.pack.json" },
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "javascript", "typescript", "tsx" })
end
end,
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "tsserver") end,
},
{
"jay-babu/mason-null-ls.nvim",
opts = function(_, opts)
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "prettierd", "eslint_d" })
if not opts.handlers then opts.handlers = {} end
opts.handlers.prettierd = function()
local null_ls = require "null-ls"
null_ls.register(null_ls.builtins.formatting.prettierd.with {
condition = function(util)
return util.root_has_file "package.json"
or util.root_has_file ".prettierrc"
or util.root_has_file ".prettierrc.json"
or util.root_has_file ".prettierrc.js"
end,
})
end
opts.handlers.eslint_d = function()
local null_ls = require "null-ls"
null_ls.register(null_ls.builtins.diagnostics.eslint_d.with {
condition = function(util)
return util.root_has_file "package.json"
or util.root_has_file ".eslintrc.json"
or util.root_has_file ".eslintrc.js"
end,
})
end
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "js") end,
},
{
"vuki656/package-info.nvim",
requires = "MunifTanjim/nui.nvim",
config = true,
event = "BufRead package.json",
},
{
"jose-elias-alvarez/typescript.nvim",
init = function() astronvim.lsp.skip_setup = utils.list_insert_unique(astronvim.lsp.skip_setup, "tsserver") end,
ft = {
"typescript",
"typescriptreact",
"javascript",
"javascriptreact",
},
opts = function() return { server = require("astronvim.utils.lsp").config "tsserver" } end,
},
{
"jose-elias-alvarez/null-ls.nvim",
opts = function(_, opts)
opts.sources = utils.list_insert_unique(opts.sources, require "typescript.extensions.null-ls.code-actions")
end,
},
{
"nvim-neo-tree/neo-tree.nvim",
opts = function(_, opts)
local events = require "neo-tree.events"
opts.event_handlers = {
{
event = events.FILE_MOVED,
handler = on_file_remove,
},
{
event = events.FILE_RENAMED,
handler = on_file_remove,
},
}
end,
},
{
"dmmulroy/tsc.nvim",
filetype = "typescript",
event = "User AstroFile",
config = function() require("tsc").setup() end,
},
}