comments(nvim): add tsserver variable annotation
This commit is contained in:
1 parent
3f062011c5
commit
3be72c24bc
7 files changed
+134
-78
No files matched your search
@@ -1,12 +1,5 @@
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
if type(opts.ensure_installed) == "table" then
|
||||
vim.list_extend(opts.ensure_installed, { "yaml" })
|
||||
end
|
||||
end,
|
||||
},
|
||||
{ import = "lazyvim.plugins.extras.lang.yaml" },
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
|
||||
@@ -49,14 +49,38 @@ return {
|
||||
"cssmodules-language-server",
|
||||
"css-lsp",
|
||||
"htmlhint",
|
||||
"stylelint",
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
opts = function(_, opts)
|
||||
opts.linters_by_ft.html = opts.linters_by_ft.html or {}
|
||||
table.insert(opts.linters_by_ft.html, "htmlhint")
|
||||
local stylelint = "stylelint"
|
||||
|
||||
local function add_linters(tbl)
|
||||
for ft, linters in pairs(tbl) do
|
||||
if opts.linters_by_ft[ft] == nil then
|
||||
opts.linters_by_ft[ft] = linters
|
||||
else
|
||||
vim.list_extend(opts.linters_by_ft[ft], linters)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_linters({
|
||||
["html"] = { "htmlhint" },
|
||||
["css"] = { stylelint },
|
||||
["scss"] = { stylelint },
|
||||
["less"] = { stylelint },
|
||||
["sugarss"] = { stylelint },
|
||||
["vue"] = { stylelint },
|
||||
["wxss"] = { stylelint },
|
||||
["javascript"] = { stylelint },
|
||||
["javascriptreact"] = { stylelint },
|
||||
["typescript"] = { stylelint },
|
||||
["typescriptreact"] = { stylelint },
|
||||
})
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
local source_action = function(name)
|
||||
return function()
|
||||
vim.lsp.buf.code_action({
|
||||
apply = true,
|
||||
context = {
|
||||
only = { string.format("source.%s.ts", name) },
|
||||
diagnostics = {},
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
local ts_server_activated = true -- Change this variable to false if you want to use typescript-tools instead of lspconfig tsserver implementation
|
||||
local ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" }
|
||||
|
||||
local inlayHints = {
|
||||
includeInlayParameterNameHints = "all",
|
||||
@@ -21,17 +12,16 @@ local inlayHints = {
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
}
|
||||
|
||||
local function denoConfigExists()
|
||||
local configs = { "deno.json", "deno.jsonc" }
|
||||
local root = require("lazyvim.util.root").get()
|
||||
|
||||
for _, config in ipairs(configs) do
|
||||
if vim.fn.filereadable(root .. "/" .. config) == 1 then
|
||||
return true
|
||||
end
|
||||
local source_action = function(name)
|
||||
return function()
|
||||
vim.lsp.buf.code_action({
|
||||
apply = true,
|
||||
context = {
|
||||
only = { string.format("source.%s.ts", name) },
|
||||
diagnostics = {},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return {
|
||||
@@ -49,6 +39,7 @@ return {
|
||||
opts = {
|
||||
servers = {
|
||||
tsserver = {
|
||||
enabled = ts_server_activated,
|
||||
init_options = {
|
||||
preferences = {
|
||||
disableSuggestions = true,
|
||||
@@ -82,13 +73,44 @@ return {
|
||||
},
|
||||
denols = {},
|
||||
},
|
||||
setup = {
|
||||
tsserver = function(_, opts)
|
||||
-- Disable tsserver if denols is present
|
||||
return denoConfigExists()
|
||||
end,
|
||||
},
|
||||
},
|
||||
{
|
||||
"pmizio/typescript-tools.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||
enabled = not ts_server_activated,
|
||||
ft = ft,
|
||||
opts = {
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
settings = {
|
||||
code_lens = "all",
|
||||
expose_as_code_action = "all",
|
||||
tsserver_plugins = {
|
||||
"@styled/typescript-styled-plugin",
|
||||
},
|
||||
tsserver_file_preferences = {
|
||||
completions = {
|
||||
completeFunctionCalls = true,
|
||||
},
|
||||
init_options = {
|
||||
preferences = {
|
||||
disableSuggestions = true,
|
||||
},
|
||||
},
|
||||
includeInlayParameterNameHints = "all",
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>co", ft = ft, "<cmd>TSToolsOrganizeImports<cr>", desc = "Organize Imports" },
|
||||
{ "<leader>cR", ft = ft, "<cmd>TSToolsRemoveUnusedImports<cr>", desc = "Remove Unused Imports" },
|
||||
{ "<leader>cM", ft = ft, "<cmd>TSToolsAddMissingImports<cr>", desc = "Add Missing Imports" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
local stylelint = "stylelint"
|
||||
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { stylelint })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
opts = function(_, opts)
|
||||
local function add_linters(tbl)
|
||||
for ft, linters in pairs(tbl) do
|
||||
if opts.linters_by_ft[ft] == nil then
|
||||
opts.linters_by_ft[ft] = linters
|
||||
else
|
||||
vim.list_extend(opts.linters_by_ft[ft], linters)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_linters({
|
||||
["html"] = { "stylelint" },
|
||||
["css"] = { "stylelint" },
|
||||
["scss"] = { "stylelint" },
|
||||
["sass"] = { "stylelint" },
|
||||
["less"] = { "stylelint" },
|
||||
})
|
||||
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user