syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.67k stars 4.89k forks source link

best practice to open a folder (project) #8453

Closed czhang03 closed 7 years ago

czhang03 commented 7 years ago

I tried to use SPC-f-f but it just pure ugly...

capture

what is the best way to open a project in specemacs?

bmag commented 7 years ago

If you don't like Dired (that's what you're seeing), you can use one of the other file browsers: Deer, Ranger or Neotree.

czhang03 commented 7 years ago

Sorry, I am not familiar with this, can you tell me how do I change the default file explore to Neotree?

bmag commented 7 years ago

Sorry, I'm kind of busy. There's plenty of documentation available - both in the Spacemacs documentation and in other places.

czhang03 commented 7 years ago

Thank you! I will check it out.

jupl commented 7 years ago

If it's a project I have already opened before I use SPC p p so I can get a Helm Projectile buffer instantly.

smile13241324 commented 7 years ago

Neotree is also quite useful if you want to have IDE like tree structures. You can call it with SPC p t for a project or SPC f t to open it for a generic file.

czhang03 commented 7 years ago

yes, but what I want is like in vim, when I type:

vim .

it opens nerdtree next to a empty buffer. but when I do

emacs .

it opens dired

bmag commented 7 years ago

Just a quick thing that I wrote, no guarantees that it will work consistently: (in fact it throws some error but still seems to do enough of the job)

;; based on neotree-show
(defun my-neotree-dir (dir)
  (let ((cw (selected-window))) ;; save current window
    (neotree-find dir)
    (neo-global--select-window)
    (selected-window cw)
    (neo-global--get-buffer))
(add-to-list 'find-directory-functions 'my-neotree-dir)

This can be improved to get a proper solution.

chrissound commented 7 years ago

Shall we close this? Or at least modify the title / question to reflect what is being asked in this thread?

kevindashgit commented 6 years ago

I'm finding that I have a similar frustration with projects (and I realize this widely varies for each individual) but It'd (that's a word right?) be nice if there were some way to auto-add all project dirs under a given dir (so any dir with a .gitconfig for example). VSCode has a really awesome plugin someone wrote here https://github.com/alefragnani/vscode-project-manager (look for Automatic Detection of Projects) - that's exactly what I'm after (and perhaps OP?)

smile13241324 commented 6 years ago

@kevindashgit I had a look at the VC plugin and for me this looks pretty similiar to SPC p pto switch between projekts. This shows a helm buffer, which is an intelligent fussy search, of all projects spacemacs knows about. By selecting one you can either decide to open a folder which opens your emacs file manager or a file you want to work with.

A project is either a git repo or a folder containing a .projectile file.

This is even better than what VScode does as you do not need to maintain any json files for this.

kevindashgit commented 6 years ago

thank you for your reply @smile13241324

This shows a helm buffer, which is an intelligent fussy search, of all projects spacemacs knows about.

The operative phrase "all projects spacemacs knows about".

By selecting one you can either decide to open a folder which opens your emacs file manager or a file you want to work with.

I think I lost you - I have numerous projects sitting at my home dir ~/ that I'd love for SPC p p to pick up - but it doesn't show up - even if I enter the full path? Am I doing something wrong? How do I open the project (without like opening an empty buffer or having to select a specific file etc... like is there an "auto detection" of projects in a directory)? I feel dumb for asking that but its not obvious to me at all!

smile13241324 commented 6 years ago

@kevindashgit hmm when you do not see your projects with SPC p p it means that emacs do not know about these. When you open a file in a directoy which contains a git repository or a file named .projectile, the emacs package projectile remembers whether that file is part of a project folder and adds an entry in your cache folder within your .emacs.d.

Next time you call helm-projectile-switch-project, this is what is bound at SPC p p, should show you a list of all the project folders you have in a helm buffer where you can select a project and then filter for files in there.

kevindashgit commented 6 years ago

[...] and adds an entry in your cache folder within your .emacs.d.

oh? I'll poke around and see if I can figure out where within that directory its sticking these "known projects." Maybe I can automate something myself.

jamiecook commented 6 years ago

@kevindashgit would love to see what you come up with - i have a similar frustration

kevindashgit commented 6 years ago

Soooooo I've decided spacemacs was not for me (too slow and buggy unfortunately - and I'm much faster with vanilla vim + tmux).

Its still a bit of a work in progress - but I decided to go with this (note: some prereqs: vim rooter, and fzf)

" list all directories in ~ that contain a package.json
function! s:listpkgs()
  call fzf#run(fzf#wrap({'source':'find /Users/kevindashgit/. -maxdepth 2 -name package.json -print0 | xargs -0 -n1 dirname | sort --unique', 'sink': 'tabedit'}))
endfunction

" open a project in a new split
nnoremap <silent><leader>p :call <sid>listpkgs()<cr>

Although this works - its still not satisfying enough for me. I think I might spend some more time with tmux instead (perhaps even using something like the above but instead open a new tmux window per project)

sizhky commented 4 years ago

I personally find C-x + d more pleasing. It opens a dired buffer in current directory

jmromer commented 4 years ago

I personally find C-x + d more pleasing. It opens a dired buffer in current directory

Just to add to that: I believe in evil mode, by default (?) - is bound to dired-jump to do just that. (I remember this binding being either a default or common practice in Vim configs.)