   (defun me:find-some-files ()
     "Find files in project or fallback to current directory"
     (interactive)
-    (if (and (fboundp 'projectile-project-p) (projectile-project-p))
-        (let* ((project-root (projectile-ensure-project (projectile-project-root)))
-               (action (lambda (f) (with-ivy-window (find-file (expand-file-name f project-root)))))
-               (files (projectile-project-files project-root)))
-          (me:find-file "Find file: " files action 'me:find-some-files))
+    (if-let* ((project (project-current))
+              (root-path (cdr project))
+              (action (lambda (f) (with-ivy-window (find-file (expand-file-name f root-path)))))
+              (files (project-files project)))
+        (me:find-file "Find file: " files action 'me:find-some-files)
       (counsel-find-file)))
+
   (defun me:find-window-buffer()
     (interactive)
     "Find buffer from buffers previously used in window"


;; modeline tabs
(use-package moody
  :after (:all (:any modus-operandi-theme modus-vivendi-theme) perspective )
  :demand
  :custom
  (x-underline-at-descent-line t)

  :general
  (:keymaps 'grep-mode-map "C-c w" #'wgrep-change-to-wgrep-mode))

;; built-in project.el
(use-package project
  :demand t
  :general
  ;; TODO: This duplicates project-prefix-map; should find a way to use that
  (:prefix "<f7>"
           "<f7>" 'me:counsel-rg-project
           "!" 'project-shell-command
           "&" 'project-async-shell-command
           "f" 'project-find-file
           "F" 'project-or-external-find-file
           "b" 'project-switch-to-buffer
           "s" 'project-shell
           "d" 'project-find-dir
           "D" 'project-dired
           "v" 'project-vc-dir
           ;; N.B. f7-c runs counsel-compile
           "C" 'project-compile
           "e" 'project-eshell
           "k" 'project-kill-buffers
           "p" 'project-switch-project
           "g" 'project-find-regexp
           "G" 'project-or-external-find-regexp
           "r" 'project-query-replace-regexp
           "x" 'project-execute-extended-command)
  :config
  (defun me:counsel-rg-project ()
    "Search using ripgrep in project"
    (interactive)
    (if-let ((root (me:project-path)))
        (counsel-rg (thing-at-point 'symbol) root)
      (message "Not in a project")))
  ;; Add project relative org templates
  (defun me:add-project-templates ()
    (when (project-current)
      (add-to-list 'org-capture-templates
                   `("pn" "Project Notes" entry (file+headline ,(me:project-path "Notes/notes.org") "Notes")))
      (add-to-list 'org-capture-templates
                   `("pd" "Project Tasks" entry (file+headline ,(me:project-path "Notes/notes.org") "TODOs")
                     "* TODO %?\n  %i\n  %a"))))
  ;; Return path relative to project or nil if no project
  (defun me:project-path ( &optional path)
    (if-let* ((proj (project-current))
              (root (project-root proj)))
        (if path
            (expand-file-name path root)
          root)))
  (defun me:project-mode-line-info()
    (if-let* ((path (me:project-path))
              (name (file-name-nondirectory (directory-file-name path))))
        (concat " [" name "] ")))
  (add-to-list 'mode-line-misc-info `(:eval (me:project-mode-line-info)))
  :ensure nil)

(use-package rainbow-delimiters
  :hook ((emacs-lisp-mode) . rainbow-delimiters-mode ))
