我可以对我的 .vimrc 做哪些改进来改善我在 NeoVim 中的体验?
What improvements can I do to my .vimrc to improve my experience in NeoVim?
这是我的 .vimrc
call plug#begin('~/.vim/plugged')
Plug 'dart-lang/dart-vim-plugin'
Plug 'natebosch/vim-lsc'
Plug 'natebosch/vim-lsc-dart'
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' }
Plug 'ncm2/ncm'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'codota/tabnine-vim'
Plug 'Chiel92/vim-autoformat'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'jiangmiao/auto-pairs'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\}
" Plug 'valloric/youcompleteme'
let g:lsc_server_commands = {'dart': 'dart_language_server'}
call plug#end()
let g:ale_fixers = {
\ 'javascript': ['eslint']
\}
let g:ale_sign_error = '❌'
let g:ale_sign_warning = '⚠️'
let g:lsc_enable_autocomplete = v:true
let g:lsc_auto_map = v:true
let g:ale_fix_on_save = 1
let g:ale_javascript_prettier_use_local_config = 1
let g:ale_javascript_eslint_options = '-c ~/.eslintrc'
let g:ale_lint_on_enter = 0
let g:ansible_unindent_after_newline = 1
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
" set softtabstop=2
" set shiftwidth=2
" set expandtab
set expandtab
" show existing tab with 2 spaces width
set tabstop=2
set softtabstop=2
" when indenting with '>', use 2 spaces width
set shiftwidth=2
nnoremap <A-Down> :m .+1<CR>==
nnoremap <A-Up> :m .-2<CR>==
inoremap <A-Down> <Esc>:m .+1<CR>==gi
inoremap <A-Up> <Esc>:m .-2<CR>==gi
vnoremap <A-Down> :m '>+1<CR>gv=gv
vnoremap <A-Up> :m '<-2<CR>gv=gv
set statusline=%<%f\ %h%m%r%{kite#statusline()}%=%-14.(%l,%c%V%)\ %P
set laststatus=2
let g:python3_host_prog='/home/thebozzkg/anaconda3/bin/python3'
au BufWrite * :Autoformat
let g:airline#extensions#tabline#enabled = 1
let g:airline_detect_spell=1
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.dirty='⚡'
nnoremap <ALT-Left> :tabprevious<CR>
nnoremap <ALT-Right> :tabnext<CR>
关于我的一些注意事项:
- 我不用hjkl我用方向键(请不要侮辱我)
- 我在 neovim 中编写 Javascript、Dart、Markdown、YAML、JSON、C 和 C++(到目前为止)(我正在从 VSCode 切换)
- 我拥有的大部分内容都是从 GitHub 和一些 Vim wiki
中复制的
- 我安装了 Anaconda
- 我正在使用 Ubuntu Linux 20.04(如果重要的话)
出于某种原因,我不知道是哪个插件在执行此操作,但我的自动完成功能一直在弄乱我的文件(编辑 YAML 文件并保存它们绝对是一种折磨,几乎所有文件都会丢失一些缩进)并且还会崩溃(TabNine)
谁能帮我解决这个问题?
欢迎来到Vim!
我认为大多数 vim 新用户都去过那里。我当然有!我想要一个
'vim as python IDE' 并从下面的每个博客中复制了一大堆东西
安装 vim.
后几乎立即进入我的 vimrc
在花了一些时间与所有设置、插件和重新映射打交道之后,我
不明白,我决定逐行浏览我的 vimrc 并发表评论
把我不明白的东西(几乎全部)都说出来。
然后我使用了这个更小的 vim 一段时间,每当我决定我有一个
需要某个功能,我检查了大部分评论的 vimrc 是否有任何内容
看起来相关,and/or 通过谷歌搜索 仅针对该特定功能。经常
你会发现有一个内置的方法可以使用核心 vim 命令来完成它,
如果没有,那么这个问题有很多解决方案(通常,你
发现有一种您没有想到的更强大的方法 - 这些
是好日子)。
但关键是不要试图在一夜之间将 vim 变成一个巨大的 IDE!让它
逐渐发生,事情会变得更有意义,你最终会得到一个
vimrc 你理解并因此能够添加到它并进行调整
它。
最后要说的是推荐以下书籍:
'Learn VimScript the Hard Way' 史蒂夫·洛斯
'Practical Vim' 德鲁·尼尔 (Drew Neil) 和他的伴奏 screencast series。
(还有 The Primagean high quality youtube tutorials)
说了这么多,并承认无法给出 objective 答案
对于你的问题,这里有一个最小的 vimrc,它有一些插件和设置
做简单但非常有用的事情(但一定要仔细阅读它们以了解如何
他们工作!):
"==== PLUGINS =================================================================
set nocompatible " don't try to be compatible with Vi
filetype plugin indent on " use default plugins
call plug#begin('~/.vim/plugged')
" plugins I would put in a new vimrc
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'vim-scripts/ReplaceWithRegister'
Plug 'flazz/vim-colorschemes'
"==== CUSTOM CONFIGURATIONS ===================================================
"- general settings -----------------------------------------------------------
set encoding=utf-8
set linebreak " wrap long lines at char in 'breakat' (default " ^I!@*-+;:,./?")
set nowrap " don't wrap lines by default
set expandtab " expand tabs into spaces
set tabstop=4 " a tab is the same as 4 spaces
set softtabstop=4 " when I hit <tab> in insert mode, put 4 spaces
set shiftwidth=4 " when auto-indenting, use 4 spaces per tab
set autoindent " when creating a new line, copy indent from line above
set incsearch " show matches for patterns while they are being typed
set smartcase " with both on, searches with no capitals are case insensitive...
set ignorecase " ...while searches with capital characters are case sensitive.
set spell spelllang=en
set nospell " don't hightlight misspellings unles I say so
set lazyredraw " don't redraw screen during macros (let them complete faster)
set t_Co=256 " use full colours
syntax enable " highlight special words to aid readability
colorscheme zenburn
" THIS NEXT BIT I DEBATED INCLUDING - IT'S MY PERSONAL PREFERENCE AND BY
NO MEANS 'NECESSARY' AND COULD SAFELY BE EXCLUDED... BUT I JUST HATED THE
BLOCK CURSOR IN INSERT MODE SO MUCH...
"- cursor behaviour (make cursor blink for insert mode, block for normal mode)
augroup cursor_behaviour
autocmd!
" reset cursor on start:
autocmd VimEnter * silent !echo -ne "\e[2 q"
" cursor blinking bar on insert mode
let &t_SI = "\e[5 q"
" cursor steady block on command mode
let &t_EI = "\e[2 q"
" highlight current line when in insert mode
autocmd InsertEnter * set cursorline
" turn off current line hightlighting when leaving insert mode
autocmd InsertLeave * set nocursorline
augroup END
祝你好运!
这是我的 .vimrc
call plug#begin('~/.vim/plugged')
Plug 'dart-lang/dart-vim-plugin'
Plug 'natebosch/vim-lsc'
Plug 'natebosch/vim-lsc-dart'
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
Plug 'pearofducks/ansible-vim', { 'do': './UltiSnips/generate.sh' }
Plug 'ncm2/ncm'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-bufword'
Plug 'ncm2/ncm2-path'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'codota/tabnine-vim'
Plug 'Chiel92/vim-autoformat'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'jiangmiao/auto-pairs'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\}
" Plug 'valloric/youcompleteme'
let g:lsc_server_commands = {'dart': 'dart_language_server'}
call plug#end()
let g:ale_fixers = {
\ 'javascript': ['eslint']
\}
let g:ale_sign_error = '❌'
let g:ale_sign_warning = '⚠️'
let g:lsc_enable_autocomplete = v:true
let g:lsc_auto_map = v:true
let g:ale_fix_on_save = 1
let g:ale_javascript_prettier_use_local_config = 1
let g:ale_javascript_eslint_options = '-c ~/.eslintrc'
let g:ale_lint_on_enter = 0
let g:ansible_unindent_after_newline = 1
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
" set softtabstop=2
" set shiftwidth=2
" set expandtab
set expandtab
" show existing tab with 2 spaces width
set tabstop=2
set softtabstop=2
" when indenting with '>', use 2 spaces width
set shiftwidth=2
nnoremap <A-Down> :m .+1<CR>==
nnoremap <A-Up> :m .-2<CR>==
inoremap <A-Down> <Esc>:m .+1<CR>==gi
inoremap <A-Up> <Esc>:m .-2<CR>==gi
vnoremap <A-Down> :m '>+1<CR>gv=gv
vnoremap <A-Up> :m '<-2<CR>gv=gv
set statusline=%<%f\ %h%m%r%{kite#statusline()}%=%-14.(%l,%c%V%)\ %P
set laststatus=2
let g:python3_host_prog='/home/thebozzkg/anaconda3/bin/python3'
au BufWrite * :Autoformat
let g:airline#extensions#tabline#enabled = 1
let g:airline_detect_spell=1
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.dirty='⚡'
nnoremap <ALT-Left> :tabprevious<CR>
nnoremap <ALT-Right> :tabnext<CR>
关于我的一些注意事项:
- 我不用hjkl我用方向键(请不要侮辱我)
- 我在 neovim 中编写 Javascript、Dart、Markdown、YAML、JSON、C 和 C++(到目前为止)(我正在从 VSCode 切换)
- 我拥有的大部分内容都是从 GitHub 和一些 Vim wiki 中复制的
- 我安装了 Anaconda
- 我正在使用 Ubuntu Linux 20.04(如果重要的话)
出于某种原因,我不知道是哪个插件在执行此操作,但我的自动完成功能一直在弄乱我的文件(编辑 YAML 文件并保存它们绝对是一种折磨,几乎所有文件都会丢失一些缩进)并且还会崩溃(TabNine)
谁能帮我解决这个问题?
欢迎来到Vim!
我认为大多数 vim 新用户都去过那里。我当然有!我想要一个 'vim as python IDE' 并从下面的每个博客中复制了一大堆东西 安装 vim.
后几乎立即进入我的 vimrc在花了一些时间与所有设置、插件和重新映射打交道之后,我 不明白,我决定逐行浏览我的 vimrc 并发表评论 把我不明白的东西(几乎全部)都说出来。
然后我使用了这个更小的 vim 一段时间,每当我决定我有一个 需要某个功能,我检查了大部分评论的 vimrc 是否有任何内容 看起来相关,and/or 通过谷歌搜索 仅针对该特定功能。经常 你会发现有一个内置的方法可以使用核心 vim 命令来完成它, 如果没有,那么这个问题有很多解决方案(通常,你 发现有一种您没有想到的更强大的方法 - 这些 是好日子)。
但关键是不要试图在一夜之间将 vim 变成一个巨大的 IDE!让它 逐渐发生,事情会变得更有意义,你最终会得到一个 vimrc 你理解并因此能够添加到它并进行调整 它。
最后要说的是推荐以下书籍:
'Learn VimScript the Hard Way' 史蒂夫·洛斯
'Practical Vim' 德鲁·尼尔 (Drew Neil) 和他的伴奏 screencast series。
(还有 The Primagean high quality youtube tutorials)
说了这么多,并承认无法给出 objective 答案 对于你的问题,这里有一个最小的 vimrc,它有一些插件和设置 做简单但非常有用的事情(但一定要仔细阅读它们以了解如何 他们工作!):
"==== PLUGINS =================================================================
set nocompatible " don't try to be compatible with Vi
filetype plugin indent on " use default plugins
call plug#begin('~/.vim/plugged')
" plugins I would put in a new vimrc
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'vim-scripts/ReplaceWithRegister'
Plug 'flazz/vim-colorschemes'
"==== CUSTOM CONFIGURATIONS ===================================================
"- general settings -----------------------------------------------------------
set encoding=utf-8
set linebreak " wrap long lines at char in 'breakat' (default " ^I!@*-+;:,./?")
set nowrap " don't wrap lines by default
set expandtab " expand tabs into spaces
set tabstop=4 " a tab is the same as 4 spaces
set softtabstop=4 " when I hit <tab> in insert mode, put 4 spaces
set shiftwidth=4 " when auto-indenting, use 4 spaces per tab
set autoindent " when creating a new line, copy indent from line above
set incsearch " show matches for patterns while they are being typed
set smartcase " with both on, searches with no capitals are case insensitive...
set ignorecase " ...while searches with capital characters are case sensitive.
set spell spelllang=en
set nospell " don't hightlight misspellings unles I say so
set lazyredraw " don't redraw screen during macros (let them complete faster)
set t_Co=256 " use full colours
syntax enable " highlight special words to aid readability
colorscheme zenburn
" THIS NEXT BIT I DEBATED INCLUDING - IT'S MY PERSONAL PREFERENCE AND BY
NO MEANS 'NECESSARY' AND COULD SAFELY BE EXCLUDED... BUT I JUST HATED THE
BLOCK CURSOR IN INSERT MODE SO MUCH...
"- cursor behaviour (make cursor blink for insert mode, block for normal mode)
augroup cursor_behaviour
autocmd!
" reset cursor on start:
autocmd VimEnter * silent !echo -ne "\e[2 q"
" cursor blinking bar on insert mode
let &t_SI = "\e[5 q"
" cursor steady block on command mode
let &t_EI = "\e[2 q"
" highlight current line when in insert mode
autocmd InsertEnter * set cursorline
" turn off current line hightlighting when leaving insert mode
autocmd InsertLeave * set nocursorline
augroup END
祝你好运!