diff --git a/lua/guess-indent/config.lua b/lua/guess-indent/config.lua index 017c0a1..483e1cd 100644 --- a/lua/guess-indent/config.lua +++ b/lua/guess-indent/config.lua @@ -2,6 +2,8 @@ local M = {} local default_config = { auto_cmd = true, + set_tabstop = true, + set_softtabstop = true, filetype_exclude = { "netrw", "tutor", diff --git a/lua/guess-indent/init.lua b/lua/guess-indent/init.lua index 31ef811..87f9c4b 100644 --- a/lua/guess-indent/init.lua +++ b/lua/guess-indent/init.lua @@ -66,15 +66,26 @@ local function set_indentation(indentation) if indentation == "tabs" then set_buffer_opt(0, "expandtab", false) + set_buffer_opt(0, "shiftwidth", 0) + if config.set_softtabstop then + set_buffer_opt(0, "softtabstop", 0) + end print("Did set indentation to tabs.") + vim.api.nvim_exec_autocmds("User", { pattern = "GuessIndentTabs" }) elseif type(indentation) == "number" and indentation > 0 then set_buffer_opt(0, "expandtab", true) - set_buffer_opt(0, "tabstop", indentation) - set_buffer_opt(0, "softtabstop", indentation) set_buffer_opt(0, "shiftwidth", indentation) + if config.set_softtabstop then + set_buffer_opt(0, "softtabstop", indentation) + end + if config.set_tabstop then + set_buffer_opt(0, "tabstop", indentation) + end print("Did set indentation to", indentation, "spaces.") + vim.api.nvim_exec_autocmds("User", { pattern = "GuessIndentSpaces" }) else print("Failed to detect indentation style.") + vim.api.nvim_exec_autocmds("User", { pattern = "GuessIndentNone" }) end end