From 9e8c6a35d7e56153813d0c13dd247d8cba23bc45 Mon Sep 17 00:00:00 2001 From: sup39 Date: Mon, 4 May 2020 11:28:26 +0900 Subject: [PATCH] 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 --- README.md | 20 ++++++------ plug.vim | 41 +++++++++++++++++++++++++ sup39.vimrc => vimrc | 72 +++++++++++--------------------------------- 3 files changed, 69 insertions(+), 64 deletions(-) create mode 100644 plug.vim rename sup39.vimrc => vimrc (58%) diff --git a/README.md b/README.md index 8c8637e..b2789f2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/plug.vim b/plug.vim new file mode 100644 index 0000000..aaa9459 --- /dev/null +++ b/plug.vim @@ -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() diff --git a/sup39.vimrc b/vimrc similarity index 58% rename from sup39.vimrc rename to vimrc index 1f45666..ac5f001 100644 --- a/sup39.vimrc +++ b/vimrc @@ -1,11 +1,12 @@ " map-leader if !exists('mapleader') let mapleader='q' - nnoremap q + nnoremap nnoremap Q q endif if !exists('maplocalleader') let maplocalleader='qw' + noremap endif inoremap jk " file @@ -16,7 +17,9 @@ inoremap jk nnoremap C :w !pbcopy " tab edit nnoremap e :tabe - nnoremap v :tabe $HOME/.vim/sup39/sup39.vimrc + nnoremap vv :tabe $HOME/.vim/sup39/vimrc + nnoremap vp :tabe $HOME/.vim/sup39/plug.vim + nnoremap vd :tabe $HOME/.vim/sup39/ nnoremap V :tabe $MYVIMRC " search nnoremap / /\v @@ -41,7 +44,7 @@ nnoremap X :exe getline('.') nnoremap H :echo synIDattr(synID(line("."),col("."),1),"name") " filetype-dependent -augroup sup39_map +augroup sup39_auto autocmd! " vim " source @@ -58,7 +61,17 @@ augroup sup39_map autocmd Filetype c,cpp iabbrev #i #include " markdown " plugin - nnoremap p :MarkdownPreview + autocmd Filetype markdown nnoremap p :MarkdownPreview + " 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