From f9825d9b69fe97afe0798595cf94bf6dd341500a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Fri, 15 Mar 2024 16:20:43 +0000 Subject: [PATCH] Port over :TextWidth command --- lua/commands.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/commands.lua b/lua/commands.lua index ac5a83f..26101e6 100644 --- a/lua/commands.lua +++ b/lua/commands.lua @@ -1,3 +1,16 @@ +-- :TabWidth set the tab width for the current buffer +vim.api.nvim_create_user_command('TabWidth', function(opts) + -- Set the tab width for the current filetype + -- FIXME: Doesn't seem to cover all bases in neovim when editorconfig is + -- involved, specifically with pressing o/O in C++ from a line with a brace. + -- This might be related to tree-sitter indentation? Or could be that I've + -- not ported over all my filetype settings yet. + local width = tonumber(opts.args) + vim.opt.tabstop = width + vim.opt.shiftwidth = width + vim.opt.softtabstop = width +end, { nargs = 1 }) + -- TODO: :Rename -- vim.loop.fs_rename