mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 12:50:04 +08:00
feat(projectmanager): support project_non_root option
the RootchandgeCallback function should only be called on project.
This commit is contained in:
parent
0d26faa31d
commit
f458b75dcb
@ -2012,6 +2012,26 @@ For example, to ignore the `node_packages/` directory:
|
||||
project_rooter_outermost = false
|
||||
```
|
||||
|
||||
There are three options for non-project files/directories:
|
||||
|
||||
- Don't change directory (default).
|
||||
|
||||
```
|
||||
project_non_root = ''
|
||||
```
|
||||
|
||||
- Change to file's directory (similar to 'autochdir').
|
||||
|
||||
```
|
||||
project_non_root = 'current'
|
||||
```
|
||||
|
||||
- Change to home directory.
|
||||
|
||||
```
|
||||
project_non_root = 'home'
|
||||
```
|
||||
|
||||
You can also disable project root detection completely (i.e. vim will set the
|
||||
root directory to the present working directory):
|
||||
|
||||
@ -2385,7 +2405,7 @@ The default color for iedit is `red`/`green` which is based on the current color
|
||||
|
||||
SpaceVim provides an asynchronous code runner plugin. In most language layers,
|
||||
the key binding `SPC l r` is defined for running the current buffer.
|
||||
To close the code runner windows, you can use ``Ctrl-` `` key binding.
|
||||
To close the code runner windows, you can use `` Ctrl-` `` key binding.
|
||||
If you need to add new commands, you can use the bootstrap function. For example:
|
||||
Use `F5` to build the project asynchronously.
|
||||
|
||||
@ -2400,7 +2420,6 @@ Key bindings within code runner buffer:
|
||||
| `ctrl-c` | stop code runner |
|
||||
| `i` | open promote to insert text |
|
||||
|
||||
|
||||
#### Custom runner
|
||||
|
||||
If you want to set custom code runner for specific language. You need to use `SpaceVim#plugins#runner#reg_runner(ft, runner)` api in bootstrap function.
|
||||
|
@ -383,13 +383,30 @@ function M.current_root()
|
||||
if rootdir == '' then
|
||||
rootdir = find_root_directory()
|
||||
if rootdir == nil or rootdir == '' then
|
||||
rootdir = sp_file.unify_path(fn.getcwd())
|
||||
-- for no project
|
||||
if vim.g.spacevim_project_non_root == '' then
|
||||
rootdir = sp_file.unify_path(fn.getcwd())
|
||||
elseif vim.g.spacevim_project_non_root == 'home' and filereadable(bufname) then
|
||||
rootdir = sp_file.unify_path(fn.expand('~'))
|
||||
elseif vim.g.spacevim_project_non_root == 'current' then
|
||||
local dir = sp_file.unify_path(bufname, ':p:h')
|
||||
if isdirectory(dir) then
|
||||
rootdir = dir
|
||||
else
|
||||
rootdir = sp_file.unify_path(fn.getcwd())
|
||||
end
|
||||
else
|
||||
-- maybe log error
|
||||
end
|
||||
change_dir(rootdir)
|
||||
else
|
||||
-- for project
|
||||
if change_dir(rootdir) then
|
||||
M.RootchandgeCallback()
|
||||
end
|
||||
end
|
||||
fn.setbufvar('%', 'rootDir', rootdir)
|
||||
end
|
||||
if change_dir(rootdir) then
|
||||
M.RootchandgeCallback()
|
||||
end
|
||||
return rootdir
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user