feat(extras): configure nvim-vtsls

This commit is contained in:
Feliche-Demian Netliukh 2024-03-31 10:29:30 +01:00
parent 6f404064e0
commit 7349089511

View file

@ -14,9 +14,63 @@ return {
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = function(_, opts) opts = function(_, opts)
vim.list_extend(opts.servers, { -- set default server config to use nvim-vtsls one, which would allow use to use the plugin
require("lspconfig.configs").vtsls = require("vtsls").lspconfig
-- ---@type lspconfig.options.vtsls -- ---@type lspconfig.options.vtsls
vtsls = { opts.servers.vtsls = {
-- you can view all keys here: https://github.com/yioneko/nvim-vtsls#commands
-- keys = {
-- {
-- "<leader>cto",
-- function()
-- require("vtsls").commands.organize_imports(0)
-- end,
-- desc = "Organize Imports",
-- },
-- {
-- "<leader>ctm",
-- function()
-- require("vtsls").commands.add_missing_imports(0)
-- end,
-- desc = "Add missing imports",
-- },
-- {
-- "<leader>ctd",
-- function()
-- require("vtsls").commands.fix_all(0)
-- end,
-- desc = "Fix all diagnostics",
-- },
-- {
-- "<leader>ctl",
-- function()
-- require("vtsls").commands.open_tsserver_log()
-- end,
-- desc = "Open Log",
-- },
-- {
-- "<leader>ctR",
-- function()
-- require("vtsls").commands.rename_file(0)
-- end,
-- desc = "Rename File",
-- },
-- {
-- "<leader>ctr",
-- function()
-- require("vtsls").commands.file_references(0)
-- end,
-- desc = "Show Rile References",
-- },
-- {
-- "<leader>ctc",
-- function()
-- require("vtsls").commands.goto_project_config(0)
-- end,
-- desc = "Open project config",
-- },
-- },
settings = { settings = {
vtsls = { vtsls = {
experimental = { experimental = {
@ -31,10 +85,24 @@ return {
convertTabsToSpaces = vim.o.expandtab, convertTabsToSpaces = vim.o.expandtab,
tabSize = vim.o.tabstop, tabSize = vim.o.tabstop,
}, },
-- enables inline hints
inlayHints = {
parameterNames = { enabled = "literals" },
parameterTypes = { enabled = true },
variableTypes = { enabled = true },
propertyDeclarationTypes = { enabled = true },
functionLikeReturnTypes = { enabled = true },
enumMemberValues = { enabled = true },
},
-- otherwise it would ask every time if you want to update imports, which is a bit annoying -- otherwise it would ask every time if you want to update imports, which is a bit annoying
updateImportsOnFileMove = { updateImportsOnFileMove = {
enabled = "always", enabled = "always",
}, },
-- cool feature, but increases ram usage
-- referencesCodeLens = {
-- enabled = true,
-- showOnAllFunctions = true,
-- },
}, },
typescript = { typescript = {
format = { format = {
@ -42,6 +110,9 @@ return {
convertTabsToSpaces = vim.o.expandtab, convertTabsToSpaces = vim.o.expandtab,
tabSize = vim.o.tabstop, tabSize = vim.o.tabstop,
}, },
updateImportsOnFileMove = {
enabled = "always",
},
inlayHints = { inlayHints = {
parameterNames = { enabled = "literals" }, parameterNames = { enabled = "literals" },
parameterTypes = { enabled = true }, parameterTypes = { enabled = true },
@ -50,21 +121,15 @@ return {
functionLikeReturnTypes = { enabled = true }, functionLikeReturnTypes = { enabled = true },
enumMemberValues = { enabled = true }, enumMemberValues = { enabled = true },
}, },
updateImportsOnFileMove = {
enabled = "always",
},
-- cool feature, but increases ram usage a lot
-- referencesCodeLens = {
-- enabled = true,
-- showOnAllFunctions = true,
-- },
}, },
}, },
}, }
})
end, end,
dependencies = { dependencies = {
{
"yioneko/nvim-vtsls", "yioneko/nvim-vtsls",
handlers = {},
},
}, },
}, },
{ {