When I open a file, I exepct cwd to be set to the directory of open file, and not the root of git repository.
If you are in a git repo ~/work/repo and open a file ~/work/repo/a/b.txt and type :pwd in vim command, you will see ~/work/repo and __not__ ~/work/repo/a.
Please press SPC h I, debug info will be put into clipboard, then paste all content below.
SpaceVim layers:
- VersionControl: not loaded https://spacevim.org/layers/VersionControl/
+ autocomplete: loaded https://spacevim.org/layers/autocomplete/
- chat: not loaded https://spacevim.org/layers/chat/
- checkers: not loaded https://spacevim.org/layers/checkers/
- chinese: not loaded https://spacevim.org/layers/chinese/
- colorscheme: not loaded https://spacevim.org/layers/colorscheme/
+ core#banner: loaded https://spacevim.org/layers/core/banner/
+ core#statusline: loaded https://spacevim.org/layers/core/statusline/
+ core#tabline: loaded https://spacevim.org/layers/core/tabline/
+ core: loaded https://spacevim.org/layers/core/
- cscope: not loaded https://spacevim.org/layers/cscope/
- ctrlp: not loaded https://spacevim.org/layers/ctrlp/
- debug: not loaded https://spacevim.org/layers/debug/
- denite: not loaded https://spacevim.org/layers/denite/
+ edit: loaded https://spacevim.org/layers/edit/
- exprfold: not loaded no exists
- floobits: not loaded https://spacevim.org/layers/floobits/
+ format: loaded https://spacevim.org/layers/format/
- fzf: not loaded https://spacevim.org/layers/fzf/
- games: not loaded no exists
- git: not loaded https://spacevim.org/layers/git/
- github: not loaded https://spacevim.org/layers/github/
- incsearch: not loaded no exists
- indentmove: not loaded no exists
- japanese: not loaded https://spacevim.org/layers/japanese/
- lang#WebAssembly: not loaded https://spacevim.org/layers/lang/WebAssembly/
- lang#agda: not loaded https://spacevim.org/layers/lang/agda/
- lang#asciidoc: not loaded https://spacevim.org/layers/lang/asciidoc/
- lang#autohotkey: not loaded https://spacevim.org/layers/lang/autohotkey/
- lang#c: not loaded https://spacevim.org/layers/lang/c/
- lang#clojure: not loaded https://spacevim.org/layers/lang/clojure/
- lang#crystal: not loaded no exists
- lang#csharp: not loaded https://spacevim.org/layers/lang/csharp/
- lang#dart: not loaded https://spacevim.org/layers/lang/dart/
- lang#dockerfile: not loaded https://spacevim.org/layers/lang/dockerfile/
- lang#elixir: not loaded https://spacevim.org/layers/lang/elixir/
- lang#elm: not loaded https://spacevim.org/layers/lang/elm/
- lang#erlang: not loaded https://spacevim.org/layers/lang/erlang/
- lang#extra: not loaded https://spacevim.org/layers/lang/extra/
- lang#fsharp: not loaded https://spacevim.org/layers/lang/fsharp/
- lang#go: not loaded https://spacevim.org/layers/lang/go/
- lang#graphql: not loaded https://spacevim.org/layers/lang/graphql/
- lang#haskell: not loaded https://spacevim.org/layers/lang/haskell/
- lang#html: not loaded https://spacevim.org/layers/lang/html/
- lang#java: not loaded https://spacevim.org/layers/lang/java/
- lang#javascript: not loaded https://spacevim.org/layers/lang/javascript/
- lang#json: not loaded no exists
- lang#julia: not loaded https://spacevim.org/layers/lang/julia/
- lang#kotlin: not loaded https://spacevim.org/layers/lang/kotlin/
- lang#latex: not loaded https://spacevim.org/layers/lang/latex/
- lang#lisp: not loaded https://spacevim.org/layers/lang/lisp/
- lang#lua: not loaded https://spacevim.org/layers/lang/lua/
- lang#markdown: not loaded https://spacevim.org/layers/lang/markdown/
- lang#nim: not loaded https://spacevim.org/layers/lang/nim/
- lang#ocaml: not loaded https://spacevim.org/layers/lang/ocaml/
- lang#perl: not loaded https://spacevim.org/layers/lang/perl/
- lang#php: not loaded https://spacevim.org/layers/lang/php/
- lang#plantuml: not loaded https://spacevim.org/layers/lang/plantuml/
- lang#pony: not loaded no exists
- lang#ps1: not loaded no exists
- lang#puppet: not loaded https://spacevim.org/layers/lang/puppet/
- lang#purescript: not loaded https://spacevim.org/layers/lang/purescript/
- lang#python: not loaded https://spacevim.org/layers/lang/python/
- lang#r: not loaded no exists
- lang#ruby: not loaded https://spacevim.org/layers/lang/ruby/
- lang#rust: not loaded https://spacevim.org/layers/lang/rust/
- lang#scala: not loaded https://spacevim.org/layers/lang/scala/
- lang#scheme: not loaded https://spacevim.org/layers/lang/scheme/
- lang#sh: not loaded https://spacevim.org/layers/lang/sh/
- lang#solidity: not loaded no exists
- lang#swift: not loaded https://spacevim.org/layers/lang/swift/
- lang#swig: not loaded no exists
- lang#toml: not loaded no exists
- lang#typescript: not loaded https://spacevim.org/layers/lang/typescript/
- lang#vim: not loaded https://spacevim.org/layers/lang/vim/
- lang#vue: not loaded https://spacevim.org/layers/lang/vue/
- lang#xml: not loaded no exists
- leaderf: not loaded https://spacevim.org/layers/leaderf/
- lsp: not loaded no exists
- mail: not loaded no exists
- operator: not loaded no exists
- org: not loaded no exists
+ shell: loaded https://spacevim.org/layers/shell/
- sudo: not loaded https://spacevim.org/layers/sudo/
- tags: not loaded https://spacevim.org/layers/tags/
- test: not loaded https://spacevim.org/layers/test/
- tmux: not loaded https://spacevim.org/layers/tmux/
- tools#dash: not loaded https://spacevim.org/layers/tools/dash/
- tools#screensaver: not loaded no exists
- tools: not loaded https://spacevim.org/layers/tools/
+ ui: loaded https://spacevim.org/layers/ui/
- unite: not loaded https://spacevim.org/layers/unite/
- vim: not loaded no exists
NA
I've added following to autoload/myspacevim.vim but no effect.
" Change to current directory. autochdir does not always work see
" https://vim.wikia.com/wiki/Set_working_directory_to_the_current_file
set autochdir
autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif
let g:spacevim_project_rooter_automatically = 0
or
project_rooter_automatically = 0
for init.toml
first, why autochdir is needed. I need to know what next feature do you need. do you want edit file in same dir with current file?
second, most command is recommanded to run in the root of a project. for example maven in java project. make grep etc.
Shidong Wang
-------- 原始邮件 --------
主题:[SpaceVim/SpaceVim] How to force autochdir (#2354)
发件人:Dilawar Singh
收件人:SpaceVim/SpaceVim
抄送:Subscribed
Expected behavior, english is required
When I open a file, I exepct :pwd to set to directory of that file not the root of git repository.
The reproduce ways from Vim starting (Required!)
If you are in a git repo ~/work/repo and open a file ~/work/repo/a/b.txt and type :pwd in vim command, you will see ~/work/repo and not ~/work/repo/a.
Debug info
Please press SPC h I, debug info will be put into clipboard, then paste all content below.
SpaceVim layers:
- VersionControl: not loaded https://spacevim.org/layers/VersionControl/
+ autocomplete: loaded https://spacevim.org/layers/autocomplete/
- chat: not loaded https://spacevim.org/layers/chat/
- checkers: not loaded https://spacevim.org/layers/checkers/
- chinese: not loaded https://spacevim.org/layers/chinese/
- colorscheme: not loaded https://spacevim.org/layers/colorscheme/
+ core#banner: loaded https://spacevim.org/layers/core/banner/
+ core#statusline: loaded https://spacevim.org/layers/core/statusline/
+ core#tabline: loaded https://spacevim.org/layers/core/tabline/
+ core: loaded https://spacevim.org/layers/core/
- cscope: not loaded https://spacevim.org/layers/cscope/
- ctrlp: not loaded https://spacevim.org/layers/ctrlp/
- debug: not loaded https://spacevim.org/layers/debug/
- denite: not loaded https://spacevim.org/layers/denite/
+ edit: loaded https://spacevim.org/layers/edit/
- exprfold: not loaded no exists
- floobits: not loaded https://spacevim.org/layers/floobits/
+ format: loaded https://spacevim.org/layers/format/
- fzf: not loaded https://spacevim.org/layers/fzf/
- games: not loaded no exists
- git: not loaded https://spacevim.org/layers/git/
- github: not loaded https://spacevim.org/layers/github/
- incsearch: not loaded no exists
- indentmove: not loaded no exists
- japanese: not loaded https://spacevim.org/layers/japanese/
- lang#WebAssembly: not loaded https://spacevim.org/layers/lang/WebAssembly/
- lang#agda: not loaded https://spacevim.org/layers/lang/agda/
- lang#asciidoc: not loaded https://spacevim.org/layers/lang/asciidoc/
- lang#autohotkey: not loaded https://spacevim.org/layers/lang/autohotkey/
- lang#c: not loaded https://spacevim.org/layers/lang/c/
- lang#clojure: not loaded https://spacevim.org/layers/lang/clojure/
- lang#crystal: not loaded no exists
- lang#csharp: not loaded https://spacevim.org/layers/lang/csharp/
- lang#dart: not loaded https://spacevim.org/layers/lang/dart/
- lang#dockerfile: not loaded https://spacevim.org/layers/lang/dockerfile/
- lang#elixir: not loaded https://spacevim.org/layers/lang/elixir/
- lang#elm: not loaded https://spacevim.org/layers/lang/elm/
- lang#erlang: not loaded https://spacevim.org/layers/lang/erlang/
- lang#extra: not loaded https://spacevim.org/layers/lang/extra/
- lang#fsharp: not loaded https://spacevim.org/layers/lang/fsharp/
- lang#go: not loaded https://spacevim.org/layers/lang/go/
- lang#graphql: not loaded https://spacevim.org/layers/lang/graphql/
- lang#haskell: not loaded https://spacevim.org/layers/lang/haskell/
- lang#html: not loaded https://spacevim.org/layers/lang/html/
- lang#java: not loaded https://spacevim.org/layers/lang/java/
- lang#javascript: not loaded https://spacevim.org/layers/lang/javascript/
- lang#json: not loaded no exists
- lang#julia: not loaded https://spacevim.org/layers/lang/julia/
- lang#kotlin: not loaded https://spacevim.org/layers/lang/kotlin/
- lang#latex: not loaded https://spacevim.org/layers/lang/latex/
- lang#lisp: not loaded https://spacevim.org/layers/lang/lisp/
- lang#lua: not loaded https://spacevim.org/layers/lang/lua/
- lang#markdown: not loaded https://spacevim.org/layers/lang/markdown/
- lang#nim: not loaded https://spacevim.org/layers/lang/nim/
- lang#ocaml: not loaded https://spacevim.org/layers/lang/ocaml/
- lang#perl: not loaded https://spacevim.org/layers/lang/perl/
- lang#php: not loaded https://spacevim.org/layers/lang/php/
- lang#plantuml: not loaded https://spacevim.org/layers/lang/plantuml/
- lang#pony: not loaded no exists
- lang#ps1: not loaded no exists
- lang#puppet: not loaded https://spacevim.org/layers/lang/puppet/
- lang#purescript: not loaded https://spacevim.org/layers/lang/purescript/
- lang#python: not loaded https://spacevim.org/layers/lang/python/
- lang#r: not loaded no exists
- lang#ruby: not loaded https://spacevim.org/layers/lang/ruby/
- lang#rust: not loaded https://spacevim.org/layers/lang/rust/
- lang#scala: not loaded https://spacevim.org/layers/lang/scala/
- lang#scheme: not loaded https://spacevim.org/layers/lang/scheme/
- lang#sh: not loaded https://spacevim.org/layers/lang/sh/
- lang#solidity: not loaded no exists
- lang#swift: not loaded https://spacevim.org/layers/lang/swift/
- lang#swig: not loaded no exists
- lang#toml: not loaded no exists
- lang#typescript: not loaded https://spacevim.org/layers/lang/typescript/
- lang#vim: not loaded https://spacevim.org/layers/lang/vim/
- lang#vue: not loaded https://spacevim.org/layers/lang/vue/
- lang#xml: not loaded no exists
- leaderf: not loaded https://spacevim.org/layers/leaderf/
- lsp: not loaded no exists
- mail: not loaded no exists
- operator: not loaded no exists
- org: not loaded no exists
+ shell: loaded https://spacevim.org/layers/shell/
- sudo: not loaded https://spacevim.org/layers/sudo/
- tags: not loaded https://spacevim.org/layers/tags/
- test: not loaded https://spacevim.org/layers/test/
- tmux: not loaded https://spacevim.org/layers/tmux/
- tools#dash: not loaded https://spacevim.org/layers/tools/dash/
- tools#screensaver: not loaded no exists
- tools: not loaded https://spacevim.org/layers/tools/
+ ui: loaded https://spacevim.org/layers/ui/
- unite: not loaded https://spacevim.org/layers/unite/
- vim: not loaded no exists
Screenshots
NA
―
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/SpaceVim/SpaceVim/issues/2354, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMiJkqs7b99RFNIZEdTjb0puph8ebu-zks5u5zrygaJpZM4ZVwYR.
@wsdjeg I usually keep makefile in each folder which I run while working in that folder. Sometime I want to copy files from other directory to current working directory using ! cp command in vim etc. When project root directory is always set to the directory of .git, I can no longer do these conviniently.
I agree that default setting is good for maven, cmake and other build system. But I use git repo and vim for various other purposes as well (bash, tex, markdown). The default behaviour can be bit confusing for people new to spacevim.
@ssfdust Probably I am doing something wrong, but I could not get it working. I've added following two lines in init.toml.
# force root directory to be the directory of current file.
project_rooter_patterns = []
project_rooter_automatically = 0
I can see value changed in the output of :SPDebugInfo.
project_rooter_automatically = 0
project_rooter_patterns = ['.clang']
but pwd still shows the .git directory as root directory.
what is result of :echo &autochdir?
0
I think there should be three kind behavior of vim:
Maybe we need to make some discussion about how to get these behavior.
same here, I'd really like vim not to change dir and stay where it was started from. I've tried the listed options before to no effect.
made a quick pr - my first one here... :)
now if you do not want to auto change dir to the root of your project, just Add project_rooter_automatically = 0, by default it is 1. and if you want to enable vim &autochdir . you can put set autochdir into bootstrap function.
the above is the solution of current version. I am not sure if we should Add an SpaceVim option for &autochdir or just rename project_rooter_automatically to change_directory_automatically. the value can be 0, 1 or 2
Thanks. It is working now.
Most helpful comment
@wsdjeg I usually keep
makefilein each folder which I run while working in that folder. Sometime I want to copy files from other directory to current working directory using! cpcommand in vim etc. When project root directory is always set to the directory of.git, I can no longer do these conviniently.I agree that default setting is good for
maven,cmakeand other build system. But I use git repo and vim for various other purposes as well (bash, tex, markdown). The default behaviour can be bit confusing for people new to spacevim.