Back

vim - 使用vim9 + command t ,以及vim plugin

发布时间: 2023-05-03 00:57:00

refer to:

vim: https://github.com/vim/vim

command-t: https://github.com/wincent/command-t#readme

fuzzyfinder: https://github.com/junegunn/fzf.vim/

vim-plug: https://github.com/junegunn/vim-plug

多个plugin: https://www.makeuseof.com/best-vim-plugin-managers/

https://vi.stackexchange.com/questions/388/what-are-the-differences-between-the-vim-plugin-managers

下载编译和安装vim

https://souhaiebtar.github.io/how-to-compile-vim-and-install-command-t-extension/

先保证你的ruby版本是2.7.0 的。 (安装asdf, ruby的过程略 ) 

版本要正确:https://stackoverflow.com/questions/34829059/vim-command-t-in-ubuntu-command-t-vim-could-not-load-the-c-extension

安装支持 vim-ruby的包:
https://stackoverflow.com/questions/3794895/installing-vim-with-ruby-support-ruby

sudo apt install vim-nox  (这个包是支持到ruby 2.7.0 patch 0 的)

asdf global ruby 2.7.0

安装 python3

git clone https://github.com/vim/vim.git

./configure --prefix=/usr/local \
  --with-x \
  --disable-nls \
  --disable-netbeans \
  --disable-gui \
  --enable-multibyte \
  --enable-rubyinterp \
  --enable-python3interp \
  --with-features=huge \
  --with-tlib=ncurses \
  --enable-fail-if-missing 

make && sudo make install

使用

编辑 .vimrc

filetype on
set langmenu=none
set fileencodings=utf-8
set fileencoding=utf-8
set encoding=utf8

set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set number
set autoindent
set hlsearch
set incsearch
set encoding=utf-8
" highlight Normal ctermfg=white ctermbg=cyan
set nowrap
syntax enable

let g:proj_window_width=5
set laststatus=2


" map <C-T> :FufFile<CR>
map <C-E> :MRU<CR>
map <C-S-M> :Rmodel<CR>
map <C-S-C> :Rcontroller<CR>
map <C-S-U> :Runit<CR>
map <C-S-L> :Rfunctional<CR>
map <C-H> :Rhelper<CR>
map <C-V> :Rview<CR>
map <C-J> :ZoomWin<CR>


" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
    " Preparation: save last search, and cursor position.
    let _s=@/
    let l = line(".")
    let c = col(".")
    " Do the business:
    %s/\s\+$//e
    " Clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
endfunction
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()

" match Todo /\s\+$/
filetype plugin on
let mapleader = ","

" THE VIM OUTLINER (TVO)
" defaults:
let otl_install_menu=1
let no_otl_maps=0
let no_otl_insert_maps=0

" overrides:
let otl_bold_headers=0
let otl_use_thlnk=0

" au BufWinLeave *.otl mkview
" au BufWinEnter *.otl silent loadview
let maplocalleader = ","

""Only do this part when compiled with support for autocommands.
"if has("autocmd")
"  autocmd Filetype java setlocal omnifunc=javacomplete#Complete
"endif


set nocompatible               " be iMproved
filetype off                   " required!




" ============== Vundle part =================
set rtp+=~/.vim/bundle/vundle/

call plug#begin()

Plug 'gmarik/vundle'
Plug 'tpope/vim-fugitive'
Plug 'Lokaltog/vim-easymotion'
Plug 'tpope/vim-rails'
Plug 'vim-scripts/matchit.zip'
Plug 'ecomba/vim-ruby-refactoring'
Plug 'vim-scripts/L9'
Plug 'vim-scripts/FuzzyFinder'
Plug 'wincent/command-t'
Plug 'vim-scripts/YankRing.vim'
Plug 'tpope/vim-vividchalk'
Plug 'preservim/nerdcommenter'
Plug 'preservim/nerdtree'
Plug 'kchmck/vim-coffee-script'
Plug 'yegappan/mru'
Plug 'skwp/greplace.vim'
Plug 'tomlion/vim-solidity'

