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
This commit is contained in:
dario 2025-04-12 16:16:06 +02:00 committed by dasvh
parent 5cdacadcf8
commit a44c559d1d
1 changed files with 11 additions and 5 deletions

View File

@ -114,11 +114,6 @@ vim.opt.scrolloff = 10
-- See `:help 'confirm'` -- See `:help 'confirm'`
vim.opt.confirm = true 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 -- highlight ExtraWhitespace
-- TODO: does not seem to clear all whitespace (-> did not work for yaml file) -- TODO: does not seem to clear all whitespace (-> did not work for yaml file)
vim.api.nvim_set_hl(0, 'ExtraWhitespace', { vim.api.nvim_set_hl(0, 'ExtraWhitespace', {
@ -180,6 +175,17 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end, 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 ]] -- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'