aboutsummaryrefslogtreecommitdiff
path: root/runtime/filetype.lua
Commit message (Collapse)AuthorAge
* fix(filetype): run filetype.match on StdinReadPost (#20070)Christian Clason2022-09-03
| | | | | | | | | | | | | Problem: filetype detection does not run on piped input Solution: add `StdinReadPost` to main filetype.lua autocommand Rationale: legacy filetype detection checked contents by sourcing `scripts.vim` in separate autocommands, including on `StdinReadPost`. For Lua filetype detection, this was moved into the main autocommand, with bundled `scripts.vim` gated behind `g:do_legacy_filetype` (i.e., only user `scripts.vim` are sourced for compatibility by default). Adding `StdinReadPost` to the main autocommand again runs content checks on piped input without requiring code duplication and low-payoff refactoring.
* feat(runtime)!: enable filetype.lua by default (#19216)Christian Clason2022-07-07
| | | | | | * revert to filetype.vim by setting `g:do_legacy_filetype` * skip either filetype.lua or filetype.vim via `g:did_load_filetypes` (Running both is no longer required and therefore no longer supported.)
* fix(filetype): remove call to vim.fn.resolve and pass filename to match functionsmjonas2022-07-06
| | | | | For example on MacOS, /etc/hostname.file is symlinked to /private/etc/hostname.file. We only care about the original file path though.
* fix(filetype): fix filetype patternssmjonas2022-07-06
|
* refactor(filetype)!: allow vim.filetype.match to use different strategies ↵Gregory Anders2022-06-26
| | | | | | | | | | | | | | | | | | | (#18895) This enables vim.filetype.match to match based on a buffer (most accurate) or simply a filename or file contents, which are less accurate but may still be useful for some scenarios. When matching based on a buffer, the buffer's name and contents are both used to do full filetype matching. When using a filename, if the file exists the file is loaded into a buffer and full filetype detection is performed. If the file does not exist then filetype matching is only performed against the filename itself. Content-based matching does the equivalent of scripts.vim, and matches solely based on file contents without any information from the name of the file itself (e.g. for shebangs). BREAKING CHANGE: use `vim.filetype.match({buf = bufnr})` instead of `vim.filetype.match(name, bufnr)`
* feat(filetype): remove side effects from vim.filetype.match (#18894)Gregory Anders2022-06-09
| | | | | | | | Many filetypes from filetype.vim set buffer-local variables, meaning vim.filetype.match cannot be used without side effects. Instead of setting these buffer-local variables in the filetype detection functions themselves, have vim.filetype.match return an optional function value that, when called, sets these variables. This allows vim.filetype.match to work without side effects.
* chore: format runtime with styluaChristian Clason2022-05-09
|
* fix(ftdetect): source plugins in autogroup (#18237)Christian Clason2022-04-23
| | | In `filetype.lua`, source runtime `ftdetect` scripts within the `filetypedetect` augroup, same as `filetype.vim` (and only do so if `g:did_load_ftdetect` does not exist).
* refactor: use Lua autocommands in filetype.lua (#17711)Gregory Anders2022-03-13
|
* feat(filetype): support scripts.vim with filetype.lua (#17517)Gregory Anders2022-02-24
| | | | When filetype.vim is disabled, create the autocommand that runs scripts.vim in filetype.lua.
* fix(filetype): match on <afile> rather than <abuf> (#16943)Gregory Anders2022-01-05
| | | | | | | Filetype detection runs on BufRead and BufNewFile autocommands, both of which can fire without an underlying buffer, so it's incorrect to use <abuf> to determine the file path. Instead, match on <afile> and assume that the buffer we're operating on is the current buffer. This is the same assumption that filetype.vim makes, so it should be safe.
* fix(filetype): set default ft_ignore_pat in filetype.lua (#16917)Gregory Anders2022-01-04
| | | | | This default value is also set in filetype.vim, but if filetype.vim is disabled the variable is never defined, which causes errors in some of the dist#ft detection functions.
* feat: filetype.lua (#16600)Gregory Anders2022-01-04
Adds a new vim.filetype module that provides support for filetype detection in Lua.