Skip to content

Instantly share code, notes, and snippets.

@shiena
Last active March 31, 2020 15:56
Show Gist options
  • Select an option

  • Save shiena/ff0aad8b65160cf3f3e853e07e412922 to your computer and use it in GitHub Desktop.

Select an option

Save shiena/ff0aad8b65160cf3f3e853e07e412922 to your computer and use it in GitHub Desktop.
vim and neovim config file
"GuiFont! HackGen\ Console:h14
GuiFont! JetBrains Mono:h14
"set guifont=MyricaM_M:h12:cSHIFTJIS
"set guifont=Ricty_Diminished_Discord:h14:cSHIFTJIS:qDRAFT
" set guifont=Cica:h14:cSHIFTJIS:qDRAFT
set guifont=HackGen:h14:cSHIFTJIS:qDRAFT
set background=dark
colorscheme darcula
set guioptions-=T
set guioptions+=!
set linespace=0
set renderoptions=type:directx,renmode:5
highlight CursorIM guibg=Purple guifg=NONE
" https://qiita.com/sei40kr/items/09e7e92eb7686f9b5950
set surround
nnoremap / :<C-u>action Find<CR>
nnoremap <C-o> :<C-u>action Back<CR>
nnoremap <C-i> :<C-u>action Forward<CR>
nnoremap <C-S-o> <C-o>
nnoremap <C-S-i> <C-i>
call plug#begin(expand('<sfile>:p:h').'/plugged')
Plug 'itchyny/lightline.vim'
Plug 'kana/vim-altr'
Plug 'osyo-manga/vim-anzu'
Plug 't9md/vim-quickhl'
Plug 'tpope/vim-surround'
Plug 'mtth/scratch.vim'
" style
Plug 'PProvost/vim-ps1'
" colorscheme
Plug 'itchyny/landscape.vim'
Plug 'blueshirts/darcula'
call plug#end()
filetype plugin indent on
syntax on
colorscheme darcula
set ambiwidth=double
set autoindent
set background=dark
set backspace=2
set cmdheight=2
set encoding=utf-8
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set nocompatible
set expandtab
set number
set relativenumber
set shiftwidth=4
set shortmess+=I
set showcmd
set showmatch
set smartcase
set smartindent
set smarttab
set spelllang+=cjk
set splitright
set tabstop=4
set title
set wildmenu
set wrap
set wrapscan
"
" lightline.vim {{{
let g:tender_lightline = 1
let g:lightline = {
\ 'colorscheme': g:colors_name,
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['readonly', 'filename', 'modified', 'anzu']
\ ]
\ },
\ 'component_function': {
\ 'anzu': 'anzu#search_status'
\ }
\ }
" }}}
if has('mac')
let mapleader="_"
endif
let maplocalleader=","
if has('win32')
let s:luadll=expand($USERPROFILE . '/scoop/apps/lua/current/lua53.dll')
if filereadable(s:luadll)
let &luadll=s:luadll
endif
let s:python2path=expand($USERPROFILE . '/scoop/apps/python27/current')
let s:python2dll=expand(s:python2path . '/python27.dll')
if filereadable(s:python2dll)
let &pythonhome=s:python2path
let &pythondll=s:python2dll
endif
let s:python3path=expand($USERPROFILE . '/scoop/apps/python/current')
let s:python3dll=expand(s:python3path . '/python3.dll')
if filereadable(s:python3dll)
let $PYTHONPATH=s:python3path
let &pythonthreedll=s:python3dll
endif
endif
" Specify a directory for plugins
" - For Neovim: ‾/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin(expand('<sfile>:p:h').'/plugged')
Plug 'itchyny/lightline.vim'
Plug 'kana/vim-altr'
"Plug 'lambdalisue/gina.vim'
Plug 'majutsushi/tagbar'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'osyo-manga/vim-anzu'
Plug 't9md/vim-choosewin'
Plug 't9md/vim-quickhl'
Plug 'tpope/vim-surround'
Plug 'mtth/scratch.vim'
Plug 'Shougo/denite.nvim'
Plug 'Shougo/neomru.vim'
Plug 'rickhowe/diffchar.vim'
" style
"Plug 'derekwyatt/vim-scala'
Plug 'jtratner/vim-flavored-markdown'
Plug 'stephpy/vim-yaml'
Plug 'PProvost/vim-ps1'
Plug 'OrangeT/vim-csharp'
" colorscheme
Plug 'itchyny/landscape.vim'
Plug 'blueshirts/darcula'
Plug 'vim-jp/vimdoc-ja'
" Initialize plugin system
call plug#end()
if (has('termguicolors'))
set termguicolors
set t_Co=256
if (!has('win32'))
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
endif
filetype plugin indent on
syntax on
colorscheme darcula
if (has('win32'))
source $VIMRUNTIME/delmenu.vim
set langmenu=none
source $VIMRUNTIME/menu.vim
endif
" option {{{
let g:no_vimrc_example = 0
if has('win32')
set nobackup
set termencoding=cp932
else
set backup
endif
set ambiwidth=double
set autoindent
set background=dark
set backspace=2
set cmdheight=2
set encoding=utf-8
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set nocompatible
set noexpandtab
set number
set norelativenumber
set shiftwidth=4
set shortmess+=I
set showcmd
set showmatch
set smartcase
set smartindent
set smarttab
set spelllang+=cjk
set splitright
set tabstop=4
set title
set wildmenu
set wrap
set wrapscan
" }}}
" lightline.vim {{{
let g:tender_lightline = 1
let g:lightline = {
\ 'colorscheme': g:colors_name,
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['readonly', 'filename', 'modified', 'anzu']
\ ]
\ },
\ 'component_function': {
\ 'anzu': 'anzu#search_status'
\ }
\ }
" }}}
" テキスト挿入中の自動折り返しを日本語に対応させる
set formatoptions+=mM
let format_join_spaces = 4
" 日本語整形スクリプト(by. 西岡拓洋さん)用の設定
let format_allow_over_tw = 1
set mouse=a
" vim-flavored-markdown {{{
augroup markdown
au!
au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown
augroup END
" }}}
" choosewin {{{
let g:choosewin_overlay_enable = 1
let g:choosewin_overlay_clear_multibyte = 1
let g:choosewin_blink_on_land = 0
let g:choosewin_statusline_replace = 0
let g:choosewin_tabline_replace = 0
nmap <Leader><Tab> <Plug>(choosewin)
" }}}
" vim-quickhl {{{
nmap <Space>m <Plug>(quickhl-manual-this)
xmap <Space>m <Plug>(quickhl-manual-this)
nmap <Space>M <Plug>(quickhl-manual-reset)
xmap <Space>M <Plug>(quickhl-manual-reset)
" }}}
" vim-altr {{{
nnoremap <Leader>a <Plug>(altr-forward)
" }}}
" vim-anzu {{{
" mapping
nmap n <Plug>(anzu-n)
nmap N <Plug>(anzu-N)
nmap * <Plug>(anzu-star)
nmap # <Plug>(anzu-sharp)
" }}}
" clear status {{{
"nmap <Esc><Esc> <Plug>(anzu-clear-search-status)
augroup vim-anzu
autocmd!
autocmd CursorHold,CursorHoldI,WinLeave,TabLeave * call anzu#clear_search_status()
augroup END
"}}}
" タブ幅をリセット
au BufNewFile,BufRead * set tabstop=4 shiftwidth=4
" refs: http://qiita.com/kefir_/items/c725731d33de4d8fb096
" Use vsplit mode {{{
if has("vim_starting") && !has('gui_running') && has('vertsplit')
function! EnableVsplitMode()
" enable origin mode and left/right margins
let &t_CS = "y"
let &t_ti = &t_ti . "\e[?6;69h"
let &t_te = "\e[?6;69l\e[999H" . &t_te
let &t_CV = "\e[%i%p1%d;%p2%ds"
call writefile([ "\e[?6;69h" ], "/dev/tty", "a")
endfunction
" old vim does not ignore CPR
map <special> <Esc>[3;9R <Nop>
" new vim can't handle CPR with direct mapping
" map <expr>  EnableVsplitMode()
set t_F9=
map <expr> <t_F9> EnableVsplitMode()
let &t_RV .= "\e[?6;69h\e[1;3s\e[3;9H\e[6n\e[0;0s\e[?6;69l"
endif
" }}}
" refs: https://shapeshed.com/vim-netrw/
" {{{
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
" augroup ProjectDrawer
" autocmd!
" autocmd VimEnter * :Vexplore
" augroup END
" }}}
" terminal {{{
function! TerminalGit()
" 日本語Windowsの場合`ja`が設定されるので、入力ロケールに合わせたUTF-8に設定しなおす
let l:env = {
\ 'LANG': systemlist('"C:/Program Files/Git/usr/bin/locale.exe" -iU')[0],
\ }
" remote連携のための設定
if has('clientserver')
call extend(l:env, {
\ 'GVIM': $VIMRUNTIME,
\ 'VIM_SERVERNAME': v:servername,
\ })
endif
" term_startでgit for windowsのbashを実行する
call term_start(['C:/Program Files/Git/bin/bash.exe', '-l'], {
\ 'term_name': 'Git',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ 'cwd': $USERPROFILE,
\ 'env': l:env,
\ })
endfunction
nnoremap <Leader>tg :<C-u>call TerminalGit()<CR>
function! TerminalMingw64()
" 日本語Windowsの場合`ja`が設定されるので、入力ロケールに合わせたUTF-8に設定しなおす
let l:env = {
\ 'LANG': systemlist('"C:/msys64/usr/bin/locale.exe" -iU')[0],
\ 'MSYSTEM': 'MINGW64',
\ }
" remote連携のための設定
if has('clientserver')
call extend(l:env, {
\ 'GVIM': $VIMRUNTIME,
\ 'VIM_SERVERNAME': v:servername,
\ })
endif
" term_startでMinGW64のbashを実行する
call term_start(['C:/msys64/usr/bin/bash', '--login'], {
\ 'term_name': 'MinGW64',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ 'cwd': 'C:/msys64',
\ 'env': l:env,
\ })
endfunction
nnoremap <Leader>tm :<C-u>call TerminalMingw64()<CR>
function! TerminalUbuntu()
" :terminalでWSLのbashを実行する
call term_start('ubuntu', {
\ 'term_name': 'ubuntu',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ 'cwd': $USERPROFILE,
\ })
endfunction
nnoremap <Leader>tw :<C-u>call TerminalUbuntu()<CR>
function! TerminalCmd()
call term_start($ComSpec, {
\ 'term_name': 'cmd',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ 'cwd': $USERPROFILE,
\ })
endfunction
nnoremap <Leader>tc :<C-u>call TerminalCmd()<CR>
function! TerminalPowershell()
call term_start('powershell', {
\ 'term_name': 'PowerShell',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ 'cwd': $USERPROFILE,
\ })
endfunction
nnoremap <Leader>tp :<C-u>call TerminalPowershell()<CR>
function! TerminalDebian()
call term_start(['ssh', '[email protected]'], {
\ 'term_name': 'Debian',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ })
endfunction
nnoremap <Leader>td :<C-u>call TerminalDebian()<CR>
function! s:terminal_ssh(...)
if a:0 >= 1
call term_start(['ssh', a:1], {
\ 'term_name': 'SSH',
\ 'curwin': 1,
\ 'term_finish': 'close',
\ })
else
echo "no host!"
end
endfunction
command! -nargs=1 TerminalSSH call s:terminal_ssh(<f-args>)
nnoremap <Leader>td :<C-u>call TerminalSSH()<CR>
command! Terminal call popup_create(term_start(['pwsh'], #{ hidden: 1, term_finish: 'close'}), #{ border: [], minwidth: winwidth(0)/2, minheight: &lines/2 })
" }}}
" Denite {{{
" refs: http://qiita.com/todashuta/items/1362654c6276e5b69abc
"nnoremap <Leader>e :<C-u>/ oldfiles<Home>browse filter /
nnoremap <Leader>de :<C-u>Denite -mode=normal file_mru<CR>
nnoremap <Leader>db :<C-u>Denite -mode=normal buffer<CR>
let s:menus = {}
let s:menus.terminal = {
\ 'description': 'Terminal'
\ }
let s:menus.terminal.command_candidates = [
\ ['Git' , 'call TerminalGit()'],
\ ['MinGW64' , 'call TerminalMingw64()'],
\ ['Cmd' , 'call TerminalCmd()'],
\ ['Powershell', 'call TerminalPowershell()'],
\ ['Ubuntu' , 'call TerminalUbuntu()'],
\ ['detroit' , 'call TerminalDebian()'],
\ ]
call denite#custom#var('menu', 'menus', s:menus)
nnoremap <Leader>dm :<C-u>Denite -mode=normal menu:terminal<CR>
" }}}
" let &t_SH='\e[2 q'
" vim: foldmethod=marker expandtab
" NormalNC {{{
autocmd ColorScheme * highlight NormalNC guifg=#8894A0 guibg=#232323
autocmd WinEnter,BufWinEnter * setlocal wincolor=
autocmd WinLeave * setlocal wincolor=NormalNC
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment