google / google/vim-maktaba

Implement a hook for "filetype known"

Open
#96 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Vim Script
Stars
588
Forks
41
PR merge metrics
No merged PRs in 30d

Description

If a plugin wants to have configuration based on a buffer's filetype, it turns out to be tricky to handle if you need to explicitly handle the case where filetype _wasn't_ set. You can use "autocmd FileType", but that will never fire for a new buffer with no filetype, and can fire multiple times for a single new buffer if autocmds are overriding filetype on each other.

It would be useful to have a hook for code that needs to read the 'filetype' setting and expects it to already be valid even for no-filetype buffers. This hook should fire:
- Once after all filetypedetect autocmds have fired (i.e., after the last BufRead or BufNewFile autocmd).
- Any time the filetype changes afterwards.
This should avoid firing multiple times for the same event if autocmds set and then override the filetype (especially for the initial filetype detection, but also for later events if possible).

Ideally, this would be implemented inside vim, and might be tricky or impossible to implement properly in maktaba, but it's worth discussing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.