diff --git a/.config/nvim/lua/my/functions.lua b/.config/nvim/lua/my/functions.lua index 461bb1a..be35e62 100644 --- a/.config/nvim/lua/my/functions.lua +++ b/.config/nvim/lua/my/functions.lua @@ -67,7 +67,7 @@ vim.api.nvim_create_user_command('ModelineInsert', M.insert_modeline, {}) -- Files that could indicate the project's root directory M.project_root_markers = { '.git', '.hg', '.svn', '.bzr', '_darcs', - '.projectile', '.clang-format', '.luarc.json', '.editorconfig' + '.projectile', '.luarc.json', '.editorconfig' } function M.get_project_root() @@ -77,11 +77,12 @@ function M.get_project_root() repeat path = path:gsub(string.format('%s[^%s]*$', sep, sep), '') for _, marker in ipairs(M.project_root_markers) do - if io.open(path .. sep .. marker) then + if path ~= os.getenv('HOME') and io.open(path .. sep .. marker) then return path end end until path == '' + return nil end diff --git a/.config/nvim/lua/my/tools.lua b/.config/nvim/lua/my/tools.lua index e6bde44..c22d39d 100644 --- a/.config/nvim/lua/my/tools.lua +++ b/.config/nvim/lua/my/tools.lua @@ -23,7 +23,8 @@ local t_builtin = require('telescope.builtin') local my = require('my.functions') map('n', 'tb', t_builtin.buffers, 'Buffers') map('n', 'tf', function() - t_builtin.find_files({ cwd = my.get_project_root() }) + t_builtin.find_files({ cwd = my.get_project_root() or + vim.fn.expand("%:p:h", true) }) -- fall back to current dir end, 'Files') map('n', 'tF', t_builtin.find_files, 'Files in cw') map('n', 'to', t_builtin.oldfiles, 'Recently opened files')