separate plugin from vimrc, rename vimrc

new nmap on `:tabe vimrc` relevant
merge 2 augroups in vimrc
remove popup from 'completeopt' which fails on other platform
This commit is contained in:
sup39 2020-05-04 11:28:26 +09:00
parent 41e8267aee
commit 9e8c6a35d7
3 changed files with 69 additions and 64 deletions

View file

@ -5,27 +5,27 @@ and to record the evolutionary history of my vimrc.
Not suitable for others now, but I will try to improve it.
## Installation
### Install [vim-plug](https://github.com/junegunn/vim-plug)
```sh
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```
### Clone this repo
```sh
git clone https://github.com/sup39/vimrc $HOME/.vim/sup39
```
### Import in your vimrc
You can simply use it.
In your vimrc:
```vim
" In your vimrc
" If you want to use vim-plug that I'm using:
" This script will install vim-plug automatically.
" Make sure to source plug.vim BEFORE vimrc
source $HOME/.vim/sup39/plug.vim
" set your `mapleader` and `maplocalleader` here if you want
source $HOME/.vim/sup39/sup39.vimrc
source $HOME/.vim/sup39/vimrc
" you can override my settings here
```
Or maybe make a Activate Command.
Alternatively, you can make a activate command to source it manually.
```vim
" In your vimrc
command Sup39Source source $HOME/.vim/sup39/sup39.vimrc
command Sup39Source source $HOME/.vim/sup39/vimrc
" anywhere when you want to activate it
:Sup39Source
" You may need to :e to trigger the autocmd

41
plug.vim Normal file
View file

@ -0,0 +1,41 @@
if !filereadable($HOME.'/.vim/autoload/plug.vim')
echom 'Installing vim-plug...'
call system('curl -fLo $HOME/.vim/autoload/plug.vim --create-dirs '.
\'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
source $HOME/.vim/autoload/plug.vim
echom 'DONE! You may need to :PlugInstall to install listed plugins'
endif
" plugin
call plug#begin('~/.vim/plugged')
" basic
Plug 'tpope/vim-sensible'
" markdown syntax
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_new_list_item_indent = 0
let g:vim_markdown_math = 1
" markdown preview
Plug 'iamcco/markdown-preview.nvim', {'do': 'cd app & yarn install'}
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 0
let g:mkdp_preview_options = {
\ 'katex': {
\ 'macros': {
\ '\s': '\square',
\ },
\ },
\}
" ale
Plug 'dense-analysis/ale'
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_sign_column_always = 1
let g:ale_completion_enabled = 1
let g:ale_linters = {
\ 'cpp': ['gcc'],
\ 'swift': ['sourcekitlsp'],
\ }
call plug#end()

View file

@ -1,11 +1,12 @@
" map-leader
if !exists('mapleader')
let mapleader='q'
nnoremap q <nop>
nnoremap <leader> <nop>
nnoremap Q q
endif
if !exists('maplocalleader')
let maplocalleader='qw'
noremap <localleader> <nop>
endif
inoremap jk <ESC>
" file
@ -16,7 +17,9 @@ inoremap jk <ESC>
nnoremap <leader>C :w !pbcopy<CR><CR>
" tab edit
nnoremap <leader>e :tabe
nnoremap <leader>v :tabe $HOME/.vim/sup39/sup39.vimrc<CR>
nnoremap <leader>vv :tabe $HOME/.vim/sup39/vimrc<CR>
nnoremap <leader>vp :tabe $HOME/.vim/sup39/plug.vim<CR>
nnoremap <leader>vd :tabe $HOME/.vim/sup39/
nnoremap <leader>V :tabe $MYVIMRC<CR>
" search
nnoremap / /\v
@ -41,7 +44,7 @@ nnoremap <leader>X :exe getline('.')<CR>
nnoremap <leader>H :echo synIDattr(synID(line("."),col("."),1),"name")<CR>
" filetype-dependent
augroup sup39_map
augroup sup39_auto
autocmd!
" vim
" source
@ -58,7 +61,17 @@ augroup sup39_map
autocmd Filetype c,cpp iabbrev <buffer> #i #include
" markdown
" plugin
nnoremap <localleader>p :MarkdownPreview<CR>
autocmd Filetype markdown nnoremap <localleader>p :MarkdownPreview<CR>
" COMMON
" disable auto comment prefix
autocmd Filetype * setlocal formatoptions-=ro
" keyword
autocmd Filetype javascript,typescript,vue setlocal iskeyword+=$
autocmd Filetype html,vue setlocal iskeyword+=-
" tab
autocmd FileType make,java,python setlocal noexpandtab
" syntax sync
autocmd FileType markdown,vue syntax sync fromstart
augroup END
" basic
@ -76,53 +89,4 @@ set autoindent smartindent
let g:vim_indent_cont = 0
" completion
set completeopt=menu,menuone,popup,noselect,noinsert
" plugin
call plug#begin('~/.vim/plugged')
" basic
Plug 'tpope/vim-sensible'
" markdown syntax
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_new_list_item_indent = 0
let g:vim_markdown_math = 1
" markdown preview
Plug 'iamcco/markdown-preview.nvim', {'do': 'cd app & yarn install'}
let g:mkdp_auto_start = 0
let g:mkdp_auto_close = 0
let g:mkdp_preview_options = {
\ 'katex': {
\ 'macros': {
\ '\s': '\square',
\ },
\ },
\}
" ale
Plug 'dense-analysis/ale'
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_sign_column_always = 1
let g:ale_completion_enabled = 1
let g:ale_linters = {
\ 'cpp': ['gcc'],
\ 'swift': ['sourcekitlsp'],
\ }
call plug#end()
" override
augroup sup39_override
autocmd!
" override plugin
autocmd Filetype * setlocal formatoptions-=ro
" keyword
autocmd Filetype javascript,typescript,vue setlocal iskeyword+=$
autocmd Filetype html,vue setlocal iskeyword+=-
" tab
autocmd FileType make,java,python setlocal noexpandtab
" syntax
autocmd FileType markdown,vue syntax sync fromstart
augroup END
set completeopt=menu,menuone,noselect,noinsert