klen / nvim-config-local

Secure load local config files for neovim
MIT License
150 stars 9 forks source link

feat: load local config file inside a sub directory #2

Closed pysan3 closed 2 years ago

pysan3 commented 2 years ago

Hi @klen,

Thanks for the awesome plugin :)

I usually put the local config file inside a sub directory like ./.vim/local.vim. However, adding this path to config_files will result in an error as follows,

[config-local]: Unsupported config filetype: "/path/to/pwd/.vim/local.vim"

It would be really nice if the plugin could find files inside subdirectories.

This is caused by line 66 in init.lua where vim.fn.fnamemodify(filename, ":t") only returns the filename (i.e. local.vim) which is not included in the config_files.

A possible fix would be to change the argument from ":t" to ":~:." which returns the filename relative to the current directory.

:h filename-modifiers
    :~  Reduce file name to be relative to the home directory, if
        possible.  File name is unmodified if it is not below the home
        directory.
    :.  Reduce file name to be relative to current directory, if
        possible.  File name is unmodified if it is not below the
        current directory, but on MS-Windows the drive is removed if
        it is the current drive.
        For maximum shortness, use ":~:.".

And this change can be done to the following three lines. image

Best, pysan3

klen commented 2 years ago

@pysan3 This is a good point. I've made the changes. Thank you!

pysan3 commented 2 years ago

It works really good!!

Thanks ;)