From 657a1cdc068025773dcd6c294e0cfad99c3960c1 Mon Sep 17 00:00:00 2001 From: "markus.dieckmann" Date: Fri, 23 May 2025 11:08:07 +0200 Subject: [PATCH] trying to enable inlayhints for vtsls --- nvim/lua/plugins/lsp.lua | 58 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 59df22f..9440d3d 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -4,8 +4,23 @@ return { { "williamboman/mason.nvim", opts = {} }, "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", + "yioneko/nvim-vtsls", + opts = { + settings = { + typescript = { + inlayHints = { + parameterNames = { enabled = "literals" }, + parameterTypes = { enabled = true }, + variableTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + enumMemberValues = { enabled = true }, + }, + }, + }, + }, - { "j-hui/fidget.nvim", opts = {} }, + { "j-hui/fidget.nvim", opts = {} }, "saghen/blink.cmp", }, @@ -14,6 +29,8 @@ return { diagnostics = { virtual_text = true }, }, config = function() + inlay_hints = { enabled = true } + diagnostics = { virtual_text = true } vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), callback = function(event) @@ -70,7 +87,7 @@ return { local client = vim.lsp.get_client_by_id(event.data.client_id) if - client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) + client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { @@ -161,13 +178,44 @@ return { rust_analyzer = {}, vtsls = { - settings = {}, + -- explicitly add default filetypes, so that we can extend + -- them in related extras + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + settings = { + typescript = { + updateImportsOnFileMove = { enabled = "always" }, + inlayHints = { + parameterNames = { enabled = "literals" }, + parameterTypes = { enabled = true }, + variableTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + enumMemberValues = { enabled = true }, + }, + suggest = { + completeFunctionCalls = true, + }, + }, + }, }, - bashls = {}, prismals = {}, gopls = {}, jsonls = {}, + eslint = { + vim.api.nvim_create_autocmd("BufWritePre", { + callback = function() + vim.lsp.buf.format() + end, + }), + }, lua_ls = { -- cmd = { ... }, -- filetypes = { ... }, @@ -183,11 +231,11 @@ return { }, }, } + local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { "stylua", -- Used to format Lua code "prettierd", - "eslint", "codelldb", "gitlab_ci_ls", "js-debug-adapter",