diff options
| author | Robert Günzler <r@gnzler.io> | 2023-01-19 18:33:43 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2023-01-19 18:33:43 +0100 |
| commit | fc67eecc8a40bf28d3d2b190702e58c580bfba9f (patch) | |
| tree | 0b8d0455046ae484e036d2f9dfa69306bbea811d /.vim/lua/internal/exrc.lua | |
| parent | c03b74ce367d6e9e2988dbb4a18985bc372dd8a6 (diff) | |
vim: format config with stylua
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.vim/lua/internal/exrc.lua')
| -rw-r--r-- | .vim/lua/internal/exrc.lua | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/.vim/lua/internal/exrc.lua b/.vim/lua/internal/exrc.lua deleted file mode 100644 index 1b3b22b..0000000 --- a/.vim/lua/internal/exrc.lua +++ /dev/null @@ -1,49 +0,0 @@ -local root_pattern = require('lspconfig.util').root_pattern - -local M = { - config = { - filenames = {'.nvimrc'} - } -} - -M.setup = function (opt) - vim.validate { - filenames = { opt.filenames, 'table', true }, - } - - M.config = vim.tbl_extend('force', M.config, opt) - - local group = vim.api.nvim_create_augroup('ExrcLoad', { clear = true }) - vim.api.nvim_create_autocmd('VimEnter', { - callback = M.load, - group = group, - }) -end - -local load = function (root, filename) - local fpath = root .. '/' .. filename - if root and vim.loop.fs_stat(fpath) then - vim.cmd('luafile ' .. fpath) - vim.g.nvimrc_loaded = fpath - else - error(string.format('[exrc] %s not found', fpath)) - end -end - -M.load = function () - local root = vim.fn.getcwd() - for _, fname in ipairs(M.config.filenames) do - local ok = false - ok, _ = pcall(load, root, fname) - if ok then return true end - - -- try harder by searching up the dir tree - root = root_pattern(fname)(root) - ok, _ = pcall(load, root, fname) - if ok then return true end - end - - return false -end - -return M |