dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit feec128e474e64531b0f6efd539a049dc697fe8b
parent f9870a7ad3b638484e37ece130e80769817855df
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 14 Jun 2019 11:30:32 +0200

Add rudimentary filetype detection from filename extension

Diffstat:
M.config/vis/visrc.lua | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua @@ -19,4 +19,20 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) vis:command('set autoindent') vis:command('set tabwidth 4') vis:command('set colorcolumn 80') + + function detect_filetype(_, _, win, _, _) + if string.find(win.file.name, '%.') then + return string.gsub(win.file.name, '.*%.', '') + else -- no dot found in win.file.name + return false; + end + end + vis:command_register('filetype', function(_, _, win, _, _) + local ext = detect_filetype(_, _, win, _, _) + vis:info('filetype: ' .. ext) + end, 'detect file type from filename') + + if detect_filetype(_, _, win, _, _) == 'tex' then + --vis:map(vis.modes.INSERT, 'l', 'L') + end end)