nvim ftplugin tweaks

This commit is contained in:
Henrik Bakken
2026-10-19 12:29:31 +02:00
parent 1ec951997b
commit 02dcab9871
9 changed files with 78 additions and 17 deletions
+20
View File
@@ -0,0 +1,20 @@
local bufname = vim.api.nvim_buf_get_name(0)
local filename_arg = bufname ~= "" and (" --stdin-filepath " .. vim.fn.shellescape(bufname)) or ""
-- Indentation & Layout
vim.opt_local.colorcolumn = "100"
vim.opt_local.textwidth = 100
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 4
vim.opt_local.softtabstop = 4
vim.opt_local.expandtab = true
-- Formatting Behavior
vim.opt_local.formatoptions:remove("t") -- Don't autowrap while typing
vim.opt_local.formatoptions:append("j") -- Remove comment markers when joining lines
-- gq Formatters (Prettier fallback, LSP primary)
-- Prefers local/global binary first to avoid slow npx invocation overhead
local prettier_bin = vim.fn.executable("prettier") == 1 and "prettier" or "npx prettier"
vim.bo.formatprg = prettier_bin .. filename_arg
vim.bo.formatexpr = "v:lua.vim.lsp.formatexpr()"