vim-projectionist icon indicating copy to clipboard operation
vim-projectionist copied to clipboard

RFC: Support 'wildignore' and 'suffixes' in .projections.json

Open kiryph opened this issue 7 years ago • 2 comments

IMHO the vim settings 'wildignore' ('wig') and 'suffixes' ('su') are directory related options, not per file, per filetype or globally. For example, vim-vinegar takes them into account when viewing a directory. In contrast to ft-related options such as 'define', 'include', 'suffixesadd', 'errorformat' and many more.

Therefore, I was thinking putting them into the file .projections.json would be a sensible location, similar to 'path' or dispatch.

What do others think about this?

kiryph avatar Aug 08 '18 08:08 kiryph

Could you try something like this?

let g:projectionist_heuristics = {
        \ "root": {
        \     "mydir/**/*": { "wildignore": "*.o,*.pyc", "suffixes": "*.h" }
        \ }}

autocmd User ProjectionistActivate call s:activate()

function! s:activate() abort
    for [root, value] in projectionist#query('wildignore')
        let &l:wildignore = value
    endfor
    for [root, value] in projectionist#query('suffixes')
        let &l:suffixes = value
    endfor
endfunction

gpanders avatar Feb 28 '19 14:02 gpanders

Thanks for your suggestion. Finally, I found the time to test this.

It works probably as you intended. However, I would prefer following changes.

First of all I would prefer to append the values from .projections.json to the defaults (vim or vimrc).

Secondly, when I am back in a netrw/vinegar window/buffer without a .projections.json, I expect that 'suffixes' is restored.

My try looks like

vimrc:

" RESTORE 'suffixes' WHEN PROJECTIONIST DETECT RUNS, IF SUCCESSFUL VALUE WILL BE APPENDED
autocmd User ProjectionistDetect
            \ if !exists('g:oldsuffixes') | let g:oldsuffixes = &l:suffixes |
            \ else | let &l:suffixes = g:oldsuffixes | endif

autocmd User ProjectionistActivate call s:activate()
function! s:activate() abort
    for [root, value] in projectionist#query('suffixes')
        "APPEND VALUE FROM .projections.json
        let &l:suffixes .= ','. value
    endfor
endfunction

I have tried this for a LaTeX project which has typically many generated files which clutter the folder a little bit. That is the reason why I like vim-vinegar which pushes the files matched by 'suffixes' to the bottom of the netrw window.

LaTeX Project/.projections.json

{
    "*": { "suffixes": ".aux,.fls,.log,.pytxcode" }
}

However, the restoring happens not at the correct moment. I guess have to leave this again for a while.

kiryph avatar May 23 '19 15:05 kiryph