From d4e1469e4b0c5aaf5c23be555e8b224f9254d781 Mon Sep 17 00:00:00 2001 From: gxlin Date: Thu, 15 Jul 2021 21:28:06 +0800 Subject: A usable boostrap config --- .vim/.gitignore | 3 ++ .vim/filetype.vim | 3 ++ .vim/init.vim | 105 ----------------------------------------- .vim/plugin/airline.plug | 4 ++ .vim/plugin/ale.vim | 24 ++++++++++ .vim/plugin/asyncrun.plug | 5 ++ .vim/plugin/easymotion.plug | 3 ++ .vim/plugin/fugitive.plug | 7 +++ .vim/plugin/general.plug | 10 ++++ .vim/plugin/godot.vim | 35 ++++++++++++++ .vim/plugin/gutentags.plug | 8 ++++ .vim/plugin/init.vim | 28 +++++++++++ .vim/plugin/lang.plug | 2 + .vim/plugin/leaderf.vim | 21 +++++++++ .vim/plugin/ledger.plug | 14 ++++++ .vim/plugin/lsp.plug | 39 +++++++++++++++ .vim/plugin/markdown.plug | 4 ++ .vim/plugin/misc.plug | 14 ++++++ .vim/plugin/slime.plug | 15 ++++++ .vim/plugin/tex.plug | 1 + .vim/plugin/vimspector.plug | 68 ++++++++++++++++++++++++++ .vim/plugin/vimwiki.plug | 9 ++++ .vim/plugin/vista.plug | 9 ++++ .vim/plugin/youcompleteme.vim | 13 +++++ .vim/plugins/airline.plug | 4 -- .vim/plugins/ale.vim | 24 ---------- .vim/plugins/asyncrun.plug | 5 -- .vim/plugins/easymotion.plug | 3 -- .vim/plugins/fugitive.plug | 7 --- .vim/plugins/general.plug | 10 ---- .vim/plugins/godot.vim | 35 -------------- .vim/plugins/gutentags.plug | 8 ---- .vim/plugins/init.vim | 28 ----------- .vim/plugins/lang.plug | 2 - .vim/plugins/leaderf.vim | 21 --------- .vim/plugins/ledger.plug | 14 ------ .vim/plugins/lsp.plug | 39 --------------- .vim/plugins/markdown.plug | 4 -- .vim/plugins/misc.plug | 16 ------- .vim/plugins/slime.plug | 15 ------ .vim/plugins/startify.plug | 1 - .vim/plugins/tex.plug | 1 - .vim/plugins/vimspector.plug | 68 -------------------------- .vim/plugins/vimwiki.plug | 9 ---- .vim/plugins/vista.plug | 9 ---- .vim/plugins/youcompleteme.vim | 13 ----- .vimrc | 105 +++++++++++++++++++++++++++++++++++++++++ bootstrap.sh | 33 +++++++++++-- 48 files changed, 474 insertions(+), 444 deletions(-) create mode 100644 .vim/.gitignore create mode 100644 .vim/filetype.vim delete mode 100644 .vim/init.vim create mode 100644 .vim/plugin/airline.plug create mode 100644 .vim/plugin/ale.vim create mode 100644 .vim/plugin/asyncrun.plug create mode 100644 .vim/plugin/easymotion.plug create mode 100644 .vim/plugin/fugitive.plug create mode 100644 .vim/plugin/general.plug create mode 100644 .vim/plugin/godot.vim create mode 100644 .vim/plugin/gutentags.plug create mode 100644 .vim/plugin/init.vim create mode 100644 .vim/plugin/lang.plug create mode 100644 .vim/plugin/leaderf.vim create mode 100644 .vim/plugin/ledger.plug create mode 100644 .vim/plugin/lsp.plug create mode 100644 .vim/plugin/markdown.plug create mode 100644 .vim/plugin/misc.plug create mode 100644 .vim/plugin/slime.plug create mode 100644 .vim/plugin/tex.plug create mode 100644 .vim/plugin/vimspector.plug create mode 100644 .vim/plugin/vimwiki.plug create mode 100644 .vim/plugin/vista.plug create mode 100644 .vim/plugin/youcompleteme.vim delete mode 100644 .vim/plugins/airline.plug delete mode 100644 .vim/plugins/ale.vim delete mode 100644 .vim/plugins/asyncrun.plug delete mode 100644 .vim/plugins/easymotion.plug delete mode 100644 .vim/plugins/fugitive.plug delete mode 100644 .vim/plugins/general.plug delete mode 100644 .vim/plugins/godot.vim delete mode 100644 .vim/plugins/gutentags.plug delete mode 100644 .vim/plugins/init.vim delete mode 100644 .vim/plugins/lang.plug delete mode 100644 .vim/plugins/leaderf.vim delete mode 100644 .vim/plugins/ledger.plug delete mode 100644 .vim/plugins/lsp.plug delete mode 100644 .vim/plugins/markdown.plug delete mode 100644 .vim/plugins/misc.plug delete mode 100644 .vim/plugins/slime.plug delete mode 100644 .vim/plugins/startify.plug delete mode 100644 .vim/plugins/tex.plug delete mode 100644 .vim/plugins/vimspector.plug delete mode 100644 .vim/plugins/vimwiki.plug delete mode 100644 .vim/plugins/vista.plug delete mode 100644 .vim/plugins/youcompleteme.vim create mode 100644 .vimrc diff --git a/.vim/.gitignore b/.vim/.gitignore new file mode 100644 index 0000000..3c1968e --- /dev/null +++ b/.vim/.gitignore @@ -0,0 +1,3 @@ +plugged +autoload +.swp diff --git a/.vim/filetype.vim b/.vim/filetype.vim new file mode 100644 index 0000000..4d7e2c5 --- /dev/null +++ b/.vim/filetype.vim @@ -0,0 +1,3 @@ +augroup filetypedetect + autocmd BufRead,BufNewFile *mutt-* setfiletype mail +augroup end diff --git a/.vim/init.vim b/.vim/init.vim deleted file mode 100644 index 73c025b..0000000 --- a/.vim/init.vim +++ /dev/null @@ -1,105 +0,0 @@ -" General Config - -set nocompatible -set number -set backspace=indent,eol,start -syntax on -set fileencodings=ucs=bom,utf-8,utf-16,gbk,big5,gb18030,latin1 -set t_Co=256 -set showcmd -set autoread -set mouse=a -filetype indent on -set modeline -set textwidth=72 -set formatoptions+=mB -set formatoptions-=tc -set secure - -set hidden - -set completeopt=menu,menuone - -if $COLORTERM is 'truecolor' - set termguicolors -endif - -" Correct background rendering in some terminal -let &t_ut='' - -" MacVim - -if has("gui_running") - if has("gui_macvim") - set guifont=Monaco:h15 - set transparency=10 - set noimdisable - - noremap :tabn 1 - noremap :tabn 2 - noremap :tabn 3 - noremap :tabn 4 - noremap :tabn 5 - noremap :tabn 6 - noremap :tabn 7 - noremap :tabn 8 - noremap :tabn 9 - noremap :tablat - endif -endif - -" Identation - -set autoindent -set tabstop=4 -set shiftwidth=4 -set expandtab -set softtabstop=4 - -autocmd FileType html setlocal shiftwidth=2 softtabstop=2 expandtab -autocmd FileType css setlocal shiftwidth=2 softtabstop=2 expandtab -autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 expandtab - -set wrap -"set nowrap -"set wrapmargin=4 -set scrolloff=5 -"set sidescrolloff=5 -set laststatus=2 -set ruler - -set hlsearch -set incsearch -set ignorecase -set smartcase - -" Completion - -set wildmenu -set wildmode=longest:list,full -set wildignore=*.o,*.obj,*~ -set wildignore+=*DS_Store* -set wildignore+=*.gem -set wildignore+=*.png,*.jpg,*.gif - -" change default directory -let s:vim_swapfiles_dir = expand('~/.vim/.swp/') -if !isdirectory(s:vim_swapfiles_dir) - silent! call mkdir(s:vim_swapfiles_dir, 'p') -endif -set directory=~/.vim/.swp// - -" tags -set tags=./.tags;,.tags - -" mapping -let mapleader=',' " change the key -nnoremap cd :cd %:p:h :pwd - -source ~/.dotfiles/.vim/plugins/init.vim -source ~/.dotfiles/.vim/keybindings.vim - -silent colorscheme onedark - -highlight Pmenu ctermbg=grey -set exrc diff --git a/.vim/plugin/airline.plug b/.vim/plugin/airline.plug new file mode 100644 index 0000000..a1c1b94 --- /dev/null +++ b/.vim/plugin/airline.plug @@ -0,0 +1,4 @@ +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' + +let g:airline#extensions#tabline#enabled = 1 diff --git a/.vim/plugin/ale.vim b/.vim/plugin/ale.vim new file mode 100644 index 0000000..105bfa8 --- /dev/null +++ b/.vim/plugin/ale.vim @@ -0,0 +1,24 @@ +let g:ale_linters_explicit = 1 +let g:ale_completion_enabled = 1 +let g:ale_completion_autoimport = 1 +let g:ale_completion_delay = 500 +let g:ale_echo_delay = 20 +let g:ale_lint_delay = 500 +let g:ale_echo_msg_format = '[%linter%] %code: %%s' +let g:ale_lint_on_text_changed = 'normal' +let g:ale_lint_on_insert_leave = 1 +let g:airline#extensions#ale#enabled = 1 + +let g:ale_c_gcc_options = '-Wall -O2 -std=c99' +let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14' +let g:ale_c_cppcheck_options = '' +let g:ale_cpp_cppcheck_options = '' + +let g:ale_sign_error = "\ue009\ue009" +hi! clear SpellBad +hi! clear SpellCap +hi! clear SpellRare +hi! SpellBad gui=undercurl guisp=red +hi! SpellCap gui=undercurl guisp=blue +hi! SpellRare gui=undercurl guisp=magenta + diff --git a/.vim/plugin/asyncrun.plug b/.vim/plugin/asyncrun.plug new file mode 100644 index 0000000..bed9473 --- /dev/null +++ b/.vim/plugin/asyncrun.plug @@ -0,0 +1,5 @@ +let g:asyncrun_open = 6 " the number of lines of quickfix window +let g:asyncrun_bell = 1 " the bell rings when the task is done +" use f10 to open/close asyncrun quickfix window +nnoremap :call asyncrun#quickfix_toggle(6) + diff --git a/.vim/plugin/easymotion.plug b/.vim/plugin/easymotion.plug new file mode 100644 index 0000000..ce87f12 --- /dev/null +++ b/.vim/plugin/easymotion.plug @@ -0,0 +1,3 @@ +Plug 'easymotion/vim-easymotion' + +map (easymotion-prefix) diff --git a/.vim/plugin/fugitive.plug b/.vim/plugin/fugitive.plug new file mode 100644 index 0000000..8dd25b2 --- /dev/null +++ b/.vim/plugin/fugitive.plug @@ -0,0 +1,7 @@ +" vim: ft=vim + +Plug 'tpope/vim-fugitive' + +nnoremap gl :Gclog! -- % +nnoremap gd :Gdiffsplit +nnoremap gs :G diff --git a/.vim/plugin/general.plug b/.vim/plugin/general.plug new file mode 100644 index 0000000..4bbc709 --- /dev/null +++ b/.vim/plugin/general.plug @@ -0,0 +1,10 @@ +Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'} +Plug 'Valloric/YouCompleteMe', { + \ 'do': 'python3 ./install.py --clangd-completer', + \ 'for': ['python', 'cpp', 'go', 'gdscript'] + \ } +Plug 'dense-analysis/ale' +Plug 'sheerun/vim-polyglot' + +let g:ycm_language_server = [] +let g:Lf_RootMarkers = [] diff --git a/.vim/plugin/godot.vim b/.vim/plugin/godot.vim new file mode 100644 index 0000000..49354f8 --- /dev/null +++ b/.vim/plugin/godot.vim @@ -0,0 +1,35 @@ +if has('macunix') + let g:godot_executable = '/Applications/Godot.app' +endif +if has('win32') || has('win32unix') + let g:godot_executable = '' +endif + +let g:ycm_language_server += [ + \ { + \ 'name': 'godot', + \ 'filetypes': ['gdscript'], + \ 'project_root_files': ['project.godot'], + \ 'port': 6008 + \ } + \ ] + +let g:Lf_RootMarkers += ['project.godot'] + +func! s:godot_settings() abort + setlocal tabstop=4 + nnoremap rl :GodotRunLast + nnoremap rc :GodotRunCurrent + nnoremap rr :GodotRun +endfunc + +augroup godot | au! + au FileType gdscript call s:godot_settings() +augroup end + +call ale#linter#Define('gdscript', { +\ 'name': 'godot', +\ 'lsp': 'socket', +\ 'address': '127.0.0.1:6008', +\ 'project_root': 'project.godot', +\ }) diff --git a/.vim/plugin/gutentags.plug b/.vim/plugin/gutentags.plug new file mode 100644 index 0000000..c2a7090 --- /dev/null +++ b/.vim/plugin/gutentags.plug @@ -0,0 +1,8 @@ +Plug 'ludovicchabant/vim-gutentags' + +let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project'] +let g:gutentags_ctags_tagfile = '.tags' +let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q'] +let g:gutentags_ctags_extra_args = ['--c++-kinds=+px'] +let g:gutentags_ctags_extra_args = ['--c-kinds=+px'] + diff --git a/.vim/plugin/init.vim b/.vim/plugin/init.vim new file mode 100644 index 0000000..7f71d9c --- /dev/null +++ b/.vim/plugin/init.vim @@ -0,0 +1,28 @@ +if empty(glob('~/.vim/autoload/plug.vim')) + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +let s:plugins = split(expand('~/.vim/plugin/*.plug')) +let s:settings = split(expand('~/.vim/plugin/*.vim')) + +function! s:load_plugins() + for plugin in s:plugins + exec "source " . plugin + endfor +endfunction + +function! s:load_settings() + for setting in s:settings + if setting !~ 'init.vim' + exec "source " . setting + endif + endfor +endfunction + +call plug#begin('~/.vim/plugged') +call s:load_plugins() +call plug#end() + +call s:load_settings() diff --git a/.vim/plugin/lang.plug b/.vim/plugin/lang.plug new file mode 100644 index 0000000..338de43 --- /dev/null +++ b/.vim/plugin/lang.plug @@ -0,0 +1,2 @@ +Plug 'habamax/vim-godot', {'for': 'gdscript'} + diff --git a/.vim/plugin/leaderf.vim b/.vim/plugin/leaderf.vim new file mode 100644 index 0000000..043fe1b --- /dev/null +++ b/.vim/plugin/leaderf.vim @@ -0,0 +1,21 @@ +" " Show icons, icons are shown by default +let g:Lf_ShowDevIcons = 1 + +let g:Lf_WindowPosition = 'popup' +let g:Lf_ShortcutF = "ff" + +noremap fb :=printf("Leaderf buffer %s", "") +noremap fm :=printf("Leaderf mru %s", "") +noremap ft :=printf("Leaderf bufTag %s", "") +noremap fl :=printf("Leaderf line %s", "") +noremap fr :=printf("Leaderf rg %s", "") +noremap :=printf("Leaderf! rg --current-buffer -e %s ", expand("")) +noremap :=printf("Leaderf! rg -e %s ", expand("")) + +" search visually selected text literally +xnoremap gf :=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual()) +noremap go :Leaderf! rg --recall + +let g:Lf_WorkingDirectoryMode = 'AF' + +let g:Lf_RootMarkers += ['.project', '.root', '.svn', '.git', '.hg', '.projectile'] diff --git a/.vim/plugin/ledger.plug b/.vim/plugin/ledger.plug new file mode 100644 index 0000000..b3a1e25 --- /dev/null +++ b/.vim/plugin/ledger.plug @@ -0,0 +1,14 @@ +Plug 'ledger/vim-ledger', {'for': 'ledger'} + +let g:ledger_bin = 'ledger' +let g:ledger_align_at = 50 +let g:ledger_commodity_before = 0 + +au FileType ledger call s:ledger_keymap() + +function! s:ledger_keymap() abort + noremap { ?^\d + noremap } /^\d + inoremap =ledger#autocomplete_and_align() + vnoremap :LedgerAlign +endfunction diff --git a/.vim/plugin/lsp.plug b/.vim/plugin/lsp.plug new file mode 100644 index 0000000..1a5704b --- /dev/null +++ b/.vim/plugin/lsp.plug @@ -0,0 +1,39 @@ +Plug 'prabirshrestha/vim-lsp' + +if executable('gopls') + au User lsp_setup call lsp#register_server({ + \ 'name': 'gopls', + \ 'cmd': {server_info->['gopls']}, + \ 'allowlist': ['go'], + \ }) +endif + +function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + setlocal signcolumn=no + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap gd (lsp-definition) + nmap gs (lsp-document-symbol-search) + nmap gS (lsp-workspace-symbol-search) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap rn (lsp-rename) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap K (lsp-hover) + inoremap lsp#scroll(+4) + inoremap lsp#scroll(-4) + + let g:lsp_format_sync_timeout = 1000 + autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') + + " refer to doc to add more commands +endfunction + +augroup lsp_install + au! + " call s:on_lsp_buffer_enabled only for languages that has the server registered. + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() +augroup END + diff --git a/.vim/plugin/markdown.plug b/.vim/plugin/markdown.plug new file mode 100644 index 0000000..1e12dad --- /dev/null +++ b/.vim/plugin/markdown.plug @@ -0,0 +1,4 @@ +Plug 'iamcco/markdown-preview.nvim', { + \ 'do': {-> mkdp#util#install()}, + \ 'for': ['markdown', 'vim-plug'] + \ } diff --git a/.vim/plugin/misc.plug b/.vim/plugin/misc.plug new file mode 100644 index 0000000..a634210 --- /dev/null +++ b/.vim/plugin/misc.plug @@ -0,0 +1,14 @@ +Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} + +Plug 'skywind3000/asyncrun.vim' + +let g:asyncrun_open = 6 " the number of lines of quickfix window +let g:asyncrun_bell = 1 " the bell rings when the task is done +" use f10 to open/close asyncrun quickfix window +nnoremap :call asyncrun#quickfix_toggle(6) + +Plug 'mhinz/vim-signify' +Plug 'tpope/vim-unimpaired' +Plug 'godlygeek/tabular' + +Plug 'joshdick/onedark.vim' diff --git a/.vim/plugin/slime.plug b/.vim/plugin/slime.plug new file mode 100644 index 0000000..0989a66 --- /dev/null +++ b/.vim/plugin/slime.plug @@ -0,0 +1,15 @@ +Plug 'jpalardy/vim-slime', { + \'on': [ + \'SlimeRegionSend', + \'SlimeParagraphSend', + \'SlimeConfig' + \] + \} + +let g:slime_no_mappings = 1 + +xmap SlimeRegionSend +nmap SlimeParagraphSend +nmap v SlimeConfig + +let g:slime_target = 'tmux' diff --git a/.vim/plugin/tex.plug b/.vim/plugin/tex.plug new file mode 100644 index 0000000..6c3f788 --- /dev/null +++ b/.vim/plugin/tex.plug @@ -0,0 +1 @@ +" Plug 'lervag/vimtex' diff --git a/.vim/plugin/vimspector.plug b/.vim/plugin/vimspector.plug new file mode 100644 index 0000000..a39d4bd --- /dev/null +++ b/.vim/plugin/vimspector.plug @@ -0,0 +1,68 @@ +Plug 'puremourning/vimspector', { 'on': 'VimspectorContinue' } + +let g:vimspector_install_gadgets = ['debugpy'] + +nmap dc VimspectorContinue +nmap dq VimspectorStop +nmap db VimspectorToggleBreakpoint +nmap dn VimspectorStepOver +nmap ds VimspectorStepInto +nmap df VimspectorStepOut +nmap di VimspectorBalloonEval +xmap di VimspectorBalloonEval + +let s:mapped = {} + +function! s:set_debug_keymaps() abort + if has_key(s:mapped, string(bufnr())) + return + endif + + " nmap c VimspectorContinue + " nmap q VimspectorStop + " nmap b VimspectorToggleBreakpoint + nmap m VimspectorStepOver + " nmap s VimspectorStepInto + " nmap f VimspectorStepOut + " nmap i VimspectorBalloonEval + " xmap i VimspectorBalloonEval + + let s:mapped[string(bufnr())] = {'modifiable': &modifiable} + + setlocal nomodifiable +endfunction + +function! s:unset_debug_keymaps() abort + let original_buf = bufnr() + let hidden = &hidden + + try + set hidden + for bufnr in keys(s:mapped) + try + execute 'noautocmd buffer' bufnr + " silent! nunmap c + " silent! nunmap q + " silent! nunmap b + silent! nunmap m + " silent! nunmap s + " silent! nunmap f + " silent! nunmap i + " silent! xunmap i + + let &l:modifiable = s:mapped[bufnr]['modifiable'] + endtry + endfor + finally + execute 'noautocmd buffer' original_buf + let &hidden = hidden + endtry + + let s:mapped = {} +endfunction + +augroup CustomMappings + au! + autocmd User VimspectorJumpedToFrame call s:set_debug_keymaps() + autocmd User VimspectorDebugEnded call s:unset_debug_keymaps() +augroup end diff --git a/.vim/plugin/vimwiki.plug b/.vim/plugin/vimwiki.plug new file mode 100644 index 0000000..cba8593 --- /dev/null +++ b/.vim/plugin/vimwiki.plug @@ -0,0 +1,9 @@ +Plug 'vimwiki/vimwiki' + +let g:vimwiki_list = [{'path': '~/Documents/notes', + \ 'syntax': 'markdown', 'ext': '.md'}] + +au FileType vimwiki setlocal textwidth=72 + +let g:vimwiki_CJK_length = 1 +let g:vimwiki_url_maxsave = 0 diff --git a/.vim/plugin/vista.plug b/.vim/plugin/vista.plug new file mode 100644 index 0000000..02264b9 --- /dev/null +++ b/.vim/plugin/vista.plug @@ -0,0 +1,9 @@ +Plug 'liuchengxu/vista.vim' + +let g:vista_default_executive = 'ctags' + +let g:vista_executive_for = { + \ 'go': 'vim_lsp', + \ } + +nnoremap s :Vista diff --git a/.vim/plugin/youcompleteme.vim b/.vim/plugin/youcompleteme.vim new file mode 100644 index 0000000..4c9f570 --- /dev/null +++ b/.vim/plugin/youcompleteme.vim @@ -0,0 +1,13 @@ +let g:ycm_server_log_level = 'info' +let g:ycm_add_preview_to_completeopt = 0 +let g:ycm_show_diagnostics_ui = 0 +let g:ycm_collect_identifiers_from_comments_and_strings = 1 +let g:ycm_complete_in_strings = 1 + +let g:ycm_filetype_whilelist = { + \ "c": 1, "cpp": 1, "sh": 1, "zsh": 1, + \ "python": 1, "go": 1, "gdscript": 1 + \ } +let g:ycm_filetype_blacklist = { + \ 'ledger': 1 + \ } diff --git a/.vim/plugins/airline.plug b/.vim/plugins/airline.plug deleted file mode 100644 index a1c1b94..0000000 --- a/.vim/plugins/airline.plug +++ /dev/null @@ -1,4 +0,0 @@ -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' - -let g:airline#extensions#tabline#enabled = 1 diff --git a/.vim/plugins/ale.vim b/.vim/plugins/ale.vim deleted file mode 100644 index 105bfa8..0000000 --- a/.vim/plugins/ale.vim +++ /dev/null @@ -1,24 +0,0 @@ -let g:ale_linters_explicit = 1 -let g:ale_completion_enabled = 1 -let g:ale_completion_autoimport = 1 -let g:ale_completion_delay = 500 -let g:ale_echo_delay = 20 -let g:ale_lint_delay = 500 -let g:ale_echo_msg_format = '[%linter%] %code: %%s' -let g:ale_lint_on_text_changed = 'normal' -let g:ale_lint_on_insert_leave = 1 -let g:airline#extensions#ale#enabled = 1 - -let g:ale_c_gcc_options = '-Wall -O2 -std=c99' -let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14' -let g:ale_c_cppcheck_options = '' -let g:ale_cpp_cppcheck_options = '' - -let g:ale_sign_error = "\ue009\ue009" -hi! clear SpellBad -hi! clear SpellCap -hi! clear SpellRare -hi! SpellBad gui=undercurl guisp=red -hi! SpellCap gui=undercurl guisp=blue -hi! SpellRare gui=undercurl guisp=magenta - diff --git a/.vim/plugins/asyncrun.plug b/.vim/plugins/asyncrun.plug deleted file mode 100644 index bed9473..0000000 --- a/.vim/plugins/asyncrun.plug +++ /dev/null @@ -1,5 +0,0 @@ -let g:asyncrun_open = 6 " the number of lines of quickfix window -let g:asyncrun_bell = 1 " the bell rings when the task is done -" use f10 to open/close asyncrun quickfix window -nnoremap :call asyncrun#quickfix_toggle(6) - diff --git a/.vim/plugins/easymotion.plug b/.vim/plugins/easymotion.plug deleted file mode 100644 index ce87f12..0000000 --- a/.vim/plugins/easymotion.plug +++ /dev/null @@ -1,3 +0,0 @@ -Plug 'easymotion/vim-easymotion' - -map (easymotion-prefix) diff --git a/.vim/plugins/fugitive.plug b/.vim/plugins/fugitive.plug deleted file mode 100644 index 8dd25b2..0000000 --- a/.vim/plugins/fugitive.plug +++ /dev/null @@ -1,7 +0,0 @@ -" vim: ft=vim - -Plug 'tpope/vim-fugitive' - -nnoremap gl :Gclog! -- % -nnoremap gd :Gdiffsplit -nnoremap gs :G diff --git a/.vim/plugins/general.plug b/.vim/plugins/general.plug deleted file mode 100644 index 4bbc709..0000000 --- a/.vim/plugins/general.plug +++ /dev/null @@ -1,10 +0,0 @@ -Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'} -Plug 'Valloric/YouCompleteMe', { - \ 'do': 'python3 ./install.py --clangd-completer', - \ 'for': ['python', 'cpp', 'go', 'gdscript'] - \ } -Plug 'dense-analysis/ale' -Plug 'sheerun/vim-polyglot' - -let g:ycm_language_server = [] -let g:Lf_RootMarkers = [] diff --git a/.vim/plugins/godot.vim b/.vim/plugins/godot.vim deleted file mode 100644 index 49354f8..0000000 --- a/.vim/plugins/godot.vim +++ /dev/null @@ -1,35 +0,0 @@ -if has('macunix') - let g:godot_executable = '/Applications/Godot.app' -endif -if has('win32') || has('win32unix') - let g:godot_executable = '' -endif - -let g:ycm_language_server += [ - \ { - \ 'name': 'godot', - \ 'filetypes': ['gdscript'], - \ 'project_root_files': ['project.godot'], - \ 'port': 6008 - \ } - \ ] - -let g:Lf_RootMarkers += ['project.godot'] - -func! s:godot_settings() abort - setlocal tabstop=4 - nnoremap rl :GodotRunLast - nnoremap rc :GodotRunCurrent - nnoremap rr :GodotRun -endfunc - -augroup godot | au! - au FileType gdscript call s:godot_settings() -augroup end - -call ale#linter#Define('gdscript', { -\ 'name': 'godot', -\ 'lsp': 'socket', -\ 'address': '127.0.0.1:6008', -\ 'project_root': 'project.godot', -\ }) diff --git a/.vim/plugins/gutentags.plug b/.vim/plugins/gutentags.plug deleted file mode 100644 index c2a7090..0000000 --- a/.vim/plugins/gutentags.plug +++ /dev/null @@ -1,8 +0,0 @@ -Plug 'ludovicchabant/vim-gutentags' - -let g:gutentags_project_root = ['.root', '.svn', '.git', '.hg', '.project'] -let g:gutentags_ctags_tagfile = '.tags' -let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q'] -let g:gutentags_ctags_extra_args = ['--c++-kinds=+px'] -let g:gutentags_ctags_extra_args = ['--c-kinds=+px'] - diff --git a/.vim/plugins/init.vim b/.vim/plugins/init.vim deleted file mode 100644 index 6b8bff2..0000000 --- a/.vim/plugins/init.vim +++ /dev/null @@ -1,28 +0,0 @@ -if empty(glob('~/.vim/autoload/plug.vim')) - silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs - \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -let s:plugins = split(expand('~/.dotfiles/.vim/plugins/*.plug')) -let s:settings = split(expand('~/.dotfiles/.vim/plugins/*.vim')) - -function! s:load_plugins() - for plugin in s:plugins - exec "source " . plugin - endfor -endfunction - -function! s:load_settings() - for setting in s:settings - if setting !~ 'init.vim' - exec "source " . setting - endif - endfor -endfunction - -call plug#begin('~/.vim/plugged') -call s:load_plugins() -call plug#end() - -call s:load_settings() diff --git a/.vim/plugins/lang.plug b/.vim/plugins/lang.plug deleted file mode 100644 index 338de43..0000000 --- a/.vim/plugins/lang.plug +++ /dev/null @@ -1,2 +0,0 @@ -Plug 'habamax/vim-godot', {'for': 'gdscript'} - diff --git a/.vim/plugins/leaderf.vim b/.vim/plugins/leaderf.vim deleted file mode 100644 index 043fe1b..0000000 --- a/.vim/plugins/leaderf.vim +++ /dev/null @@ -1,21 +0,0 @@ -" " Show icons, icons are shown by default -let g:Lf_ShowDevIcons = 1 - -let g:Lf_WindowPosition = 'popup' -let g:Lf_ShortcutF = "ff" - -noremap fb :=printf("Leaderf buffer %s", "") -noremap fm :=printf("Leaderf mru %s", "") -noremap ft :=printf("Leaderf bufTag %s", "") -noremap fl :=printf("Leaderf line %s", "") -noremap fr :=printf("Leaderf rg %s", "") -noremap :=printf("Leaderf! rg --current-buffer -e %s ", expand("")) -noremap :=printf("Leaderf! rg -e %s ", expand("")) - -" search visually selected text literally -xnoremap gf :=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual()) -noremap go :Leaderf! rg --recall - -let g:Lf_WorkingDirectoryMode = 'AF' - -let g:Lf_RootMarkers += ['.project', '.root', '.svn', '.git', '.hg', '.projectile'] diff --git a/.vim/plugins/ledger.plug b/.vim/plugins/ledger.plug deleted file mode 100644 index b3a1e25..0000000 --- a/.vim/plugins/ledger.plug +++ /dev/null @@ -1,14 +0,0 @@ -Plug 'ledger/vim-ledger', {'for': 'ledger'} - -let g:ledger_bin = 'ledger' -let g:ledger_align_at = 50 -let g:ledger_commodity_before = 0 - -au FileType ledger call s:ledger_keymap() - -function! s:ledger_keymap() abort - noremap { ?^\d - noremap } /^\d - inoremap =ledger#autocomplete_and_align() - vnoremap :LedgerAlign -endfunction diff --git a/.vim/plugins/lsp.plug b/.vim/plugins/lsp.plug deleted file mode 100644 index 1a5704b..0000000 --- a/.vim/plugins/lsp.plug +++ /dev/null @@ -1,39 +0,0 @@ -Plug 'prabirshrestha/vim-lsp' - -if executable('gopls') - au User lsp_setup call lsp#register_server({ - \ 'name': 'gopls', - \ 'cmd': {server_info->['gopls']}, - \ 'allowlist': ['go'], - \ }) -endif - -function! s:on_lsp_buffer_enabled() abort - setlocal omnifunc=lsp#complete - setlocal signcolumn=no - if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif - nmap gd (lsp-definition) - nmap gs (lsp-document-symbol-search) - nmap gS (lsp-workspace-symbol-search) - nmap gr (lsp-references) - nmap gi (lsp-implementation) - nmap gt (lsp-type-definition) - nmap rn (lsp-rename) - nmap [g (lsp-previous-diagnostic) - nmap ]g (lsp-next-diagnostic) - nmap K (lsp-hover) - inoremap lsp#scroll(+4) - inoremap lsp#scroll(-4) - - let g:lsp_format_sync_timeout = 1000 - autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') - - " refer to doc to add more commands -endfunction - -augroup lsp_install - au! - " call s:on_lsp_buffer_enabled only for languages that has the server registered. - autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() -augroup END - diff --git a/.vim/plugins/markdown.plug b/.vim/plugins/markdown.plug deleted file mode 100644 index 1e12dad..0000000 --- a/.vim/plugins/markdown.plug +++ /dev/null @@ -1,4 +0,0 @@ -Plug 'iamcco/markdown-preview.nvim', { - \ 'do': {-> mkdp#util#install()}, - \ 'for': ['markdown', 'vim-plug'] - \ } diff --git a/.vim/plugins/misc.plug b/.vim/plugins/misc.plug deleted file mode 100644 index 34de763..0000000 --- a/.vim/plugins/misc.plug +++ /dev/null @@ -1,16 +0,0 @@ -Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} - -Plug 'skywind3000/asyncrun.vim' - -let g:asyncrun_open = 6 " the number of lines of quickfix window -let g:asyncrun_bell = 1 " the bell rings when the task is done -" use f10 to open/close asyncrun quickfix window -nnoremap :call asyncrun#quickfix_toggle(6) - -Plug 'mhinz/vim-signify' -Plug 'tpope/vim-unimpaired' -Plug 'godlygeek/tabular' - -" colorscheme -" Plug 'sonph/onehalf', { 'rtp': 'vim' } -Plug 'joshdick/onedark.vim' diff --git a/.vim/plugins/slime.plug b/.vim/plugins/slime.plug deleted file mode 100644 index 0989a66..0000000 --- a/.vim/plugins/slime.plug +++ /dev/null @@ -1,15 +0,0 @@ -Plug 'jpalardy/vim-slime', { - \'on': [ - \'SlimeRegionSend', - \'SlimeParagraphSend', - \'SlimeConfig' - \] - \} - -let g:slime_no_mappings = 1 - -xmap SlimeRegionSend -nmap SlimeParagraphSend -nmap v SlimeConfig - -let g:slime_target = 'tmux' diff --git a/.vim/plugins/startify.plug b/.vim/plugins/startify.plug deleted file mode 100644 index a4f7c1d..0000000 --- a/.vim/plugins/startify.plug +++ /dev/null @@ -1 +0,0 @@ -Plug 'mhinz/vim-startify' diff --git a/.vim/plugins/tex.plug b/.vim/plugins/tex.plug deleted file mode 100644 index 6c3f788..0000000 --- a/.vim/plugins/tex.plug +++ /dev/null @@ -1 +0,0 @@ -" Plug 'lervag/vimtex' diff --git a/.vim/plugins/vimspector.plug b/.vim/plugins/vimspector.plug deleted file mode 100644 index a39d4bd..0000000 --- a/.vim/plugins/vimspector.plug +++ /dev/null @@ -1,68 +0,0 @@ -Plug 'puremourning/vimspector', { 'on': 'VimspectorContinue' } - -let g:vimspector_install_gadgets = ['debugpy'] - -nmap dc VimspectorContinue -nmap dq VimspectorStop -nmap db VimspectorToggleBreakpoint -nmap dn VimspectorStepOver -nmap ds VimspectorStepInto -nmap df VimspectorStepOut -nmap di VimspectorBalloonEval -xmap di VimspectorBalloonEval - -let s:mapped = {} - -function! s:set_debug_keymaps() abort - if has_key(s:mapped, string(bufnr())) - return - endif - - " nmap c VimspectorContinue - " nmap q VimspectorStop - " nmap b VimspectorToggleBreakpoint - nmap m VimspectorStepOver - " nmap s VimspectorStepInto - " nmap f VimspectorStepOut - " nmap i VimspectorBalloonEval - " xmap i VimspectorBalloonEval - - let s:mapped[string(bufnr())] = {'modifiable': &modifiable} - - setlocal nomodifiable -endfunction - -function! s:unset_debug_keymaps() abort - let original_buf = bufnr() - let hidden = &hidden - - try - set hidden - for bufnr in keys(s:mapped) - try - execute 'noautocmd buffer' bufnr - " silent! nunmap c - " silent! nunmap q - " silent! nunmap b - silent! nunmap m - " silent! nunmap s - " silent! nunmap f - " silent! nunmap i - " silent! xunmap i - - let &l:modifiable = s:mapped[bufnr]['modifiable'] - endtry - endfor - finally - execute 'noautocmd buffer' original_buf - let &hidden = hidden - endtry - - let s:mapped = {} -endfunction - -augroup CustomMappings - au! - autocmd User VimspectorJumpedToFrame call s:set_debug_keymaps() - autocmd User VimspectorDebugEnded call s:unset_debug_keymaps() -augroup end diff --git a/.vim/plugins/vimwiki.plug b/.vim/plugins/vimwiki.plug deleted file mode 100644 index cba8593..0000000 --- a/.vim/plugins/vimwiki.plug +++ /dev/null @@ -1,9 +0,0 @@ -Plug 'vimwiki/vimwiki' - -let g:vimwiki_list = [{'path': '~/Documents/notes', - \ 'syntax': 'markdown', 'ext': '.md'}] - -au FileType vimwiki setlocal textwidth=72 - -let g:vimwiki_CJK_length = 1 -let g:vimwiki_url_maxsave = 0 diff --git a/.vim/plugins/vista.plug b/.vim/plugins/vista.plug deleted file mode 100644 index 02264b9..0000000 --- a/.vim/plugins/vista.plug +++ /dev/null @@ -1,9 +0,0 @@ -Plug 'liuchengxu/vista.vim' - -let g:vista_default_executive = 'ctags' - -let g:vista_executive_for = { - \ 'go': 'vim_lsp', - \ } - -nnoremap s :Vista diff --git a/.vim/plugins/youcompleteme.vim b/.vim/plugins/youcompleteme.vim deleted file mode 100644 index 4c9f570..0000000 --- a/.vim/plugins/youcompleteme.vim +++ /dev/null @@ -1,13 +0,0 @@ -let g:ycm_server_log_level = 'info' -let g:ycm_add_preview_to_completeopt = 0 -let g:ycm_show_diagnostics_ui = 0 -let g:ycm_collect_identifiers_from_comments_and_strings = 1 -let g:ycm_complete_in_strings = 1 - -let g:ycm_filetype_whilelist = { - \ "c": 1, "cpp": 1, "sh": 1, "zsh": 1, - \ "python": 1, "go": 1, "gdscript": 1 - \ } -let g:ycm_filetype_blacklist = { - \ 'ledger': 1 - \ } diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..3e98c85 --- /dev/null +++ b/.vimrc @@ -0,0 +1,105 @@ +" General Config + +set nocompatible +set number +set backspace=indent,eol,start +syntax on +set fileencodings=ucs=bom,utf-8,utf-16,gbk,big5,gb18030,latin1 +set t_Co=256 +set showcmd +set autoread +set mouse=a +filetype indent on +set modeline +set textwidth=72 +set formatoptions+=mB +set formatoptions-=tc +set secure + +set hidden + +set completeopt=menu,menuone + +if $COLORTERM is 'truecolor' + set termguicolors +endif + +" Correct background rendering in some terminal +let &t_ut='' + +" MacVim + +if has("gui_running") + if has("gui_macvim") + set guifont=Monaco:h15 + set transparency=10 + set noimdisable + + noremap :tabn 1 + noremap :tabn 2 + noremap :tabn 3 + noremap :tabn 4 + noremap :tabn 5 + noremap :tabn 6 + noremap :tabn 7 + noremap :tabn 8 + noremap :tabn 9 + noremap :tablat + endif +endif + +" Identation + +set autoindent +set tabstop=4 +set shiftwidth=4 +set expandtab +set softtabstop=4 + +autocmd FileType html setlocal shiftwidth=2 softtabstop=2 expandtab +autocmd FileType css setlocal shiftwidth=2 softtabstop=2 expandtab +autocmd FileType javascript setlocal shiftwidth=2 softtabstop=2 expandtab + +set wrap +"set nowrap +"set wrapmargin=4 +set scrolloff=5 +"set sidescrolloff=5 +set laststatus=2 +set ruler + +set hlsearch +set incsearch +set ignorecase +set smartcase + +" Completion + +set wildmenu +set wildmode=longest:list,full +set wildignore=*.o,*.obj,*~ +set wildignore+=*DS_Store* +set wildignore+=*.gem +set wildignore+=*.png,*.jpg,*.gif + +" change default directory +let s:vim_swapfiles_dir = expand('~/.vim/.swp/') +if !isdirectory(s:vim_swapfiles_dir) + silent! call mkdir(s:vim_swapfiles_dir, 'p') +endif +set directory=~/.vim/.swp// + +" tags +set tags=./.tags;,.tags + +" mapping +let mapleader=',' " change the key +nnoremap cd :cd %:p:h :pwd + +source ~/.vim/plugin/init.vim +source ~/.vim/keybindings.vim + +silent colorscheme onedark + +highlight Pmenu ctermbg=grey +set exrc diff --git a/bootstrap.sh b/bootstrap.sh index aea2465..f0876f9 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -2,6 +2,33 @@ dotfiles_dir=$(cd -- "$(dirname ${BASH_SOURCE})" > /dev/null 2>&1; pwd -P) -ln -s $dotfiles_dir/.emacs.d $HOME/.emacs.d -ln -s $dotfiles_dir/.macos $HOME/.macos -ln -s $dotfiles_dir/.urlview $HOME/.urlview +remove_and_link () { + for var in $@ + do + if [ -L $HOME/$var ] && [ -e $HOME/$var ] && \ + [ "$(readlink -- $HOME/$var)" = "$dotfiles_dir/$var" ]; then + return + fi + + rm -rf $HOME/$var + ln -s $dotfiles_dir/$var $HOME/$var + done +} + +link_all () { + remove_and_link .ctags.d .mutt bin .alias .macos \ + .mbsyncrc .msmtprc .tmux.conf .urlview .zshrc \ + .vimrc .vim +} + +main () { + if [ $# -eq 0 ] || [ $1 -eq 'all' ]; then + link_all + return + fi + + remove_and_link $@ +} + +main $@ + -- cgit v1.2.3