feat: add TypeScript, Vue.js and ESLint support with LSP, formatter and treesitter

- Add vtsls LSP with @vue/typescript-plugin for Vue hybrid mode
- Add vue_ls (Volar) for Vue 3 SFC support
- Add ESLint LSP for real-time linting
- Configure prettierd formatter for JS/TS/Vue/CSS/HTML/JSON via conform.nvim
- Add nvim-ts-autotag for auto-close/rename HTML and Vue tags
- Extend treesitter parsers: typescript, tsx, javascript, vue, css, json
- Add Mason ensure_installed for all new tools
This commit is contained in:
Maxime Pierront 2026-02-14 12:57:56 +01:00
parent 8eac473ad8
commit 1a776b3be1
1 changed files with 54 additions and 16 deletions

View File

@ -618,17 +618,44 @@ require('lazy').setup({
-- Enable the following language servers -- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
-- See `:help lsp-config` for information about keys and how to configure -- See `:help lsp-config` for information about keys and how to configure
-- Path to Vue language server for the TypeScript plugin
local vue_language_server_path = vim.fn.stdpath 'data' .. '/mason/packages/vue-language-server/node_modules/@vue/language-server'
local servers = { local servers = {
-- clangd = {}, -- clangd = {},
-- gopls = {}, -- gopls = {},
-- pyright = {}, -- pyright = {},
-- rust_analyzer = {}, -- rust_analyzer = {},
--
-- Some languages (like typescript) have entire language plugins that can be useful: vtsls = {
-- https://github.com/pmizio/typescript-tools.nvim settings = {
-- vtsls = {
-- But for many setups, the LSP (`ts_ls`) will work just fine -- Enable auto-use of workspace TypeScript version
-- ts_ls = {}, autoUseWorkspaceTsdk = true,
tsserver = {
globalPlugins = {
{
name = '@vue/typescript-plugin',
location = vue_language_server_path,
languages = { 'vue' },
configNamespace = 'typescript',
},
},
},
},
},
-- Include vue so vtsls attaches to .vue files for TypeScript support
filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'vue' },
},
vue_ls = {},
eslint = {
settings = {
-- Auto-fix on save
run = 'onSave',
},
},
} }
-- Ensure the servers and tools above are installed -- Ensure the servers and tools above are installed
@ -638,12 +665,14 @@ require('lazy').setup({
-- :Mason -- :Mason
-- --
-- You can press `g?` for help in this menu. -- You can press `g?` for help in this menu.
local ensure_installed = vim.tbl_keys(servers or {}) local ensure_installed = {
vim.list_extend(ensure_installed, {
'lua-language-server', -- Lua Language server 'lua-language-server', -- Lua Language server
'stylua', -- Used to format Lua code 'stylua', -- Used to format Lua code
-- You can add other tools here that you want Mason to install 'vtsls', -- TypeScript/JavaScript LSP
}) 'vue-language-server', -- Vue.js LSP (Volar)
'eslint-lsp', -- ESLint LSP
'prettierd', -- Prettier daemon (formatter)
}
require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-tool-installer').setup { ensure_installed = ensure_installed }
@ -712,11 +741,14 @@ require('lazy').setup({
end, end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially javascript = { 'prettierd', 'prettier', stop_after_first = true },
-- python = { "isort", "black" }, javascriptreact = { 'prettierd', 'prettier', stop_after_first = true },
-- typescript = { 'prettierd', 'prettier', stop_after_first = true },
-- You can use 'stop_after_first' to run the first available formatter from the list typescriptreact = { 'prettierd', 'prettier', stop_after_first = true },
-- javascript = { "prettierd", "prettier", stop_after_first = true }, vue = { 'prettierd', 'prettier', stop_after_first = true },
css = { 'prettierd', 'prettier', stop_after_first = true },
html = { 'prettierd', 'prettier', stop_after_first = true },
json = { 'prettierd', 'prettier', stop_after_first = true },
}, },
}, },
}, },
@ -875,13 +907,19 @@ require('lazy').setup({
end, end,
}, },
{ -- Auto-close and auto-rename HTML/Vue tags
'windwp/nvim-ts-autotag',
event = { 'BufReadPre', 'BufNewFile' },
opts = {},
},
{ -- Highlight, edit, and navigate code { -- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', build = ':TSUpdate',
config = function() config = function()
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, ensure_installed = { 'bash', 'c', 'css', 'diff', 'html', 'javascript', 'json', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'tsx', 'typescript', 'vim', 'vimdoc', 'vue' },
auto_install = true, auto_install = true,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },