update
This commit is contained in:
parent
7683d9b5f8
commit
b0cfcc41ac
@ -10,18 +10,29 @@ depends = []
|
||||
[zsh.files]
|
||||
zshrc = "~/.zshrc"
|
||||
zprofile = "~/.zprofile"
|
||||
zsh_20_keybind = "~/.zsh/20_keybind.zsh"
|
||||
zsh_30_alias = "~/.zsh/30_alias.zsh"
|
||||
zsh_50_setopt = "~/.zsh/50_setopt.zsh"
|
||||
zsh_70_misc = "~/.zsh/70_misc.zsh"
|
||||
zsh = "~/.zsh"
|
||||
|
||||
[shell.files]
|
||||
# Optional variables email+git_username
|
||||
gitconfig = "~/.gitconfig"
|
||||
tmux = "~/.tmux.conf"
|
||||
ssh = "~/.ssh"
|
||||
ctags = "~/.ctags"
|
||||
|
||||
[vim.files]
|
||||
vimrc = "~/.vimrc"
|
||||
|
||||
[vim.variables]
|
||||
# linter can be "standard" or "eslint"
|
||||
js_linter = "\"standard\""
|
||||
# fixer can be "standard" or "prettier"
|
||||
js_fixer = "\"standard\""
|
||||
|
||||
[nvim.files]
|
||||
init_vim = "~/.config/nvim/init.vim"
|
||||
nvim = "~/.config/nvim"
|
||||
|
||||
[nvim.variables]
|
||||
# linter can be "standard" or "eslint"
|
||||
js_linter = "\"standard\""
|
||||
# fixer can be "standard" or "prettier"
|
||||
js_fixer = "\"standard\""
|
||||
|
11
ctags
Normal file
11
ctags
Normal file
@ -0,0 +1,11 @@
|
||||
--langdef=js
|
||||
--langmap=js:.js
|
||||
--regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/o,object/
|
||||
|
||||
--regex-JavaScript=/([A-Za-z0-9._$'"()]+)[ \t]*[:][ \t]*function[ \t]*\([^)]*\)/\1/f,function/
|
||||
|
||||
--regex-JavaScript=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/a,array/
|
||||
|
||||
--regex-JavaScript=/([^= ]+)[ \t]*=[ \t]*'[^']*'/\1/s,string/
|
||||
|
||||
--regex-JavaScript=/([^= ]+)[ \t]*=[ \t]*"[^"]*"/\1/s,string/
|
426
nvim/init.vim
Normal file
426
nvim/init.vim
Normal file
@ -0,0 +1,426 @@
|
||||
"*****************************************************************************
|
||||
""" Vim-Plug core
|
||||
"*****************************************************************************
|
||||
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
|
||||
let curl_exists=expand('curl')
|
||||
|
||||
if !filereadable(vimplug_exists)
|
||||
if !executable(curl_exists)
|
||||
echoerr "You have to install curl or first install vim-plug yourself!"
|
||||
execute "q!"
|
||||
endif
|
||||
echo "Installing Vim-Plug..."
|
||||
echo ""
|
||||
silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
||||
let g:not_finish_vimplug = "yes"
|
||||
|
||||
autocmd VimEnter * PlugInstall
|
||||
endif
|
||||
|
||||
" Required:
|
||||
call plug#begin(expand('~/.config/nvim/plugged'))
|
||||
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'hrsh7th/nvim-cmp'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
Plug 'hrsh7th/cmp-buffer'
|
||||
Plug 'hrsh7th/cmp-path'
|
||||
Plug 'hrsh7th/cmp-cmdline'
|
||||
" For vsnip users.
|
||||
Plug 'hrsh7th/cmp-vsnip'
|
||||
Plug 'hrsh7th/vim-vsnip'
|
||||
|
||||
Plug 'tomasr/molokai'
|
||||
Plug 'scrooloose/nerdcommenter'
|
||||
Plug 'vim-scripts/DrawIt'
|
||||
|
||||
Plug 'easymotion/vim-easymotion'
|
||||
Plug 'mattn/emmet-vim'
|
||||
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
||||
Plug 'pangloss/vim-javascript'
|
||||
" tagbar
|
||||
" golang install go get -u github.com/jstemmer/gotags
|
||||
Plug 'majutsushi/tagbar'
|
||||
Plug 'w0rp/ale'
|
||||
Plug 'connorholyday/vim-snazzy'
|
||||
Plug 'hzchirs/vim-material'
|
||||
Plug 'kadekillary/Turtles'
|
||||
Plug 'phanviet/vim-monokai-pro'
|
||||
Plug 'sickill/vim-monokai'
|
||||
Plug 'godlygeek/tabular'
|
||||
Plug 'plasticboy/vim-markdown'
|
||||
Plug 'ctrlpvim/ctrlp.vim'
|
||||
|
||||
" defx file explorer
|
||||
" require python package pynvim
|
||||
" install `pip3 install --user pynvim`
|
||||
Plug 'Shougo/defx.nvim', { 'do': ':UpdateRemotePlugins' }
|
||||
|
||||
Plug 'vim-airline/vim-airline'
|
||||
Plug 'kien/tabman.vim'
|
||||
|
||||
" for git
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'christoomey/vim-conflicted'
|
||||
|
||||
" for mark
|
||||
Plug 'inkarkat/vim-ingo-library'
|
||||
Plug 'inkarkat/vim-mark'
|
||||
|
||||
Plug 'rking/ag.vim'
|
||||
Plug 'terryma/vim-multiple-cursors'
|
||||
|
||||
" temp plugin
|
||||
Plug 'tpope/vim-surround'
|
||||
Plug 'buoto/gotests-vim'
|
||||
Plug 'chr4/nginx.vim'
|
||||
Plug 'cespare/vim-toml'
|
||||
Plug 'zah/nim.vim'
|
||||
Plug 'rust-lang/rust.vim'
|
||||
Plug 'danilo-augusto/vim-afterglow'
|
||||
Plug 'vim-scripts/TaskList.vim'
|
||||
Plug 'google/vim-jsonnet'
|
||||
Plug 'github/copilot.vim'
|
||||
|
||||
call plug#end()
|
||||
|
||||
syntax on
|
||||
set number
|
||||
set tabstop=2
|
||||
set shiftwidth=2
|
||||
set expandtab
|
||||
set nofoldenable
|
||||
set pastetoggle=<F2>
|
||||
" always show status
|
||||
set laststatus=2
|
||||
" show cursor position
|
||||
set ruler
|
||||
set cursorline
|
||||
set cursorcolumn
|
||||
set hlsearch
|
||||
" no wrap line
|
||||
set nowrap
|
||||
" enable backspace
|
||||
set backspace=indent,eol,start
|
||||
set encoding=utf-8
|
||||
set completeopt=menu,menuone,noselect
|
||||
|
||||
" set guifont=Hack\ Nerd\ Font:h11
|
||||
|
||||
set background=dark
|
||||
|
||||
function! AdaptColorscheme()
|
||||
highlight clear CursorLine
|
||||
highlight Normal ctermbg=none
|
||||
highlight LineNr ctermbg=none
|
||||
highlight Folded ctermbg=none
|
||||
highlight NonText ctermbg=none
|
||||
highlight SpecialKey ctermbg=none
|
||||
highlight VertSplit ctermbg=none
|
||||
highlight SignColumn ctermbg=none
|
||||
endfunction
|
||||
autocmd ColorScheme * call AdaptColorscheme()
|
||||
|
||||
" colorscheme turtles
|
||||
colorscheme afterglow
|
||||
|
||||
|
||||
" define leader key
|
||||
let mapleader=";"
|
||||
filetype indent on
|
||||
" 開啟檔案類型偵測
|
||||
filetype on
|
||||
" 根據檔案類型載入plugin
|
||||
filetype plugin on
|
||||
|
||||
" split window
|
||||
nmap <leader>sw <c-w>
|
||||
nmap <leader>sww <c-w>k
|
||||
nmap <leader>sws <c-w>j
|
||||
nmap <leader>swa <c-w>h
|
||||
nmap <leader>swd <c-w>l
|
||||
|
||||
nmap <leader>aa gT
|
||||
nmap <leader>dd gt
|
||||
|
||||
function! TabCloseRight(bang)
|
||||
let cur=tabpagenr()
|
||||
while cur < tabpagenr('$')
|
||||
exe 'tabclose' . a:bang . ' ' . (cur + 1)
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! TabCloseLeft(bang)
|
||||
while tabpagenr() > 1
|
||||
exe 'tabclose' . a:bang . ' 1'
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
command! -bang Tabcloseright call TabCloseRight('<bang>')
|
||||
command! -bang Tabcloseleft call TabCloseLeft('<bang>')
|
||||
|
||||
" defx settings
|
||||
call defx#custom#option('_', {
|
||||
\ 'winwidth': 40,
|
||||
\ 'split': 'vertical',
|
||||
\ 'direction': 'topleft',
|
||||
\ 'buffer_name': '',
|
||||
\ 'toggle': 1,
|
||||
\ 'resume': 1,
|
||||
\ })
|
||||
nmap <F3> :Defx<CR>
|
||||
nmap <leader>me :Defx<CR>
|
||||
autocmd FileType defx call s:defx_my_settings()
|
||||
function! s:defx_my_settings() abort
|
||||
" Define mappings
|
||||
nnoremap <silent><buffer><expr> <CR>
|
||||
\ defx#is_directory() ?
|
||||
\ defx#do_action('open_tree', 'toggle') :
|
||||
\ defx#do_action('drop')
|
||||
nnoremap <silent><buffer><expr> T
|
||||
\ defx#do_action('open', 'tabe')
|
||||
nnoremap <silent><buffer><expr> s
|
||||
\ defx#do_action('drop', 'vsplit')
|
||||
nnoremap <silent><buffer><expr> mc
|
||||
\ defx#do_action('copy')
|
||||
nnoremap <silent><buffer><expr> mm
|
||||
\ defx#do_action('move')
|
||||
nnoremap <silent><buffer><expr> mp
|
||||
\ defx#do_action('paste')
|
||||
nnoremap <silent><buffer><expr> P
|
||||
\ defx#do_action('preview')
|
||||
nnoremap <silent><buffer><expr> o
|
||||
\ defx#do_action('open_tree', 'toggle')
|
||||
nnoremap <silent><buffer><expr> ma
|
||||
\ defx#do_action('new_file')
|
||||
nnoremap <silent><buffer><expr> C
|
||||
\ defx#do_action('toggle_columns',
|
||||
\ 'mark:indent:icon:filename:type:size:time')
|
||||
nnoremap <silent><buffer><expr> S
|
||||
\ defx#do_action('toggle_sort', 'time')
|
||||
nnoremap <silent><buffer><expr> md
|
||||
\ defx#do_action('remove')
|
||||
nnoremap <silent><buffer><expr> mr
|
||||
\ defx#do_action('rename')
|
||||
nnoremap <silent><buffer><expr> !
|
||||
\ defx#do_action('execute_command')
|
||||
nnoremap <silent><buffer><expr> x
|
||||
\ defx#do_action('execute_system')
|
||||
nnoremap <silent><buffer><expr> yy
|
||||
\ defx#do_action('yank_path')
|
||||
nnoremap <silent><buffer><expr> .
|
||||
\ defx#do_action('toggle_ignored_files')
|
||||
nnoremap <silent><buffer><expr> ;
|
||||
\ defx#do_action('repeat')
|
||||
nnoremap <silent><buffer><expr> h
|
||||
\ defx#do_action('cd', ['..'])
|
||||
nnoremap <silent><buffer><expr> ~
|
||||
\ defx#do_action('cd')
|
||||
nnoremap <silent><buffer><expr> q
|
||||
\ defx#do_action('quit')
|
||||
nnoremap <silent><buffer><expr> <Space>
|
||||
\ defx#do_action('toggle_select') . 'j'
|
||||
nnoremap <silent><buffer><expr> *
|
||||
\ defx#do_action('toggle_select_all')
|
||||
nnoremap <silent><buffer><expr> j
|
||||
\ line('.') == line('$') ? 'gg' : 'j'
|
||||
nnoremap <silent><buffer><expr> k
|
||||
\ line('.') == 1 ? 'G' : 'k'
|
||||
nnoremap <silent><buffer><expr> r
|
||||
\ defx#do_action('redraw')
|
||||
nnoremap <silent><buffer><expr> <C-g>
|
||||
\ defx#do_action('print')
|
||||
nnoremap <silent><buffer><expr> cd
|
||||
\ defx#do_action('change_vim_cwd')
|
||||
endfunction
|
||||
|
||||
" tagbar
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
nmap <F9> :%!jq .<CR>
|
||||
|
||||
" NeoComplete
|
||||
let g:neocomplete#enable_at_startup = 1
|
||||
|
||||
let g:airline_powerline_fonts = 1
|
||||
|
||||
" <Leader>f{char} to move to {char}
|
||||
map <Leader>f <Plug>(easymotion-bd-f)
|
||||
nmap <Leader>f <Plug>(easymotion-overwin-f)
|
||||
" s{char}{char} to move to {char}{char}
|
||||
nmap s <Plug>(easymotion-overwin-f2)
|
||||
" Move to line
|
||||
map <Leader>L <Plug>(easymotion-bd-jk)
|
||||
nmap <Leader>L <Plug>(easymotion-overwin-line)
|
||||
" Move to word
|
||||
map <Leader>w <Plug>(easymotion-bd-w)
|
||||
nmap <Leader>w <Plug>(easymotion-overwin-w)
|
||||
|
||||
" lint
|
||||
let g:ale_linters = {
|
||||
\ 'javascript': [{{js_linter}}],
|
||||
\ 'go': ['gopls'],
|
||||
\ 'rust': ['analyzer'],
|
||||
\}
|
||||
let g:ale_fixers = {'javascript': [{{js_fixer}}]}
|
||||
let g:ale_linters_explicit = 1
|
||||
let g:ale_lint_on_save = 1
|
||||
let g:ale_fix_on_save = 1
|
||||
nmap <leader>= <Plug>(ale_fix)
|
||||
|
||||
" NERDCommenter
|
||||
let g:NERDSpaceDelims=1
|
||||
let g:NERDDefaultAlign='left'
|
||||
|
||||
let g:tagbar_type_go = {
|
||||
\ 'ctagstype' : 'go',
|
||||
\ 'kinds' : [
|
||||
\ 'p:package',
|
||||
\ 'i:imports:1',
|
||||
\ 'c:constants',
|
||||
\ 'v:variables',
|
||||
\ 't:types',
|
||||
\ 'n:interfaces',
|
||||
\ 'w:fields',
|
||||
\ 'e:embedded',
|
||||
\ 'm:methods',
|
||||
\ 'r:constructor',
|
||||
\ 'f:functions'
|
||||
\ ],
|
||||
\ 'sro' : '.',
|
||||
\ 'kind2scope' : {
|
||||
\ 't' : 'ctype',
|
||||
\ 'n' : 'ntype'
|
||||
\ },
|
||||
\ 'scope2kind' : {
|
||||
\ 'ctype' : 't',
|
||||
\ 'ntype' : 'n'
|
||||
\ },
|
||||
\ 'ctagsbin' : 'gotags',
|
||||
\ 'ctagsargs' : '-sort -silent'
|
||||
\ }
|
||||
|
||||
" vim-go setting
|
||||
autocmd FileType go nmap tgd <Plug>(go-def-tab)
|
||||
autocmd FileType go nmap <leader>err <Plug>(go-iferr)
|
||||
let g:go_fmt_fail_silently = 1
|
||||
let g:go_fmt_command = "goimports"
|
||||
let g:go_def_mode = 'godef'
|
||||
let g:go_decls_includes = "func,type"
|
||||
let g:go_highlight_types = 1
|
||||
let g:go_highlight_fields = 1
|
||||
let g:go_highlight_functions = 1
|
||||
let g:go_highlight_function_calls = 1
|
||||
let g:go_highlight_operators = 1
|
||||
let g:go_highlight_extra_types = 1
|
||||
|
||||
" for rust-vim
|
||||
let g:rust_recommended_style = 0
|
||||
let g:rustfmt_autosave = 1
|
||||
let g:syntastic_rust_checkers = ['cargo']
|
||||
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
let g:airline#extensions#tabline#show_buffers = 0
|
||||
let g:airline#extensions#tabline#show_splits = 0
|
||||
let g:airline#extensions#tabline#show_tabs = 1
|
||||
let g:airline#extensions#tabline#show_tab_nr = 0
|
||||
let g:airline#extensions#tabline#show_tab_type = 0
|
||||
let g:airline#extensions#tabline#close_symbol = '×'
|
||||
let g:airline#extensions#tabline#show_close_button = 0
|
||||
|
||||
let g:multi_cursor_use_default_mapping=0
|
||||
|
||||
" Default mapping
|
||||
let g:multi_cursor_start_word_key = "<C-n>"
|
||||
let g:multi_cursor_select_all_word_key = '<A-n>'
|
||||
let g:multi_cursor_start_key = "g<C-n>"
|
||||
let g:multi_cursor_select_all_key = 'g<A-n>'
|
||||
let g:multi_cursor_next_key = "<C-n>"
|
||||
" let g:multi_cursor_prev_key = '<C-p>'
|
||||
let g:multi_cursor_skip_key = '<C-x>'
|
||||
let g:multi_cursor_quit_key = '<Esc>'
|
||||
|
||||
let g:javascript_plugin_jsdoc = 1
|
||||
|
||||
lua << EOF
|
||||
|
||||
local nvlsp = require'lspconfig'
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
-- buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gt', '<cmd>tab split<CR><cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
-- buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<leader>ge', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
end
|
||||
|
||||
nvlsp['gopls'].setup{
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
nvlsp['tsserver'].setup{
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
nvlsp['rust_analyzer'].setup{
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
-- nvim-cmp setup
|
||||
local cmp = require 'cmp'
|
||||
cmp.setup {
|
||||
mapping = {
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
-- behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
-- ['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
|
||||
},
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
-- require'snippy'.expand_snippet(args.body) -- For `snippy` users.
|
||||
end,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
}, {
|
||||
{name = 'buffer'},
|
||||
}),
|
||||
}
|
||||
|
||||
EOF
|
||||
|
5
ssh/config
Normal file
5
ssh/config
Normal file
@ -0,0 +1,5 @@
|
||||
Host *
|
||||
StrictHostKeyChecking no
|
||||
UserKnownHostsFile /dev/null
|
||||
ForwardAgent yes
|
||||
|
16
vim_dep.sh
Executable file
16
vim_dep.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
if type npm > /dev/null; then
|
||||
npm i -g typescript typescript-language-server jsctags dockerfile-language-server-nodejs
|
||||
fi
|
||||
|
||||
if type go > /dev/null; then
|
||||
go get -u -v github.com/sourcegraph/go-langserver
|
||||
go get -u github.com/jstemmer/gotags
|
||||
go get -u github.com/cweill/gotests/...
|
||||
fi
|
||||
|
||||
if type rustup > /dev/null; then
|
||||
rustup update
|
||||
rustup component add rls rust-analysis rust-src
|
||||
fi
|
5
vim_plug.sh
Normal file
5
vim_plug.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
# install vim and nvim plug
|
||||
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
437
vimrc
Normal file
437
vimrc
Normal file
@ -0,0 +1,437 @@
|
||||
filetype off
|
||||
call plug#begin('~/.vim/Plugged')
|
||||
|
||||
Plug 'prabirshrestha/async.vim'
|
||||
Plug 'prabirshrestha/vim-lsp'
|
||||
Plug 'prabirshrestha/asyncomplete.vim'
|
||||
Plug 'prabirshrestha/asyncomplete-lsp.vim'
|
||||
|
||||
" autocompleter
|
||||
Plug 'prabirshrestha/asyncomplete-gocode.vim'
|
||||
Plug 'runoshun/tscompletejob'
|
||||
Plug 'prabirshrestha/asyncomplete-tscompletejob.vim'
|
||||
|
||||
Plug 'tomasr/molokai'
|
||||
Plug 'scrooloose/nerdcommenter'
|
||||
Plug 'vim-scripts/DrawIt'
|
||||
Plug 'easymotion/vim-easymotion'
|
||||
Plug 'mattn/emmet-vim'
|
||||
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
||||
Plug 'pangloss/vim-javascript'
|
||||
" tagbar
|
||||
" golang install go get -u github.com/jstemmer/gotags
|
||||
Plug 'majutsushi/tagbar'
|
||||
Plug 'w0rp/ale'
|
||||
Plug 'connorholyday/vim-snazzy'
|
||||
Plug 'hzchirs/vim-material'
|
||||
Plug 'kadekillary/Turtles'
|
||||
Plug 'phanviet/vim-monokai-pro'
|
||||
Plug 'sickill/vim-monokai'
|
||||
Plug 'godlygeek/tabular'
|
||||
Plug 'plasticboy/vim-markdown'
|
||||
Plug 'ctrlpvim/ctrlp.vim'
|
||||
|
||||
" defx file explorer
|
||||
" require python package pynvim
|
||||
" install `pip3 install --user pynvim`
|
||||
Plug 'Shougo/defx.nvim'
|
||||
Plug 'roxma/nvim-yarp'
|
||||
Plug 'roxma/vim-hug-neovim-rpc'
|
||||
|
||||
Plug 'vim-airline/vim-airline'
|
||||
Plug 'kien/tabman.vim'
|
||||
|
||||
" for git
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'christoomey/vim-conflicted'
|
||||
|
||||
" for mark
|
||||
Plug 'inkarkat/vim-ingo-library'
|
||||
Plug 'inkarkat/vim-mark'
|
||||
|
||||
Plug 'rking/ag.vim'
|
||||
Plug 'terryma/vim-multiple-cursors'
|
||||
|
||||
" temp plugin
|
||||
Plug 'tpope/vim-surround'
|
||||
Plug 'buoto/gotests-vim'
|
||||
Plug 'chr4/nginx.vim'
|
||||
Plug 'cespare/vim-toml'
|
||||
Plug 'zah/nim.vim'
|
||||
Plug 'rust-lang/rust.vim'
|
||||
Plug 'danilo-augusto/vim-afterglow'
|
||||
Plug 'vim-scripts/TaskList.vim'
|
||||
|
||||
call plug#end()
|
||||
|
||||
syntax on
|
||||
set number
|
||||
set tabstop=2
|
||||
set shiftwidth=2
|
||||
set expandtab
|
||||
set nofoldenable
|
||||
|
||||
set pastetoggle=<F2>
|
||||
" always show status
|
||||
set laststatus=2
|
||||
" show cursor position
|
||||
set ruler
|
||||
set cursorline
|
||||
set cursorcolumn
|
||||
set hlsearch
|
||||
" no wrap line
|
||||
set nowrap
|
||||
" enable backspace
|
||||
set backspace=indent,eol,start
|
||||
set encoding=utf-8
|
||||
" set font
|
||||
" set guifont=Hack\ Nerd\ Font:h11
|
||||
|
||||
set background=dark
|
||||
|
||||
function! AdaptColorscheme()
|
||||
highlight clear CursorLine
|
||||
highlight Normal ctermbg=none
|
||||
highlight LineNr ctermbg=none
|
||||
highlight Folded ctermbg=none
|
||||
highlight NonText ctermbg=none
|
||||
highlight SpecialKey ctermbg=none
|
||||
highlight VertSplit ctermbg=none
|
||||
highlight SignColumn ctermbg=none
|
||||
endfunction
|
||||
autocmd ColorScheme * call AdaptColorscheme()
|
||||
|
||||
" colorscheme turtles
|
||||
colorscheme afterglow
|
||||
|
||||
" define leader key
|
||||
let mapleader=";"
|
||||
filetype indent on
|
||||
" 開啟檔案類型偵測
|
||||
filetype on
|
||||
" 根據檔案類型載入plugin
|
||||
filetype plugin on
|
||||
|
||||
autocmd BufWritePost $MYVIMRC source $MYVIMRC
|
||||
|
||||
" split window
|
||||
nmap <leader>sw <c-w>
|
||||
nmap <leader>sww <c-w>k
|
||||
nmap <leader>sws <c-w>j
|
||||
nmap <leader>swa <c-w>h
|
||||
nmap <leader>swd <c-w>l
|
||||
|
||||
nmap <leader>aa gT
|
||||
nmap <leader>dd gt
|
||||
|
||||
" defx settings
|
||||
call defx#custom#option('_', {
|
||||
\ 'winwidth': 40,
|
||||
\ 'split': 'vertical',
|
||||
\ 'direction': 'topleft',
|
||||
\ 'buffer_name': '',
|
||||
\ 'toggle': 1,
|
||||
\ 'resume': 1,
|
||||
\ })
|
||||
nmap <F3> :Defx<CR>
|
||||
nmap <leader>me :Defx<CR>
|
||||
autocmd FileType defx call s:defx_my_settings()
|
||||
function! s:defx_my_settings() abort
|
||||
" Define mappings
|
||||
nnoremap <silent><buffer><expr> <CR>
|
||||
\ defx#is_directory() ?
|
||||
\ defx#do_action('open_tree', 'toggle') :
|
||||
\ defx#do_action('drop')
|
||||
nnoremap <silent><buffer><expr> T
|
||||
\ defx#do_action('open', 'tabe')
|
||||
nnoremap <silent><buffer><expr> s
|
||||
\ defx#do_action('drop', 'vsplit')
|
||||
nnoremap <silent><buffer><expr> mc
|
||||
\ defx#do_action('copy')
|
||||
nnoremap <silent><buffer><expr> mm
|
||||
\ defx#do_action('move')
|
||||
nnoremap <silent><buffer><expr> mp
|
||||
\ defx#do_action('paste')
|
||||
nnoremap <silent><buffer><expr> P
|
||||
\ defx#do_action('preview')
|
||||
nnoremap <silent><buffer><expr> o
|
||||
\ defx#do_action('open_tree', 'toggle')
|
||||
nnoremap <silent><buffer><expr> ma
|
||||
\ defx#do_action('new_file')
|
||||
nnoremap <silent><buffer><expr> C
|
||||
\ defx#do_action('toggle_columns',
|
||||
\ 'mark:indent:icon:filename:type:size:time')
|
||||
nnoremap <silent><buffer><expr> S
|
||||
\ defx#do_action('toggle_sort', 'time')
|
||||
nnoremap <silent><buffer><expr> md
|
||||
\ defx#do_action('remove')
|
||||
nnoremap <silent><buffer><expr> mr
|
||||
\ defx#do_action('rename')
|
||||
nnoremap <silent><buffer><expr> !
|
||||
\ defx#do_action('execute_command')
|
||||
nnoremap <silent><buffer><expr> x
|
||||
\ defx#do_action('execute_system')
|
||||
nnoremap <silent><buffer><expr> yy
|
||||
\ defx#do_action('yank_path')
|
||||
nnoremap <silent><buffer><expr> .
|
||||
\ defx#do_action('toggle_ignored_files')
|
||||
nnoremap <silent><buffer><expr> ;
|
||||
\ defx#do_action('repeat')
|
||||
nnoremap <silent><buffer><expr> h
|
||||
\ defx#do_action('cd', ['..'])
|
||||
nnoremap <silent><buffer><expr> ~
|
||||
\ defx#do_action('cd')
|
||||
nnoremap <silent><buffer><expr> q
|
||||
\ defx#do_action('quit')
|
||||
nnoremap <silent><buffer><expr> <Space>
|
||||
\ defx#do_action('toggle_select') . 'j'
|
||||
nnoremap <silent><buffer><expr> *
|
||||
\ defx#do_action('toggle_select_all')
|
||||
nnoremap <silent><buffer><expr> j
|
||||
\ line('.') == line('$') ? 'gg' : 'j'
|
||||
nnoremap <silent><buffer><expr> k
|
||||
\ line('.') == 1 ? 'G' : 'k'
|
||||
nnoremap <silent><buffer><expr> r
|
||||
\ defx#do_action('redraw')
|
||||
nnoremap <silent><buffer><expr> <C-g>
|
||||
\ defx#do_action('print')
|
||||
nnoremap <silent><buffer><expr> cd
|
||||
\ defx#do_action('change_vim_cwd')
|
||||
endfunction
|
||||
|
||||
" tagbar
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
|
||||
" NeoComplete
|
||||
let g:neocomplete#enable_at_startup = 1
|
||||
|
||||
let g:airline_powerline_fonts = 1
|
||||
|
||||
" <Leader>f{char} to move to {char}
|
||||
map <Leader>f <Plug>(easymotion-bd-f)
|
||||
nmap <Leader>f <Plug>(easymotion-overwin-f)
|
||||
" s{char}{char} to move to {char}{char}
|
||||
nmap s <Plug>(easymotion-overwin-f2)
|
||||
" Move to line
|
||||
map <Leader>L <Plug>(easymotion-bd-jk)
|
||||
nmap <Leader>L <Plug>(easymotion-overwin-line)
|
||||
" Move to word
|
||||
map <Leader>w <Plug>(easymotion-bd-w)
|
||||
nmap <Leader>w <Plug>(easymotion-overwin-w)
|
||||
|
||||
" lint
|
||||
let g:ale_linters = {
|
||||
\ 'javascript': [{{js_linter}}],
|
||||
\ 'go': ['gopls'],
|
||||
\ 'rust': ['analyzer'],
|
||||
\}
|
||||
let g:ale_fixers = {'javascript': [{{js_fixer}}]}
|
||||
let g:ale_lint_on_save = 1
|
||||
let g:ale_fix_on_save = 1
|
||||
nmap <leader>= <Plug>(ale_fix)
|
||||
|
||||
" NERDCommenter
|
||||
let g:NERDSpaceDelims=1
|
||||
let g:NERDDefaultAlign='left'
|
||||
|
||||
function! MergeTab()
|
||||
let bufnums = tabpagebuflist()
|
||||
hide tabclose
|
||||
topleft vsplit
|
||||
for n in bufnums
|
||||
execute 'sbuffer ' . n
|
||||
wincmd _
|
||||
endfor
|
||||
wincmd t
|
||||
quit
|
||||
wincmd =
|
||||
endfunction
|
||||
command! MergeTab call MergeTab()
|
||||
|
||||
" LSP Settings
|
||||
" key binding
|
||||
nmap <silent> <Leader>gd :LspDefinition<CR>
|
||||
nmap <silent> <Leader>gt :tab split<CR>:LspDefinition<CR>
|
||||
nmap <silent> <Leader>p :LspHover<CR>
|
||||
nmap <silent> <Leader>gr :LspReferences<CR>
|
||||
nmap <silent> <Leader>rr :LspStopServer<CR>
|
||||
nmap <silent> <Leader>i :LspImplementation<CR>
|
||||
nmap <silent> <Leader>gs :split \| :LspDefinition <CR>
|
||||
nmap <silent> <Leader>gv :vsplit \| :LspDefinition <CR>
|
||||
nmap <silent> <Leader>gf :LspDocumentFormat<CR>
|
||||
|
||||
let g:lsp_diagnostics_enabled = 0 " disable diagnostics support
|
||||
let g:lsp_diagnostics_float_cursor = 0
|
||||
let g:lsp_diagnostics_echo_cursor = 1
|
||||
|
||||
" require node module
|
||||
" npm i -g dockerfile-language-server-nodejs
|
||||
if executable('docker-langserver')
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'docker-langserver',
|
||||
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'docker-langserver --stdio']},
|
||||
\ 'whitelist': ['dockerfile'],
|
||||
\ })
|
||||
endif
|
||||
|
||||
" require golang app
|
||||
" go get -u github.com/sourcegraph/go-langserver
|
||||
" Setting >>>>
|
||||
" 'cmd': {server_info->['go-langserver', '-gocodecompletion']},
|
||||
" 'cmd': {server_info->['gopls', '-mode', 'stdio']},
|
||||
if executable('gopls')
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'gopls',
|
||||
\ 'cmd': {server_info->['gopls']},
|
||||
\ 'whitelist': ['go'],
|
||||
\ })
|
||||
autocmd FileType go setlocal omnifunc=lsp#complete
|
||||
endif
|
||||
|
||||
if executable('deno')
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'deno',
|
||||
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'deno lsp']},
|
||||
\ 'whitelist': ['typescript', 'typescript.tsx', 'typescriptreact'],
|
||||
\ })
|
||||
endif
|
||||
|
||||
" rustup update
|
||||
" rustup component add rls rust-analysis rust-src
|
||||
" if executable('rls')
|
||||
" au User lsp_setup call lsp#register_server({
|
||||
" \ 'name': 'rls',
|
||||
" \ 'cmd': {server_info->['rustup', 'run', 'stable', 'rls']},
|
||||
" \ 'workspace_config': {'rust': {'clippy_preference': 'on'}},
|
||||
" \ 'whitelist': ['rust'],
|
||||
" \ })
|
||||
" endif
|
||||
if executable('rust-analyzer')
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'rust-analyzer',
|
||||
\ 'cmd': {server_info->['rust-analyzer']},
|
||||
\ 'workspace_config': {'rust': {'clippy_preference': 'on'}},
|
||||
\ 'whitelist': ['rust'],
|
||||
\ })
|
||||
endif
|
||||
|
||||
" LSP
|
||||
" JS/TS require
|
||||
" npm install -g typescript typescript-language-server
|
||||
if executable('typescript-language-server')
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'javascript support using typescript-language-server',
|
||||
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'typescript-language-server --stdio']},
|
||||
\ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'package.json'))},
|
||||
\ 'whitelist': ['javascript', 'javascript.jsx'],
|
||||
\ })
|
||||
|
||||
au User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'typescript support using typescript-language-server',
|
||||
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'typescript-language-server --stdio']},
|
||||
\ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'tsconfig.json'))},
|
||||
\ 'whitelist': ['typescript', 'typescript.tsx', 'typescriptreact'],
|
||||
\ })
|
||||
endif
|
||||
|
||||
" auto completer
|
||||
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
|
||||
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
|
||||
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"
|
||||
|
||||
" set completeopt+=preview
|
||||
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
|
||||
let g:asyncomplete_auto_popup = 0
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~ '\s'
|
||||
endfunction
|
||||
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ asyncomplete#force_refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
|
||||
call asyncomplete#register_source(asyncomplete#sources#gocode#get_source_options({
|
||||
\ 'name': 'gocode',
|
||||
\ 'whitelist': ['go'],
|
||||
\ 'completor': function('asyncomplete#sources#gocode#completor'),
|
||||
\ }))
|
||||
|
||||
call asyncomplete#register_source(asyncomplete#sources#tscompletejob#get_source_options({
|
||||
\ 'name': 'tscompletejob',
|
||||
\ 'whitelist': ['typescript'],
|
||||
\ 'completor': function('asyncomplete#sources#tscompletejob#completor'),
|
||||
\ }))
|
||||
|
||||
let g:tagbar_type_go = {
|
||||
\ 'ctagstype' : 'go',
|
||||
\ 'kinds' : [
|
||||
\ 'p:package',
|
||||
\ 'i:imports:1',
|
||||
\ 'c:constants',
|
||||
\ 'v:variables',
|
||||
\ 't:types',
|
||||
\ 'n:interfaces',
|
||||
\ 'w:fields',
|
||||
\ 'e:embedded',
|
||||
\ 'm:methods',
|
||||
\ 'r:constructor',
|
||||
\ 'f:functions'
|
||||
\ ],
|
||||
\ 'sro' : '.',
|
||||
\ 'kind2scope' : {
|
||||
\ 't' : 'ctype',
|
||||
\ 'n' : 'ntype'
|
||||
\ },
|
||||
\ 'scope2kind' : {
|
||||
\ 'ctype' : 't',
|
||||
\ 'ntype' : 'n'
|
||||
\ },
|
||||
\ 'ctagsbin' : 'gotags',
|
||||
\ 'ctagsargs' : '-sort -silent'
|
||||
\ }
|
||||
|
||||
" vim-go setting
|
||||
autocmd FileType go nmap tgd <Plug>(go-def-tab)
|
||||
autocmd FileType go nmap <leader>err <Plug>(go-iferr)
|
||||
let g:go_fmt_fail_silently = 1
|
||||
let g:go_fmt_command = "goimports"
|
||||
let g:go_def_mode = 'godef'
|
||||
let g:go_decls_includes = "func,type"
|
||||
let g:go_highlight_types = 1
|
||||
let g:go_highlight_fields = 1
|
||||
let g:go_highlight_functions = 1
|
||||
let g:go_highlight_function_calls = 1
|
||||
let g:go_highlight_operators = 1
|
||||
let g:go_highlight_extra_types = 1
|
||||
|
||||
" for rust-vim
|
||||
let g:rust_recommended_style = 0
|
||||
let g:rustfmt_autosave = 1
|
||||
let g:syntastic_rust_checkers = ['cargo']
|
||||
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
let g:airline#extensions#tabline#show_buffers = 0
|
||||
let g:airline#extensions#tabline#show_splits = 0
|
||||
let g:airline#extensions#tabline#show_tabs = 1
|
||||
let g:airline#extensions#tabline#show_tab_nr = 0
|
||||
let g:airline#extensions#tabline#show_tab_type = 0
|
||||
let g:airline#extensions#tabline#close_symbol = '×'
|
||||
let g:airline#extensions#tabline#show_close_button = 0
|
||||
|
||||
let g:multi_cursor_use_default_mapping=0
|
||||
|
||||
" Default mapping
|
||||
let g:multi_cursor_start_word_key = "<C-n>"
|
||||
let g:multi_cursor_select_all_word_key = '<A-n>'
|
||||
let g:multi_cursor_start_key = "g<C-n>"
|
||||
let g:multi_cursor_select_all_key = 'g<A-n>'
|
||||
let g:multi_cursor_next_key = "<C-n>"
|
||||
" let g:multi_cursor_prev_key = '<C-p>'
|
||||
let g:multi_cursor_skip_key = '<C-x>'
|
||||
let g:multi_cursor_quit_key = '<Esc>'
|
||||
|
||||
let g:javascript_plugin_jsdoc = 1
|
3
zsh/30_alias.zsh
Normal file
3
zsh/30_alias.zsh
Normal file
@ -0,0 +1,3 @@
|
||||
alias k="kubectl"
|
||||
alias nv="nvim"
|
||||
alias ls="ls --color=auto"
|
@ -1 +0,0 @@
|
||||
alias k="kubectl"
|
Loading…
Reference in New Issue
Block a user