add support for ts/js

This commit is contained in:
2026-06-30 08:44:54 +05:30
parent c2c98ec83c
commit a9651a67c6
8 changed files with 232 additions and 12 deletions

View File

@@ -6,10 +6,9 @@ return {
},
init = function() vim.g.barbar_auto_setup = false end,
opts = {
-- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
-- animation = true,
-- insert_at_start = true,
-- …etc.
sidebar_filetypes = {
NvimTree = true,
},
},
version = '^1.0.0', -- optional: only update when a new 1.x version is released
}}

35
lua/plugins/format.lua Normal file
View File

@@ -0,0 +1,35 @@
return {
{
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>f",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
mode = "",
desc = "Format buffer",
},
},
opts = {
formatters_by_ft = {
lua = { "stylua" },
python = { "ruff_format" },
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
html = { "prettier" },
css = { "prettier" },
json = { "prettier" },
markdown = { "prettier" },
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
},
},
}

View File

@@ -27,6 +27,8 @@ return {
ensure_installed = {
"pyright",
"ruff",
"ts_ls",
"eslint",
},
automatic_installation = true,
},
@@ -77,15 +79,13 @@ return {
client.server_capabilities.hoverProvider = false
end
-- Format on save if client supports it
if client and client:supports_method("textDocument/formatting") then
local format_grp = vim.api.nvim_create_augroup("LspFormat." .. bufnr, { clear = true })
-- Auto-fix ESLint issues on save if ESLint is active
if client and client.name == "eslint" then
local eslint_grp = vim.api.nvim_create_augroup("LspEslint." .. bufnr, { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = format_grp,
group = eslint_grp,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr, id = client.id, async = false })
end,
command = "EslintFixAll",
})
end
@@ -152,6 +152,26 @@ return {
capabilities = capabilities,
})
vim.lsp.enable("ruff")
-- Configure ts_ls (TypeScript/JavaScript LSP) using native Neovim 0.11+ API
vim.lsp.config("ts_ls", {
capabilities = capabilities,
init_options = {
preferences = {
disableSuggestions = false,
},
},
})
vim.lsp.enable("ts_ls")
-- Configure ESLint (JS/TS linter) using native Neovim 0.11+ API
vim.lsp.config("eslint", {
capabilities = capabilities,
settings = {
workingDirectories = { mode = "location" },
},
})
vim.lsp.enable("eslint")
end,
},
}

View File

@@ -6,13 +6,15 @@ return {
"nvim-tree/nvim-web-devicons",
},
config = function()
local ignored = require("config.ignored_patterns")
-- vim.cmd([[hi NvimTreeNormal guibg=NONE ctermbd=NONE]])
require("nvim-tree").setup {
git = {
ignore = false,
},
filters= {
filters = {
dotfiles = false,
custom = ignored.get_for_nvim_tree(),
},
view = {
adaptive_size = true,

View File

@@ -6,8 +6,10 @@ return {
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
},
config = function()
local ignored = require("config.ignored_patterns")
require('telescope').setup({
defaults = {
file_ignore_patterns = ignored.get_for_telescope(),
vimgrep_arguments = {
"rg",
"--color=never",