call plug#end()

colorscheme vividchalk
set background=light
set background=dark

filetype plugin indent on     " required!

map <S-F> <Leader><Leader>f
map <Leader>a :YRShow<CR>
map <Leader>t :NERDTree<CR>
map <Leader>q :q<CR>
map <Leader>f :Rfixture<CR>
map <Leader>rj :Rjavascript<CR>

"autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile --join appstore/static/javascripts/angular/controllers.js appstore/static/javascripts/angular/controllers.coffee appstore/static/javascripts/angular/tabs/*coffee appstore/static/javascripts/angular/applications/*coffee appstore/static/javascripts/angular/users/*coffee appstore/static/javascripts/angular/commons/*coffee
"autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile appstore/static/javascripts/angular/app.coffee appstore/static/javascripts/angular/directives.coffee appstore/static/javascripts/angular/filters.coffee appstore/static/javascripts/angular/services.coffee

"autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile --join tvboxcms/static/javascripts/angular/controllers.js tvboxcms/static/javascripts/angular/controllers.coffee tvboxcms/static/javascripts/angular/tabs/*coffee tvboxcms/static/javascripts/angular/applications/*coffee tvboxcms/static/javascripts/angular/users/*coffee tvboxcms/static/javascripts/angular/commons/*coffee
"autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile tvboxcms/static/javascripts/angular/app.coffee tvboxcms/static/javascripts/angular/directives.coffee tvboxcms/static/javascripts/angular/filters.coffee tvboxcms/static/javascripts/angular/services.coffee

"autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile --join m-cms-preview/static/javascripts/angular/controllers.js m-cms-preview/static/javascripts/angular/controllers.coffee m-cms-preview/static/javascripts/angular/tabs/*coffee m-cms-preview/static/javascripts/angular/applications/*coffee m-cms-preview/static/javascripts/angular/users/*coffee m-cms-preview/static/javascripts/angular/commons/*coffee
"autocmd BufWritePost,FileWritePost *.coffee :silent !coffee --compile m-cms-preview/static/javascripts/angular/app.coffee m-cms-preview/static/javascripts/angular/directives.coffee m-cms-preview/static/javascripts/angular/filters.coffee m-cms-preview/static/javascripts/angular/services.coffee
"
autocmd BufWritePost,FileWritePost *.raml silent! !raml2html doc/api.raml > public/api_doc.html
"
"
"" For fuf plugin , ignore the node_modules folder
" Truth be told, I don't remember what these do, but I must have
" found them necessary back when I installed fuzzyfinder years ago
let s:slash = '[/\\]'
let s:startname = '(^|'.s:slash.')'
let s:endname = '($|'.s:slash.')'

" directories and extensions to ignore when listing files
" these contain a lot of Python-isms, yours will probably vary
let s:extension = '\.bak|\.dll|\.exe|\.o|\.pyc|\.pyo|\.swp|\.swo'
let s:dirname = 'build|deploy|dist|vms|\.bzr|\.git|\.hg|\.svn|.+\.egg-info|node_modules|logs|log|tmp|coverage'
let g:fuf_file_exclude = '\v'.'('.s:startname.'('.s:dirname.')'.s:endname.')|(('.s:extension.')$)'
let g:fuf_dir_exclude = '\v'.s:startname.'('.s:dirname.')'.s:endname

" limit number of displayed matches
" (makes response instant even on huge source trees)
let g:fuf_enumeratingLimit = 200

然后下载 vim-plug 插件:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

进入vim ,然后 :PlugInstall

即可。

command-t的使用

$ vim --version  看一下是否支持ruby

asdf global ruby 2.7.0 切记这一点

cd ~/.vim/plugged/command-t/ruby/command-t/ext/command-t

ruby extconf.rb && make clean &&  make

sudo make install

就安装好了。

Back