How to disable mini.map for specific filetypes? #2207
-
Contributing guidelines
Module(s)mini.map QuestionBasically the title. I want to have Mini.map disabled for markdown filetype. Tried to add Thanks for the plugin! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, that's the right direction, but it does only half the job: it hides map window when it needs to be hidden. The other part is making sure that it is opened when it needs to be shown. Here is one way to do it (put this in a regular config files, not filetype script): -- Define filetypes which need to not show map window
local hide_map_filetypes = { markdown = true }
-- Use `schedule_wrap` to skip some "temporary" buffers
local f = vim.schedule_wrap(function(ev)
-- Act only if the target buffer that triggered the autocommand is current
-- This is also to skip some "temporary" buffers
if ev.buf ~= vim.api.nvim_get_current_buf() then return end
-- Close if needed, otherwise - make sure that it is open
local ft = vim.bo[ev.buf].filetype
if hide_map_filetypes[ft] then return MiniMap.close() end
MiniMap.open()
end)
-- Act both on `FileType` (when 'filetype' changes) and `BufEnter` (when
-- entering a buffer which already has filetype set)
vim.api.nvim_create_autocmd({ 'FileType', 'BufEnter' }, { callback = f })Instead of |
Beta Was this translation helpful? Give feedback.
Yes, that's the right direction, but it does only half the job: it hides map window when it needs to be hidden. The other part is making sure that it is opened when it needs to be shown.
Here is one way to do it (put this in a regular config files, not filetype script):