~glacambre/firenvim

ref: 076c1a4f04db2173afb395d0af8c63a5bbcab6a8 firenvim/autoload/firenvimft.vim -rw-r--r-- 979 bytes
076c1a4f — Brian Ryall fixes installing fire nvim on brave 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
let s:patterns_to_ft = {
        \ '/github.com_.*\.txt$': 'markdown',
        \ '/\(\w\+\.\)*reddit\.com_.*\.txt$': 'markdown',
        \ '/stackoverflow.com_.*\.txt$': 'markdown',
        \ '/stackexchange.com_.*\.txt$': 'markdown',
        \ '/slack.com_.*\.txt$': 'markdown',
        \ '/gitter.com_.*\.txt$': 'markdown',
        \ '/riot.im_.*\.txt$': 'markdown',
        \ '/lobste.rs_.*\.txt$': 'markdown',
        \ '/cocalc.com_.*\.txt$': 'python',
        \ '/kaggleusercontent.com_.*\.txt$': 'python',
  \ }

function! firenvimft#detect(buf) abort
        let l:name = nvim_buf_get_name(a:buf)
        if l:name !~? '/firenvim/.*\.txt$'
                return 0
        endif
        let l:ft = 'text'
        for l:pattern in keys(s:patterns_to_ft)
                if l:name =~? l:pattern
                        call nvim_buf_set_option(a:buf, 'filetype', s:patterns_to_ft[l:pattern])
                        return
                endif
        endfor
endfunction