From a73e190383635576e0b0f63d6e1a7850242d666b Mon Sep 17 00:00:00 2001 From: Jason Schneekloth Date: Thu, 4 Dec 2025 11:41:01 -0600 Subject: [PATCH] Getting ts/js autoformatting to work...sorta hacky --- init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/init.lua b/init.lua index 4e08b855..51f6eb5c 100644 --- a/init.lua +++ b/init.lua @@ -219,6 +219,17 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Use spaces, 2-width indent for TS/JS (both normal and React variants) +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'typescript', 'typescriptreact', 'javascript', 'javascriptreact' }, + callback = function() + vim.opt_local.expandtab = true + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.softtabstop = 2 + end, +}) + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -787,6 +798,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + -- NOTE: we've specified ts/js formats above via nvim_create_autocmd -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, --