From a44c559d1de68b7d074841b10010a8bdf2caa0b5 Mon Sep 17 00:00:00 2001 From: dario Date: Sat, 12 Apr 2025 16:16:06 +0200 Subject: [PATCH] fix: use autocommand to set indendation for Go files when jumping to a declaration the indendation defaulted back to 8 instead of 4 but with autocommand it works when jumping between files --- init.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 06691125..28813d2c 100644 --- a/init.lua +++ b/init.lua @@ -114,11 +114,6 @@ vim.opt.scrolloff = 10 -- See `:help 'confirm'` vim.opt.confirm = true --- set tabs to 4 spaces (default is 8) -vim.bo.tabstop = 4 -vim.bo.shiftwidth = 4 -vim.bo.softtabstop = 4 - -- highlight ExtraWhitespace -- TODO: does not seem to clear all whitespace (-> did not work for yaml file) vim.api.nvim_set_hl(0, 'ExtraWhitespace', { @@ -180,6 +175,17 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Set correct indendation for Go files +vim.api.nvim_create_autocmd('FileType', { + pattern = 'go', + callback = function() + vim.bo.tabstop = 4 + vim.bo.shiftwidth = 4 + vim.bo.softtabstop = 4 + vim.bo.expandtab = false + 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'