如何在你的Android手机上配置 Python 环境?( 三 )

  • 使用vim-plug安装NeoVim插件
vim-plug是一款Vim插件管理工具,支持异步并行,可以快速安装、更新或卸载插件 。可以通过如下命令进行安装,或手动下载plug.vim文件,复制到在~/.config/nvim/autoload文件夹中 。
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirshttps://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim使用vim-plug时,需要在init.vim中添加下列代码块 。
" vim-plug插件管理call plug#begin('~/.config/nvim/plugged')Plug 'junegunn/vim-plug'call plug#end()保存后,在普通模式下输入:so %使配置文件生效,再通过:PlugInstall进行安装 。
  • 常用插件及设置
下面列举了一下常用插件和基本设置:
call plug#begin('~/.config/nvim/plugged')Plug 'junegunn/vim-plug'" git支持Plug 'tpope/vim-fugitive'" Python自动缩进插件Plug 'vim-scripts/indentpython.vim'" 项目管理工具Plug 'mhinz/vim-startify'" 快速对齐插件Plug 'junegunn/vim-easy-align'" 当前光标下的单词增加下划线Plug 'itchyny/vim-cursorword'" 快速选择插件Plug 'tpope/vim-surround'" 自定义代码片断Plug 'honza/vim-snippets'" 语法高亮支持Plug 'sheerun/vim-polyglot'" 主题、状态栏设置Plug 'haishanh/night-owl.vim'Plug 'vim-airline/vim-airline'Plug 'vim-airline/vim-airline-themes'Plug 'ryanoasis/vim-devicons'" coc扩展Plug 'neoclide/coc.nvim', {'branch': 'release'}" fzf模糊查找Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }Plug 'junegunn/fzf.vim'" whichkey快捷菜单Plug 'liuchengxu/vim-which-key" 浮动窗口支持Plug 'voldikss/vim-floaterm'" ranger文件管理器支持Plug 'kevinhwang91/rnvimr'call plug#end()" 启用标签栏let g:airline#extensions#tabline#enabled = 1" 支持图标字体let g:airline_powerline_fonts = 1" 设置状态栏主题let g:airline_theme='night_owl'" 设置主题set termguicolorslet &t_8f = "<Esc>[38;2;%lu;%lu;%lum"let &t_8b = "<Esc>[48;2;%lu;%lu;%lum"syntax enablecolorscheme night-owl
如何在你的Android手机上配置 Python 环境?

文章插图
 
  • 安装、配置coc.nvim扩展
coc.nvim是一款支持扩展的插件,类似于油猴,可以通过安装扩展,以实现像Vscode一样使用NeoVim,下面列举了Python相关的coc扩展和配置:
" coc扩展let g:coc_global_extensions = ['coc-json','coc-pyright','coc-snippets','coc-xml','coc-explorer','coc-prettier','coc-highlight']" 使用tab键进行补全选择inoremap <silent><expr> <TAB>pumvisible() ? "<C-n>" :<SID>check_back_space() ? "<TAB>" :coc#refresh()inoremap <expr><S-TAB> pumvisible() ? "<C-p>" : "<C-h>"function! s:check_back_space() abortlet col = col('.') - 1return !col || getline('.')[col - 1]=~# 's'endfunction" 使用回车进行补全选择inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm(): "<C-g>u<CR><c-r>=coc#on_enter()<CR>"" Highlight the symbol and its references when holding the cursor.autocmd CursorHold * silent call CocActionAsync('highlight')" Add `:Format` command to format current buffer.command! -nargs=0 Format :call CocAction('format')" Add `:Fold` command to fold current buffer.command! -nargs=? Fold :callCocAction('fold', <f-args>)" Add `:OR` command for organize imports of the current buffer.command! -nargs=0 OR:callCocAction('runCommand', 'editor.action.organizeImport')" 添加状态栏显示支持set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}" 启用Prettier进行文件自动格式化command! -nargs=0 Prettier :CocCommand prettier.formatFilelet g:prettier#autoformat = 1" 设置Coc Searchnnoremap <leader>? :CocSearch <C-R>=expand("<cword>")<CR><CR>此外,coc扩展可以通过在~/.config/nvim/文件夹中创建coc-settings.json文件来进行配置:
{"python.defaultInterpreterPath": "/data/data/com.termux/files/usr/bin/python","python.pythonPath": "/data/data/com.termux/files/usr/bin/python","python.linting.pylintEnable":true,"python.formatting.provider": "yapf","python.formatting.yapfArgs": ["--style","{SPACES_AROUND_POWER_OPERATOR: True, SPACES_BEFORE_COMMENT: 1}"],"explorer.width": 38,"explorer.quitOnOpen": true,"explorer.sources": [{"name": "buffer","expand": false},{"name": "file","expand": true}],"explorer.file.column.indent.indentLine": true,"explorer.file.showHiddenFiles": true,"explorer.icon.enableNerdfont": true,"explorer.keyMappingMode": "none","explorer.buffer.showHiddenBuffers": false,"explorer.keyMappings.global": {"o": ["wait", "expanded?", "collapse", "expand"],"<cr>": ["wait", "expandable?", "cd", "open"],"?": "help","q": "quit"},"coc.preferences.formatOnSaveFiletypes": ["*"],"prettier.printWidth": 100,"prettier.eslintIntegration": true,"prettier.disableLanguages": [],"prettier.formatterPriority": 1,"prettier.useTabs": true,"prettier.trailingComma": "all","prettier.singleQuote": false,"prettier.tabWidth": 4}


推荐阅读