commit 41e8267aeecbe3d347854f40cb751ce7bf5890aa Author: sup39 Date: Sun May 3 18:23:53 2020 +0900 init diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2846a41 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 sup39 + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c8637e --- /dev/null +++ b/README.md @@ -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) diff --git a/sup39.vimrc b/sup39.vimrc new file mode 100644 index 0000000..1f45666 --- /dev/null +++ b/sup39.vimrc @@ -0,0 +1,128 @@ +" map-leader +if !exists('mapleader') + let mapleader='q' + nnoremap q + nnoremap Q q +endif +if !exists('maplocalleader') + let maplocalleader='qw' +endif +inoremap jk +" file + " save + nnoremap :w + inoremap :w + " copy + nnoremap C :w !pbcopy + " tab edit + nnoremap e :tabe + nnoremap v :tabe $HOME/.vim/sup39/sup39.vimrc + nnoremap V :tabe $MYVIMRC +" search +nnoremap / /\v +nnoremap ? ?\v +nnoremap sl :s/\v +nnoremap se :.,$s/\v +nnoremap ss :%s/\v +nnoremap hh :set hlsearch! incsearch! +nnoremap hc :nohlsearch +" ale +nnoremap r :ALERename +nnoremap n :ALENext +nnoremap p :ALEPrevious +nnoremap :ALEHover +nnoremap db :ALEGoToDefinition -tab +nnoremap dm :ALEGoToDefinition +nnoremap dl :ALEDetail +" external +nnoremap m :w:make +" debug +nnoremap X :exe getline('.') +nnoremap H :echo synIDattr(synID(line("."),col("."),1),"name") + +" filetype-dependent +augroup sup39_map + autocmd! + " vim + " source + autocmd Filetype vim noremap s :w:so % + " c, cpp + " macro + autocmd Filetype c,cpp noremap h + \:call setline('.', toupper(substitute(@%, '\.', '_', 'g'))) + \yyI#ifndef p#define o#endifkki + autocmd Filetype c,cpp noremap i + \:call setline('.', + \'#include "'.substitute(@%, '\.\zsc\ze\(pp\)\?$', 'h', '').'"')o + " abbr + autocmd Filetype c,cpp iabbrev #i #include + " markdown + " plugin + nnoremap p :MarkdownPreview +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