init
This commit is contained in:
commit
41e8267aee
3 changed files with 184 additions and 0 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2020 sup39 <sup39hakujun@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
35
README.md
Normal file
35
README.md
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# vimrc for sup39
|
||||||
|
## Description
|
||||||
|
Well, just a place to put my vimrc,
|
||||||
|
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.
|
||||||
|
```vim
|
||||||
|
" In your vimrc
|
||||||
|
" set your `mapleader` and `maplocalleader` here if you want
|
||||||
|
source $HOME/.vim/sup39/sup39.vimrc
|
||||||
|
" you can override my settings here
|
||||||
|
```
|
||||||
|
Or maybe make a Activate Command.
|
||||||
|
```vim
|
||||||
|
" In your vimrc
|
||||||
|
command Sup39Source source $HOME/.vim/sup39/sup39.vimrc
|
||||||
|
" anywhere when you want to activate it
|
||||||
|
:Sup39Source
|
||||||
|
" You may need to :e to trigger the autocmd
|
||||||
|
```
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
Steve Losh (2013) [Learn Vimscript the Hard Way](https://learnvimscriptthehardway.stevelosh.com)
|
128
sup39.vimrc
Normal file
128
sup39.vimrc
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
" map-leader
|
||||||
|
if !exists('mapleader')
|
||||||
|
let mapleader='q'
|
||||||
|
nnoremap q <nop>
|
||||||
|
nnoremap Q q
|
||||||
|
endif
|
||||||
|
if !exists('maplocalleader')
|
||||||
|
let maplocalleader='qw'
|
||||||
|
endif
|
||||||
|
inoremap jk <ESC>
|
||||||
|
" file
|
||||||
|
" save
|
||||||
|
nnoremap <C-S> :w<CR>
|
||||||
|
inoremap <C-S> <ESC>:w<CR>
|
||||||
|
" copy
|
||||||
|
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>V :tabe $MYVIMRC<CR>
|
||||||
|
" search
|
||||||
|
nnoremap / /\v
|
||||||
|
nnoremap ? ?\v
|
||||||
|
nnoremap <leader>sl :s/\v
|
||||||
|
nnoremap <leader>se :.,$s/\v
|
||||||
|
nnoremap <leader>ss :%s/\v
|
||||||
|
nnoremap <leader>hh :set hlsearch! incsearch!<CR>
|
||||||
|
nnoremap <leader>hc :nohlsearch<CR>
|
||||||
|
" ale
|
||||||
|
nnoremap <leader>r :ALERename<CR>
|
||||||
|
nnoremap <leader>n :ALENext<CR>
|
||||||
|
nnoremap <leader>p :ALEPrevious<CR>
|
||||||
|
nnoremap <leader><space> :ALEHover<CR>
|
||||||
|
nnoremap <leader>db :ALEGoToDefinition -tab<CR>
|
||||||
|
nnoremap <leader>dm :ALEGoToDefinition<CR>
|
||||||
|
nnoremap <leader>dl :ALEDetail<CR>
|
||||||
|
" external
|
||||||
|
nnoremap <leader>m :w<CR>:make<CR>
|
||||||
|
" debug
|
||||||
|
nnoremap <leader>X :exe getline('.')<CR>
|
||||||
|
nnoremap <leader>H :echo synIDattr(synID(line("."),col("."),1),"name")<CR>
|
||||||
|
|
||||||
|
" filetype-dependent
|
||||||
|
augroup sup39_map
|
||||||
|
autocmd!
|
||||||
|
" vim
|
||||||
|
" source
|
||||||
|
autocmd Filetype vim noremap <buffer> <localleader>s :w<CR>:so %<CR>
|
||||||
|
" c, cpp
|
||||||
|
" macro
|
||||||
|
autocmd Filetype c,cpp noremap <buffer> <localleader>h
|
||||||
|
\:call setline('.', toupper(substitute(@%, '\.', '_', 'g')))<CR>
|
||||||
|
\yyI#ifndef <C-O>p#define <C-O>o<CR><CR><CR>#endif<ESC>kki
|
||||||
|
autocmd Filetype c,cpp noremap <buffer> <localleader>i
|
||||||
|
\:call setline('.',
|
||||||
|
\'#include "'.substitute(@%, '\.\zsc\ze\(pp\)\?$', 'h', '').'"')<CR>o
|
||||||
|
" abbr
|
||||||
|
autocmd Filetype c,cpp iabbrev <buffer> #i #include
|
||||||
|
" markdown
|
||||||
|
" plugin
|
||||||
|
nnoremap <localleader>p :MarkdownPreview<CR>
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
" basic
|
||||||
|
filetype on
|
||||||
|
syntax on
|
||||||
|
set encoding=utf-8
|
||||||
|
set backspace=indent,eol,start
|
||||||
|
set nocompatible
|
||||||
|
set nofoldenable
|
||||||
|
|
||||||
|
" indent
|
||||||
|
set list listchars=tab:\▸\-
|
||||||
|
set tabstop=2 shiftwidth=2 softtabstop=2 expandtab smarttab
|
||||||
|
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
|
Loading…
Reference in a new issue