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
-- 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
-- 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 = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
vtsls = {
settings = {
vtsls = {
-- Enable auto-use of workspace TypeScript version
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
@ -638,12 +665,14 @@ require('lazy').setup({
-- :Mason
--
-- You can press `g?` for help in this menu.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
local ensure_installed = {
'lua-language-server', -- Lua Language server
'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 }
@ -712,11 +741,14 @@ require('lazy').setup({
end,
formatters_by_ft = {
lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
javascript = { 'prettierd', 'prettier', stop_after_first = true },
javascriptreact = { 'prettierd', 'prettier', stop_after_first = true },
typescript = { 'prettierd', 'prettier', stop_after_first = true },
typescriptreact = { '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,
},
{ -- Auto-close and auto-rename HTML/Vue tags
'windwp/nvim-ts-autotag',
event = { 'BufReadPre', 'BufNewFile' },
opts = {},
},
{ -- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function()
---@diagnostic disable-next-line: missing-fields
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,
highlight = { enable = true },
indent = { enable = true },