Skip to content

Instantly share code, notes, and snippets.

@malanjp
Created May 22, 2021 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malanjp/4843bc687bf93ca2f6fcbd1bf5db9ba4 to your computer and use it in GitHub Desktop.
Save malanjp/4843bc687bf93ca2f6fcbd1bf5db9ba4 to your computer and use it in GitHub Desktop.
neovim settings
[[plugins]]
repo = 'Shougo/dein.vim'
[[plugins]]
repo = 'Shougo/vimproc.vim'
build = 'make'
[[plugins]]
repo = 'Shougo/vimshell.vim'
[[plugins]]
repo = 'w0rp/ale'
[[plugins]]
repo = 'michalbachowski/vim-wombat256mod'
repo = 'davidhalter/jedi'
on_ft = ['python']
[[plugins]]
repo = 'Shougo/deoplete.nvim'
on_event = 'InsertEnter'
[[plugins]]
repo = 'w0rp/ale'
[[plugins]]
repo = 'scrooloose/nerdtree'
[[plugins]]
repo = 'tpope/vim-surround'
# [[plugins]]
# repo = 'jsfaint/gen_tags.vim'
# hook_add = '''
# let g:gen_tags#ctags_auto_gen = 1
# let g:gen_tags#gtags_auto_gen = 1
# '''
# [[plugins]]
# repo = 'Shougo/neosnippet.vim'
# [[plugins]]
# repo = 'Shougo/neosnippet-snippets'
[[plugins]]
repo = 'cespare/vim-toml'
on_ft = 'toml'
[[plugins]]
repo = 'michalbachowski/vim-wombat256mod'
on_event = 'VimEnter'
[[plugins]]
repo = 'w0ng/vim-hybrid'
on_event = 'VimEnter'
[[plugins]]
repo = 'kristijanhusak/vim-hybrid-material'
[[plugins]]
repo = 'Shougo/denite.nvim'
depends = 'neomru.vim'
hook_add = '''
nmap <silent> ,t :,Denite filetype<CR>
nmap <silent> ,b :,Denite buffer<CR>
nmap <silent> ,f :,Denite file_rec<CR>
nmap <silent> ,j :,Denite line<CR>
nmap <silent> ,g :,Denite grep<CR>
nmap <silent> ,] :,DeniteCursorWord grep<CR>
nmap <silent> ,c :,Denite colorscheme<CR>
nmap <silent> ,m :,Denite file_mru<CR>
"nmap <silent> ,y :,Denite neoyank<CR>
nmap <silent> ,r :,Denite -resume<CR>
nmap <silent> ,; :,Denite -resume -immediately -select=+1<CR>
nmap <silent> ,- :,Denite -resume -immediately -select=-1<CR>
nnoremap ml :,call denite#start([{'name': 'file_rec', 'args': [g:memolist_path]}])<CR>
call denite#custom#option('default', 'prompt', '>')
call denite#custom#var('file_rec', 'command', ['ag', '--follow', '--nocolor', '--nogroup', '-g', ''])
call denite#custom#var('grep', 'command', ['ag'])
call denite#custom#map(
\ 'insert',
\ '<Down>',
\ '<denite:move_to_next_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<Up>',
\ '<denite:move_to_previous_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<C-N>',
\ '<denite:move_to_next_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<C-P>',
\ '<denite:move_to_previous_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<C-G>',
\ '<denite:assign_next_txt>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<C-T>',
\ '<denite:assign_previous_line>',
\ 'noremap'
\)
call denite#custom#map(
\ 'normal',
\ '/',
\ '<denite:enter_mode:insert>',
\ 'noremap'
\)
call denite#custom#map(
\ 'insert',
\ '<Esc>',
\ '<denite:enter_mode:normal>',
\ 'noremap'
\)
'''
[[plugins]]
repo = 'posva/vim-vue'
[[plugins]]
repo = 'zchee/deoplete-jedi'
on_source = ['deoplete.vim', 'jedi']
[[plugins]]
repo = 'Shougo/neomru.vim'
on_source = ['denite.nvim']
" vim:fileencoding=utf-8
set verbosefile=~/.vim_verbose.log
let g:python2_host_prog = '/usr/bin/python2'
let g:python3_host_prog = $PYENV_ROOT . '/shims/python3'
"dein Scripts-----------------------------
if &compatible
set nocompatible
endif
set runtimepath+=~/.cache/dein
" プラグインが実際にインストールされるディレクトリ
let s:dein_dir = expand('~/.cache/dein')
" dein.vim 本体
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" dein.vim がなければ github から落としてくる
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif
execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif
" 設定開始
if dein#load_state(s:dein_dir)
call dein#begin(s:dein_dir)
" プラグインリストを収めた TOML ファイル
" 予め TOML ファイル(後述)を用意しておく
let g:rc_dir = expand('~/.config/nvim/rc')
let s:toml = g:rc_dir . '/dein.toml'
let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
" TOML を読み込み、キャッシュしておく
call dein#load_toml(s:toml, {'lazy': 0})
call dein#load_toml(s:lazy_toml, {'lazy': 1})
" 設定終了
call dein#end()
call dein#save_state()
endif
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
"End dein Scripts-------------------------
"
" Required:
filetype plugin indent on
syntax enable
"set synmaxcol=150
"set t_Co=256
set background=dark
"colorscheme wombat256mod
"colorscheme jellybeans
"let g:solarized_termcolors=256
"let g:solarized_termtrans=1
"colorscheme solarized
"colorscheme molokai
colorscheme hybrid
"colorscheme hybrid_material
"colorscheme Dracula
set viminfo='20,<50,s10,h,! " YankRing用に!を追加
set shellslash " Windowsでディレクトリパスの区切り文字に / を使えるようにする
set lazyredraw " マクロなどを実行中は描画を中断
" OSのクリップボードを使用する"
set clipboard=unnamedplus
" ターミナルでマウスを使用できるようにする
"set mouse=a
"set guioptions+=a
"set ttymouse=xterm2
" タブ周り {{{
" tabstopはTab文字を画面上で何文字分に展開するか
" shiftwidthはcindentやautoindent時に挿入されるインデントの幅
" softtabstopはTabキー押し下げ時の挿入される空白の量,0の場合はtabstopと同じ,BSにも影響する
set tabstop=2 shiftwidth=2 softtabstop=2
set expandtab " タブを空白文字に展開
set autoindent smartindent " 自動インデント,スマートインデント
" }}}
" 入力補助 {{{
set backspace=indent,eol,start " バックスペースでなんでも消せるように
set formatoptions+=mM " 整形オプション,マルチバイト系を追加
" }}}
" コマンド補完 {{{
set wildmenu " コマンド補完を強化
set wildmode=list:full " リスト表示,最長マッチ
set history=1000 " コマンド・検索パターンの履歴数
set complete+=k " 補完に辞書ファイル追加
set cmdheight=1
" }}}
" 検索関連 {{{
set wrapscan " 最後まで検索したら先頭へ戻る
set ignorecase " 大文字小文字無視
set smartcase " 大文字ではじめたら大文字小文字無視しない
set incsearch " インクリメンタルサーチ
set hlsearch " 検索文字をハイライト
set cindent " Cプログラムファイルの自動インデントを始める"
" }}}
" ファイル関連 {{{
set nobackup " バックアップ取らない
set autoread " 他で書き換えられたら自動で読み直す
set noswapfile " スワップファイル作らない
set hidden " 編集中でも他のファイルを開けるようにする
function! s:remove_dust()
let cursor = getpos(".")
"" 保存時に行末の空白を除去する
"%s/\s\+$//ge
" 保存時にtabを4スペースに変換する
%s/\t/ /ge
call setpos(".", cursor)
unlet cursor
endfunction
autocmd BufWritePre * call <SID>remove_dust()
" }}}
" 表示関連 {{{
set splitbelow
set showmatch " 括弧の対応をハイライト
set matchtime=1
set showcmd " 入力中のコマンドを表示
set number " 行番号表示
set wrap " 画面幅で折り返す
set list " 不可視文字表示
set listchars=tab:>\ " 不可視文字の表示方法
set display=uhex,lastline
set pumheight=10
"set notitle " タイトル書き換えない
"set scrolloff=5 " 行送り
set visualbell t_vb= " bell off
" 全角スペースの表示
highlight ZenkakuSpace cterm=underline ctermfg=lightblue guibg=darkgray
match ZenkakuSpace / /
highlight Search ctermfg=black ctermbg=yellow
" }}}
" ステータスライン関連 {{{
set laststatus=2
set statusline=%<%F\ %r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%4v(ASCII=%03.3b,HEX=%02.2B)\ %l/%L(%P)%m
"let g:Powerline_symbols='fancy'
"let g:Powerline_mode_n = 'NORMAL'
" }}}
" 文字コードの自動認識 {{{
" 適当な文字コード判別
"set termencoding=utf-8
"set encoding=utf-8
"set fileencodings=utf-8,iso-2022-jp,cp932,euc-jp
"
" UTF-8の□や○でカーソル位置がずれないようにする
" Terminal.appはどっちにしてもダメ,PrivatePortsのiTermでやる
set ambiwidth=double
" }}}
" 補完に辞書ファイル追加
set complete+=k
" Migemo
if has('migemo')
set migemo
set migemodict=/usr/local/share/migemo/utf-8/migemo-dict
endif
" Kaoriya
if has('kaoriya')
" imを無効にする
set iminsert=0
set imsearch=0
endif
"カーソル行の強調表示
"set cursorline
" カレントディレクトリを自動的に移動
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
map <C-n> :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" キーマップ {{{
" 表示行単位で移動
"noremap j gj
"noremap k gk
"vnoremap j gj
"vnoremap k gk
nnoremap Y y$
nnoremap + <C-a>
nnoremap - <C-x>
" CTRL-hjklでウィンドウ移動
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h
" 検索ハイライトを Esc x 2 で消す
nmap <Esc><Esc> :nohlsearch<CR><Esc>
" }}}
" ファイルタイプ毎の設定 {{{
" Markdown
autocmd BufNewFile,BufRead *.md set ft=markdown fenc=utf-8
" html.vimの設定
" -------------
"let g:do_xhtml_mappings=1
"let g:no_html_toolbar='yes'
"let g:no_html_menu='yes'
" let g:did_html_menus=1
"let b:html_tag_case='l'
"let g:html_default_charset='utf-8'
"let g:html_charset='utf-8'
" HTML
" ------
autocmd FileType html setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
autocmd BufNewFile,BufRead *.vue set ft=html fenc=utf-8
" HTML-Django
" ------
autocmd FileType htmldjango setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" CSS
" ------
autocmd FileType css setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" Javascript
" ----------
"autocmd BufNewFile,BufRead *.js set ft=javascript fenc=utf-8
autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2
let javascript_enable_domhtmlcss=1
" python support
" ------------
function! InitPython()
" autocmd FileType python let b:did_ftplugin = 1
au FileType python setlocal tabstop=4 expandtab shiftwidth=4 softtabstop=4 textwidth=80
setlocal cinwords=if,elif,else,for,while,try,except,finally,def,class
let g:indentLine_color_term = 239
let g:indentLine_color_gui = '#A4E57E'
endfunction
autocmd BufNewFile,BufRead *.py set ft=python fenc=utf-8
autocmd BufEnter * if &filetype == "python" | call InitPython() | endif
" }}}
" taglist.vim {{{
set tags+=tags,/home/michihiro-shibata/.tms.tags;
" }}}
"" quickrun.vim {{{
"nmap <Leader>r <plug>(quickrun)
"
"let g:quickrun_config = {'*': {'split': ''}}
"let g:quickrun_config = {'*': {'hook/time/enable': '1'},}
"let g:quickrun_config.markdown = {
" \ 'outputter' : 'null',
" \ 'command' : 'open',
" \ 'cmdopt' : '-a',
" \ 'args' : 'Marked\ 2',
" \ 'exec' : '%c %o %a %s',
" \ }
"let g:quickrun_config.go = {
" \ 'command': 'go',
" \ 'exec': ['%c run %s']
" \ }
"" }}}
" deoplete.vim {{{
let g:deoplete#enable_at_startup = 1
" }}}
" jedi.vim {{{
let g:jedi#auto_initialization = 1
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_definitions_command = "<leader>d"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>R"
let g:jedi#show_call_signatures = "1"
" }}}
" ale.vim {{{
" エラー行に表示するマーク
let g:ale_sign_error = '⨉'
let g:ale_sign_warning = '⚠'
" エラー行にカーソルをあわせた際に表示されるメッセージフォーマット
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
" エラー表示の列を常時表示
let g:ale_sign_column_always = 1
" ファイルを開いたときにlint実行
let g:ale_lint_on_enter = 1
" ファイルを保存したときにlint実行
let g:ale_lint_on_save = 1
" 編集中のlintはしない
let g:ale_lint_on_text_changed = 'never'
" lint結果をロケーションリストとQuickFixには表示しない
" 出てると結構うざいしQuickFixを書き換えられるのは困る
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
let g:ale_open_list = 0
let g:ale_keep_list_window_open = 0
" 有効にするlinter
let g:ale_linters = {
\ 'python': ['flake8'],
\ 'javascript': ['eslint'],
\ }
" 各ツールをFixerとして登録
let g:ale_fixers = {
\ 'python': ['black'],
\ }
" 各ツールの実行オプションを変更してPythonパスを固定
let g:ale_python_flake8_executable = g:python3_host_prog
let g:ale_python_flake8_options = '-m flake8'
let g:ale_python_autopep8_executable = g:python3_host_prog
let g:ale_python_autopep8_options = '-m autopep8'
let g:ale_python_isort_executable = g:python3_host_prog
let g:ale_python_isort_options = '-m isort'
let g:ale_python_black_executable = g:python3_host_prog
let g:ale_python_black_options = '-m black'
" ALE用プレフィックス
nmap [ale] <Nop>
map <C-k> [ale]
" エラー行にジャン
nmap <silent> [ale]<C-P> <Plug>(ale_previous)
nmap <silent> [ale]<C-N> <Plug>(ale_next)
" ついでにFixを実行するマッピングしとく
nmap <silent> [ale]x <Plug>(ale_fix)
" ファイル保存時に自動的にFixするオプションもあるのでお好みで
let g:ale_fix_on_save = 0
" }}}
" yapf
"autocmd FileType python nnoremap <leader>y :0,$!yapf<Cr>
" vim:set foldmethod=marker:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment