Skip to content

Instantly share code, notes, and snippets.

@jaren82
Created July 5, 2023 03:45
Show Gist options
  • Select an option

  • Save jaren82/e7c231ce17c16b4ee25c0b12a2168218 to your computer and use it in GitHub Desktop.

Select an option

Save jaren82/e7c231ce17c16b4ee25c0b12a2168218 to your computer and use it in GitHub Desktop.
my macvim config
" MacVim 설정
set nocompatible
set number
set clipboard=unnamed
set smartindent
set tabstop=2
set expandtab
" >> 또는 << 키로 들여 쓰기 할때 스페이스의 갯수. 기본값 8
set shiftwidth=2
" 색상 변경
set background=light
highlight clear
highlight Normal gui=NONE guifg=Black guibg=White
highlight Visual guibg=#72F7FF
colorscheme polar
set laststatus=2
let g:airline_theme='solarized'
" 리더키 스페이스 설정
let mapleader="\<Space>"
map <Space> <Leader>
nnoremap <C-s> :w!<CR>
vnoremap <C-s> :w!<CR>
nnoremap <Leader>bn :bnext<CR>
nnoremap <Leader>bb :bprevious<CR>
nnoremap <Leader>b :<C-u>execute 'b' . v:count1<CR>
" 기본 VIMRC 파일 경로 변경
let $MYVIMRC=$HOME.'/.vim/gvimrc'
" vimrc 변경되면 즉시 리로딩
au! BufWritePost .vimrc so %
au! BufWritePost gvimrc so %
" Edit vimr configuration file
nnoremap <Leader>lc :e $MYVIMRC<CR>
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
Plugin 'vimwiki/vimwiki'
Plugin 'jamshedvesuna/vim-markdown-preview'
Plugin 'tpope/vim-surround'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" colorscheme
Plugin 'habamax/vim-polar'
Plugin 'chrisbra/vim-commentary'
Plugin 'wincent/command-t'
" Plugin 'img-paste-devs/img-paste.vim'
" Plugin 'andrew749/vim-bufpaste'
Plugin 'unicornrainbow/vim-image_paste'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"1번 위키(개인용)와 2번 위키(업무용)
let g:vimwiki_list = [
\{
\ 'path': '~/Documents/vimwiki',
\ 'syntax': 'markdown',
\ 'ext' : '.md',
\},
\{
\ 'path': '~/Documents/vimwiki_fitpet',
\ 'syntax': 'markdown',
\ 'ext' : '.md',
\},
\]
" vimwiki의 conceallevel 을 끄는 쪽이 좋다. 특수문자가 안보이게됨
let g:vimwiki_conceallevel = 0
" md 파일은 vimwiki 폴더 안에만
let g:vimwiki_global_ext = 0
let g:markdown_fenced_languages = ['html', 'js=javascript', 'ruby', 'tsx=javascript']
" vimwiki key mapping
nmap <Leader>wt :VimwikiTable<CR>
nnoremap <Leader>wf :execute "VWS /" . expand("<cword>") . "/" <Bar> :lopen<CR>
nnoremap <Leader>wr :execute "VWB" <Bar> :lopen<CR>
function! VimwikiFindIncompleteTasks()
lvimgrep /- \[ \]/ %:p
lopen
endfunction
function! VimwikiFindAllIncompleteTasks()
VimwikiSearch /- \[ \]/
lopen
endfunction
nmap <Leader>wa :call VimwikiFindAllIncompleteTasks()<CR>
nmap <Leader>wx :call VimwikiFindIncompleteTasks()<CR>
" Airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_highlighting_cache = 1
" Command T 설정 (파일 찾기)
let g:CommandTMaxFiles=20000
let g:CommandTPreferredImplementation='ruby'
let g:CommandTMatchWindowAtTop=1
let g:CommandTMatchWindowReverse=0
let g:CommandTMaxHeight = 30
set rubydll=/Users/hansoonmo/.rbenv/versions/3.2.2/lib/libruby.dylib
autocmd VimEnter * PluginInstall
let vim_markdown_preview_browser='Google Chrome'
let vim_markdown_preview_github=1
let vim_markdown_preview_temp_file=1
" autocmd FileType tex let g:PasteImageFunction = 'g:LatexPasteImage'
autocmd FileType markdown nmap <buffer><silent> <leader>p :call image_paste#PasteImage()<CR>
function! NewTemplate()
let l:wiki_directory = v:false
for wiki in g:vimwiki_list
if expand('%:p:h') =~ expand(wiki.path)
let l:wiki_directory = v:true
break
endif
endfor
if !l:wiki_directory
return
endif
if line("$") > 1
return
endif
let l:template = []
call add(l:template, '---')
call add(l:template, 'layout : wiki')
call add(l:template, 'title : ')
call add(l:template, 'summary : ')
call add(l:template, 'date : ' . strftime('%Y-%m-%d %H:%M:%S +0900'))
call add(l:template, 'updated : ' . strftime('%Y-%m-%d %H:%M:%S +0900'))
call add(l:template, 'tag : ')
call add(l:template, 'toc : true')
call add(l:template, 'public : true')
call add(l:template, 'parent : ')
call add(l:template, 'latex : false')
call add(l:template, 'resource: ' . substitute(system("uuidgen"), '\n', '', ''))
call add(l:template, '---')
call add(l:template, '* TOC')
call add(l:template, '{:toc}')
call add(l:template, '')
call add(l:template, '# ')
call setline(1, l:template)
execute 'normal! G'
execute 'normal! $'
echom 'new wiki page has created'
endfunction
function! LastModified()
if &modified
" echo('markdown updated time modified')
let save_cursor = getpos(".")
let n = min([10, line("$")])
keepjumps exe '1,' . n . 's#^\(.\{,10}updated\s*: \).*#\1' .
\ strftime('%Y-%m-%d %H:%M:%S +0900') . '#e'
call histdel('search', -1)
call setpos('.', save_cursor)
endif
endfunction
augroup vimwikiauto
autocmd FileType *wiki/*.md let g:loaded_images_paste='~/Documents/vimwiki/images'
autocmd BufWritePre *wiki/*.md call LastModified()
autocmd BufRead,BufNewFile *wiki/*.md call NewTemplate()
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment