Neovim configs for 2023. Hopefully they last.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
669 B

2 years ago
2 years ago
  1. local builtin = require("telescope.builtin")
  2. local function git_exists()
  3. local path = require("pl.path")
  4. local p = "."
  5. while true do
  6. local gitpath = p .. "/.git"
  7. local d = io.open(gitpath)
  8. if d then
  9. d:close()
  10. return true
  11. else
  12. p = p .. "/.."
  13. end
  14. if path.abspath(p) ~= "/" then
  15. return false
  16. end
  17. end
  18. end
  19. vim.keymap.set('n', '<C-P>', function()
  20. if git_exists() then
  21. builtin.git_files()
  22. else
  23. builtin.find_files()
  24. end
  25. end, {})
  26. vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
  27. vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
  28. vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})