1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 23:49:19 +08:00

Fix neovim py support (#1988)

This commit is contained in:
Wang Shidong 2018-07-28 10:58:12 +08:00 committed by GitHub
parent 2a3f8400ad
commit f1801f4ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 31 deletions

View File

@ -7,3 +7,5 @@ policies:
enabled: false
ProhibitAbbreviationOption:
enabled: false
ProhibitSetNoCompatible:
enabled: false

View File

@ -11,6 +11,13 @@ if has('vim_starting')
if &compatible
set nocompatible
endif
" python host
if !empty($PYTHON_HOST_PROG)
let g:python_host_prog = $PYTHON_HOST_PROG
endif
if !empty($PYTHON3_HOST_PROG)
let g:python3_host_prog = $PYTHON3_HOST_PROG
endif
endif
" Detect root directory of SpaceVim
let g:_spacevim_root_dir = fnamemodify(expand('<sfile>'),

View File

@ -1,14 +1,14 @@
function! s:GetVisual()
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][:col2 - 2]
let lines[0] = lines[0][col1 - 1:]
return lines
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][:col2 - 2]
let lines[0] = lines[0][col1 - 1:]
return lines
endfunction
function! REPLSend(lines)
call jobsend(g:last_terminal_job_id, add(a:lines, ''))
call jobsend(g:last_terminal_job_id, add(a:lines, ''))
endfunction
" }}}
" Commands {{{
@ -18,22 +18,23 @@ command! REPLSendLine call REPLSend([getline('.')])
" }}}
" https://github.com/syngan/vim-vimlint/issues/102
function! s:has(version) abort
return has(a:version)
return has(a:version)
endfunction
if !s:has('nvim-0.2.0')
let $NVIM_TUI_ENABLE_CURSOR_SHAPE = g:spacevim_terminal_cursor_shape
let $NVIM_TUI_ENABLE_CURSOR_SHAPE = g:spacevim_terminal_cursor_shape
else
if g:spacevim_terminal_cursor_shape == 0
" prevent nvim from changing the cursor shape
set guicursor=
elseif g:spacevim_terminal_cursor_shape == 1
" enable non-blinking mode-sensitive cursor
set guicursor=n-v-c:block-blinkon0,i-ci-ve:ver25-blinkon0,r-cr:hor20,o:hor50
elseif g:spacevim_terminal_cursor_shape == 2
" enable blinking mode-sensitive cursor
set guicursor=n-v-c:block-blinkon10,i-ci-ve:ver25-blinkon10,r-cr:hor20,o:hor50
endif
if g:spacevim_terminal_cursor_shape == 0
" prevent nvim from changing the cursor shape
set guicursor=
elseif g:spacevim_terminal_cursor_shape == 1
" enable non-blinking mode-sensitive cursor
set guicursor=n-v-c:block-blinkon0,i-ci-ve:ver25-blinkon0,r-cr:hor20,o:hor50
elseif g:spacevim_terminal_cursor_shape == 2
" enable blinking mode-sensitive cursor
set guicursor=n-v-c:block-blinkon10,i-ci-ve:ver25-blinkon10,r-cr:hor20,o:hor50
endif
endif
"silent! let &t_SI = "\<Esc>]50;CursorShape=1\x7"
"silent! let &t_SR = "\<Esc>]50;CursorShape=2\x7"
"silent! let &t_EI = "\<Esc>]50;CursorShape=0\x7"
@ -69,16 +70,16 @@ let g:terminal_color_14 = '#8ec07c'
let g:terminal_color_7 = '#a89984'
let g:terminal_color_15 = '#ebdbb2'
augroup Terminal
au!
au TermOpen * let g:last_terminal_job_id = b:terminal_job_id | IndentLinesDisable
au WinEnter,BufWinEnter term://* startinsert | IndentLinesDisable
if has('timers')
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer')
else
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call SpaceVim#mapping#close_term_buffer()
endif
au!
au TermOpen * let g:last_terminal_job_id = b:terminal_job_id | IndentLinesDisable
au WinEnter,BufWinEnter term://* startinsert | IndentLinesDisable
if has('timers')
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer')
else
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call SpaceVim#mapping#close_term_buffer()
endif
augroup END
augroup nvimrc_aucmd
autocmd!
autocmd CursorHold,FocusGained,FocusLost * rshada|wshada
autocmd!
autocmd CursorHold,FocusGained,FocusLost * rshada|wshada
augroup END

View File

@ -15,6 +15,7 @@ this is a list of most asked questions about SpaceVim.
- [E492: Not an editor command: ^M](#e492-not-an-editor-command-m)
- [Why SpaceVim can not display default colorscheme?](#why-spacevim-can-not-display-default-colorscheme)
- [Why I can not update plugins?](#why-i-can-not-update-plugins)
- [how to enable +py and +py3 in neovim?](#how-to-enable-py-and-py3-in-neovim)
<!-- vim-markdown-toc -->
@ -74,3 +75,16 @@ Sometimes you will see `Updating failed, The plugin dir is dirty`. Since the dir
directory is dirty, you can not use `git pull` to update plugin. To fix this issue, just move your cursor to the
error line, and press `gf`, then run `git reset --hard HEAD` or `git checkout .`. for more info, please read
documentation of git.
### how to enable +py and +py3 in neovim?
In neovim we can use `g:python_host_prog` and `g:python3_host_prog` to config python prog. but in SpaceVim
the custom configuration file is loaded after SpaceVim core code. so in SpaceVim itself, if we using `:py` command, it may cause errors.
so we intrude two new environment variable: `PYTHON_HOST_PROG` and `PYTHON3_HOST_PROG`.
for example:
```sh
export PYTHON_HOST_PROG='/home/q/envs/neovim2/bin/python'
export PYTHON3_HOST_PROG='/home/q/envs/neovim3/bin/python'
```

View File

@ -6,6 +6,4 @@
" License: GPLv3
"=============================================================================
" call neobundle#get()
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/config/main.vim'

View File

@ -23,6 +23,7 @@ The next release is v0.9.0.
- Improve plugin manager ([#1962](https://github.com/SpaceVim/SpaceVim/pull/1962))
- Support mouse click in tabline ([#1902](https://github.com/SpaceVim/SpaceVim/pull/1902))
- Add go def function for python ([#1969](https://github.com/SpaceVim/SpaceVim/pull/1969))
- neovim +py and +py3 support ([#1988](https://github.com/SpaceVim/SpaceVim/pull/1988))
### Changed