zaeph / .emacs.d

Personal configuration for Emacs & Custom modules
GNU General Public License v3.0
104 stars 9 forks source link

Can we change the following code to increase the performance, my computer get stuck when I use projectile to open project. #5

Open dineshbhardwaj opened 4 years ago

dineshbhardwaj commented 4 years ago
;;  Its changed by dinesh from here
;; removed (use-package projectile
;; removed   ;;  :ensure t
;; removed   :bind-keymap ("C-c p" . projectile-command-map)
;; removed   :custom
;; removed   (projectile-project-search-path '("~/.emacs.d/"
;; removed                                     "~/.bin/"
;; removed                                     "~/.dotfiles/"
;; removed                                     "~/projects/"))
;; removed   (projectile-switch-project-action (lambda () (dired ".")))
;; removed   :config
;; removed   (projectile-mode))

;; removed (use-package counsel-projectile
;; removed   :ensure t
;; removed   :bind (("s-r" . counsel-projectile))
;; removed   :custom
;; removed   (counsel-projectile-switch-project-action
;; removed    '(1
;; removed      ("D" counsel-projectile-switch-project-action-dired "open project in dired")
;; removed      ("o" counsel-projectile-switch-project-action "jump to a project buffer or file")
;; removed      ("f" counsel-projectile-switch-project-action-find-file "jump to a project file")
;; removed      ("d" counsel-projectile-switch-project-action-find-dir "jump to a project directory")
;; removed      ("b" counsel-projectile-switch-project-action-switch-to-buffer "jump to a project buffer")
;; removed      ("m" counsel-projectile-switch-project-action-find-file-manually "find file manually from project root")
;; removed      ("S" counsel-projectile-switch-project-action-save-all-buffers "save all project buffers")
;; removed      ("k" counsel-projectile-switch-project-action-kill-buffers "kill all project buffers")
;; removed      ("K" counsel-projectile-switch-project-action-remove-known-project "remove project from known projects")
;; removed      ("c" counsel-projectile-switch-project-action-compile "run project compilation command")
;; removed      ("C" counsel-projectile-switch-project-action-configure "run project configure command")
;; removed      ("E" counsel-projectile-switch-project-action-edit-dir-locals "edit project dir-locals")
;; removed      ("v" counsel-projectile-switch-project-action-vc "open project in vc-dir / magit / monky")
;; removed      ("sg" counsel-projectile-switch-project-action-grep "search project with grep")
;; removed      ("si" counsel-projectile-switch-project-action-git-grep "search project with git grep")
;; removed      ("ss" counsel-projectile-switch-project-action-ag "search project with ag")
;; removed      ("sr" counsel-projectile-switch-project-action-rg "search project with rg")
;; removed      ("xs" counsel-projectile-switch-project-action-run-shell "invoke shell from project root")
;; removed      ("xe" counsel-projectile-switch-project-action-run-eshell "invoke eshell from project root")
;; removed      ("xt" counsel-projectile-switch-project-action-run-term "invoke term from project root")
;; removed      ("xv" counsel-projectile-switch-project-action-run-vterm "invoke vterm from project root")
;; removed      ("Oc" counsel-projectile-switch-project-action-org-capture "capture into project")
;; removed      ("Oa" counsel-projectile-switch-project-action-org-agenda "open project agenda")))
;; removed   :init
;; removed   (counsel-projectile-mode))
;; removed
(defcustom dotemacs-temp-directory (concat user-emacs-directory "tmp/")
  "Storage location for various configuration files."
  :group 'dotemacs)

(use-package projectile
  :ensure t
  :config
  (setq projectile-known-projects-file (concat dotemacs-temp-directory "projectile-known-projects.eld")
        projectile-cache-file (concat dotemacs-temp-directory "projectile.cache"))
  (projectile-mode 1) ; Otherwise keybindings not bound explicitly with bind* will not be respected
  (setq projectile-enable-caching t
        projectile-file-exists-remote-cache-expire nil
        projectile-verbose nil
        projectile-require-project-root t ; Use projectile only in desired directories, too much noise otherwise
        projectile-find-dir-includes-top-level t
        projectile-switch-project-action 'projectile-find-file ; Use projectile-dired to view in dired
        ;; projectile-mode-line nil
        projectile-completion-system 'ivy
        ;; The contents of .projectile are ignored when using the alien project indexing method
        projectile-indexing-method 'hybrid
        projectile-enable-idle-timer t  ; Runs "regenerate ctags" by default
        projectile-idle-timer-seconds 120
        projectile-project-search-path '("~/.emacs.d/"
                                         "~/.bin/"
                                         "~/.dotfiles/"
                                         "~/projects/"
                                         "~/Workspace/deployment/Anirudh/"))
  (add-to-list 'projectile-ignored-projects `,(concat (getenv "HOME") "/"))
                                        ; Do not consider the home dir as a project

  (dolist (dirs '(".cache"
                  ".dropbox"
                  ".git"
                  ".hg"
                  ".svn"
                  ".nx"
                  "elpa"
                  "auto"
                  "__pycache__"
                  ".vscode"))
    (add-to-list 'projectile-globally-ignored-directories dirs))

  (dolist (item '("GPATH"
                  "GRTAGS"
                  "GTAGS"
                  "GSYMS"
                  "TAGS"
                  ".tags"
                  "__init__.py"))
    (add-to-list 'projectile-globally-ignored-files item))

  (dolist (list '("\\.out$"
                  "\\.pdf$"
                  "\\.pyc$"
                  "\\.rel$"
                  "\\.rip$"
                  "~$"))
    (add-to-list 'projectile-globally-ignored-file-suffixes list))

   ;; https://www.reddit.com/r/emacs/comments/320cvb/projectile_slows_tramp_mode_to_a_crawl_is_there_a/
  (defadvice projectile-project-root (around ignore-remote first activate)
    (unless (file-remote-p default-directory) ad-do-it))

  (add-hook 'projectile-after-switch-project-hook
            (lambda ()
              (unless (bound-and-true-p treemacs-mode)
                (treemacs)
                (other-window 1))))

  (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))

(use-package counsel-projectile
  :ensure t
  :config
  (counsel-projectile-mode)
  ;; Sort projects from newest to oldest
  (add-to-list 'ivy-sort-functions-alist
               '(counsel-projectile-switch-project . file-newer-than-file-p))
  (bind-keys ("<f5>" . counsel-projectile-switch-project)
             ("s-r" . counsel-projectile)
         ("<f7>" . counsel-projectile-rg))
  :custom
  (counsel-projectile-switch-project-action
   '(1
     ("D" counsel-projectile-switch-project-action-dired "open project in dired")
     ("o" counsel-projectile-switch-project-action "jump to a project buffer or file")
     ("f" counsel-projectile-switch-project-action-find-file "jump to a project file")
     ("d" counsel-projectile-switch-project-action-find-dir "jump to a project directory")
     ("b" counsel-projectile-switch-project-action-switch-to-buffer "jump to a project buffer")
     ("m" counsel-projectile-switch-project-action-find-file-manually "find file manually from project root")
     ("S" counsel-projectile-switch-project-action-save-all-buffers "save all project buffers")
     ("k" counsel-projectile-switch-project-action-kill-buffers "kill all project buffers")
     ("K" counsel-projectile-switch-project-action-remove-known-project "remove project from known projects")
     ("c" counsel-projectile-switch-project-action-compile "run project compilation command")
     ("C" counsel-projectile-switch-project-action-configure "run project configure command")
     ("E" counsel-projectile-switch-project-action-edit-dir-locals "edit project dir-locals")
     ("v" counsel-projectile-switch-project-action-vc "open project in vc-dir / magit / monky")
     ("sg" counsel-projectile-switch-project-action-grep "search project with grep")
     ("si" counsel-projectile-switch-project-action-git-grep "search project with git grep")
     ("ss" counsel-projectile-switch-project-action-ag "search project with ag")
     ("sr" counsel-projectile-switch-project-action-rg "search project with rg")
     ("xs" counsel-projectile-switch-project-action-run-shell "invoke shell from project root")
     ("xe" counsel-projectile-switch-project-action-run-eshell "invoke eshell from project root")
     ("xt" counsel-projectile-switch-project-action-run-term "invoke term from project root")
     ("xv" counsel-projectile-switch-project-action-run-vterm "invoke vterm from project root")
     ("Oc" counsel-projectile-switch-project-action-org-capture "capture into project")
     ("Oa" counsel-projectile-switch-project-action-org-agenda "open project agenda")))
   )
;;;  Its changed by dinesh till here
zaeph commented 4 years ago

I'm at work right now, but I'll have a look tonight.