after/ftplugin instead of autocmd

Use after/ftplugin instead of autocmds to handle options depending on
filetype
This commit is contained in:
Oliver Ladner 2024-05-17 15:24:50 +02:00
commit aa0f1fbd92
5 changed files with 26 additions and 9 deletions

View file

@ -0,0 +1,2 @@
-- Disable column width indicators in quickfix/Trouble windows
vim.opt.colorcolumn = ""

View file

@ -0,0 +1,8 @@
-- TIP: If you want custom color of colorcolumn local to window
-- do
-- local ns = vim.api.nvim_create_namespace('gitcommit')
-- vim.api.nvim_set_hl(ns, 'ColorColumn', { link = '#ff0000' })
-- vim.api.nvim_win_set_hl_ns(0, ns)
-- end
vim.bo.textwidth = 72
vim.wo.colorcolumn = "+0"

3
after/ftplugin/go.lua Normal file
View file

@ -0,0 +1,3 @@
vim.keymap.set("n", "<space>td", function()
require("dap-go").debug_test()
end, { buffer = 0 })

3
after/ftplugin/oil.lua Normal file
View file

@ -0,0 +1,3 @@
-- Disable numbers in Oil windows
vim.opt.relativenumber = false
vim.opt.number = false

View file

@ -7,12 +7,13 @@ vim.api.nvim_create_autocmd("TextYankPost", {
end, end,
}) })
-- Disable (relative) line numbers on Oil windows -- NOTE: the config below was put to after/ftplugin to make it simpler
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("weeheavy-no-line-numbers-in-oil", { clear = true }), -- Disable colorcolumn on quickfix (qf) windows
pattern = { "oil" }, --vim.api.nvim_create_autocmd("FileType", {
callback = function() -- group = vim.api.nvim_create_augroup("weeheavy-no-colorcolumn-in-quickfix", { clear = true }),
vim.opt.relativenumber = false -- pattern = { "qf", "Trouble" },
vim.opt.number = false -- callback = function()
end, -- vim.opt.colorcolumn = ""
}) -- end,
--})